source: main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py @ 8110

Last change on this file since 8110 was 8108, checked in by Henrik Bettermann, 13 years ago

Add more upload viewlets.

User our date widgets.

  • Property svn:keywords set to Id
File size: 7.7 KB
RevLine 
[7505]1## $Id: browser.py 8108 2012-04-11 13:52:36Z henrik $
2##
3## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import grok
19from zope.formlib.textwidgets import BytesDisplayWidget
[7822]20from waeup.kofa.widgets.datewidget import (
[7525]21    FriendlyDateWidget, FriendlyDateDisplayWidget
22    )
[7822]23from waeup.kofa.students.browser import (
[7525]24    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
25    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
[7998]26    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
[8076]27    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
28    StudentBaseEditFormPage)
[7879]29from waeup.kofa.students.viewlets import RequestCallbackActionButton
[8020]30from waeup.uniben.students.interfaces import (
[8076]31    IStudentBase, IStudent, IStudentPersonal,
[7995]32    IUGStudentClearance,IPGStudentClearance,
[7879]33    )
[8020]34from waeup.uniben.interfaces import MessageFactory as _
[8076]35from waeup.uniben.widgets.phonewidget import PhoneWidget
[7505]36
[7998]37class RequestCallbackActionButton(RequestCallbackActionButton):
38    """ Do not display the base package callback button in custom pages.
39    """
40    @property
41    def target_url(self):
42        return ''
43
44class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
45    """ Neutralize callback simulation view
46    """
47    def update(self):
48        return
49
[8076]50class StudentBaseManageFormPage(StudentBaseManageFormPage):
51    """ View to manage student base data
52    """
53    form_fields = grok.AutoFields(IStudentBase).omit('student_id')
54    form_fields['phone'].custom_widget = PhoneWidget
55
56class StudentBaseEditFormPage(StudentBaseEditFormPage):
57    """ View to edit student base data
58    """
59    form_fields = grok.AutoFields(IStudentBase).select(
60        'email', 'phone')
61    form_fields['phone'].custom_widget = PhoneWidget
62
63
[7505]64class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
65    """ Page to display student personal data
66    """
67    grok.context(IStudent)
68    form_fields = grok.AutoFields(IStudentPersonal)
69    form_fields['perm_address'].custom_widget = BytesDisplayWidget
70
[7525]71class StudentPersonalManageFormPage(StudentPersonalManageFormPage):
72    """ Page to edit student clearance data
73    """
74    grok.context(IStudent)
75    form_fields = grok.AutoFields(IStudentPersonal)
[7505]76
[7525]77class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
78    """ Page to display student clearance data
79    """
80    grok.context(IStudent)
81
[7995]82    @property
83    def form_fields(self):
84        cm = getattr(self.context,'current_mode', None)
85        if cm is not None and cm.startswith('pg'):
86            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
[8108]87            form_fields['emp_start'].custom_widget = FriendlyDateDisplayWidget('le')
88            form_fields['emp_end'].custom_widget = FriendlyDateDisplayWidget('le')
89            form_fields['emp2_start'].custom_widget = FriendlyDateDisplayWidget('le')
90            form_fields['emp2_end'].custom_widget = FriendlyDateDisplayWidget('le')
[7995]91        else:
92            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
93        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
[8108]94        form_fields['fst_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
95        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
96        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
97        form_fields['alr_date'].custom_widget = FriendlyDateDisplayWidget('le')
[7995]98        return form_fields
99
100class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
101    """Deliver a PDF slip of the context.
102    """
103    grok.context(IStudent)
104
105    @property
106    def form_fields(self):
107        cm = getattr(self.context,'current_mode', None)
108        if cm is not None and cm.startswith('pg'):
109            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
[8108]110            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
111            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
112            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
113            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
[7995]114        else:
115            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
116        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
[8108]117        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
118        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
119        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
120        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
[7995]121        return form_fields
122
[7525]123class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
124    """ Page to edit student clearance data
125    """
126    grok.context(IStudent)
127
[7995]128    @property
129    def form_fields(self):
130        cm = getattr(self.context,'current_mode', None)
131        if cm is not None and cm.startswith('pg'):
132            form_fields = grok.AutoFields(IPGStudentClearance)
[8108]133            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
134            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
135            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
136            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
[7995]137        else:
138            form_fields = grok.AutoFields(IUGStudentClearance)
139        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
[8108]140        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
141        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
142        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
143        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
144
145
[7995]146        return form_fields
147
[7525]148class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
149    """ View to edit student clearance data by student
150    """
151    grok.context(IStudent)
152
[7995]153    @property
154    def form_fields(self):
155        cm = getattr(self.context,'current_mode', None)
156        if cm is not None and cm.startswith('pg'):
157            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
[8108]158            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
159            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
160            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
161            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
[7995]162        else:
163            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
164        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
[8108]165        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
166        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
167        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
168        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
[7995]169        return form_fields
170
Note: See TracBrowser for help on using the repository browser.