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

Last change on this file since 8119 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
Line 
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
20from waeup.kofa.widgets.datewidget import (
21    FriendlyDateWidget, FriendlyDateDisplayWidget
22    )
23from waeup.kofa.students.browser import (
24    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
25    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
26    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
27    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
28    StudentBaseEditFormPage)
29from waeup.kofa.students.viewlets import RequestCallbackActionButton
30from waeup.uniben.students.interfaces import (
31    IStudentBase, IStudent, IStudentPersonal,
32    IUGStudentClearance,IPGStudentClearance,
33    )
34from waeup.uniben.interfaces import MessageFactory as _
35from waeup.uniben.widgets.phonewidget import PhoneWidget
36
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
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
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
71class StudentPersonalManageFormPage(StudentPersonalManageFormPage):
72    """ Page to edit student clearance data
73    """
74    grok.context(IStudent)
75    form_fields = grok.AutoFields(IStudentPersonal)
76
77class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
78    """ Page to display student clearance data
79    """
80    grok.context(IStudent)
81
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')
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')
91        else:
92            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
93        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
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')
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')
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')
114        else:
115            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
116        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
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')
121        return form_fields
122
123class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
124    """ Page to edit student clearance data
125    """
126    grok.context(IStudent)
127
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)
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')
137        else:
138            form_fields = grok.AutoFields(IUGStudentClearance)
139        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
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
146        return form_fields
147
148class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
149    """ View to edit student clearance data by student
150    """
151    grok.context(IStudent)
152
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')
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')
162        else:
163            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
164        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
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')
169        return form_fields
170
Note: See TracBrowser for help on using the repository browser.