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

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

... verhauen ...

  • Property svn:keywords set to Id
File size: 8.4 KB
Line 
1## $Id: browser.py 8144 2012-04-13 15:10:17Z 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 zope.component import getUtility
21from waeup.kofa.widgets.datewidget import (
22    FriendlyDateWidget, FriendlyDateDisplayWidget
23    )
24from waeup.kofa.interfaces import IExtFileStore
25from waeup.kofa.students.browser import (
26    StudentPersonalDisplayFormPage,
27    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
28    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
29    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
30    StudentBaseEditFormPage, StudentPersonalEditFormPage)
31from waeup.kofa.students.viewlets import RequestCallbackActionButton
32from waeup.uniben.students.interfaces import (
33    IStudentBase, IStudent, IStudentPersonal,
34    IUGStudentClearance,IPGStudentClearance,
35    )
36from waeup.uniben.interfaces import MessageFactory as _
37from waeup.uniben.widgets.phonewidget import PhoneWidget
38
39class RequestCallbackActionButton(RequestCallbackActionButton):
40    """ Do not display the base package callback button in custom pages.
41    """
42    @property
43    def target_url(self):
44        return ''
45
46class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
47    """ Neutralize callback simulation view
48    """
49    def update(self):
50        return
51
52class StudentBaseManageFormPage(StudentBaseManageFormPage):
53    """ View to manage student base data
54    """
55    form_fields = grok.AutoFields(IStudentBase).omit('student_id')
56    form_fields['phone'].custom_widget = PhoneWidget
57
58class StudentBaseEditFormPage(StudentBaseEditFormPage):
59    """ View to edit student base data
60    """
61    form_fields = grok.AutoFields(IStudentBase).select(
62        'email', 'phone')
63    form_fields['phone'].custom_widget = PhoneWidget
64
65
66class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
67    """ Page to display student personal data
68    """
69    grok.context(IStudent)
70    form_fields = grok.AutoFields(IStudentPersonal)
71    form_fields['perm_address'].custom_widget = BytesDisplayWidget
72
73
74class StudentPersonalEditFormPage(StudentPersonalEditFormPage):
75    """ Page to edit personal data
76    """
77    form_fields = grok.AutoFields(IStudentPersonal)
78
79
80class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
81    """ Page to display student clearance data
82    """
83    grok.context(IStudent)
84
85    @property
86    def form_fields(self):
87        cm = getattr(self.context,'current_mode', None)
88        if cm is not None and cm.startswith('pg'):
89            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
90            form_fields['emp_start'].custom_widget = FriendlyDateDisplayWidget('le')
91            form_fields['emp_end'].custom_widget = FriendlyDateDisplayWidget('le')
92            form_fields['emp2_start'].custom_widget = FriendlyDateDisplayWidget('le')
93            form_fields['emp2_end'].custom_widget = FriendlyDateDisplayWidget('le')
94        else:
95            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
96        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
97        form_fields['fst_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
98        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
99        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
100        form_fields['alr_date'].custom_widget = FriendlyDateDisplayWidget('le')
101        return form_fields
102
103class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
104    """Deliver a PDF slip of the context.
105    """
106    grok.context(IStudent)
107
108    @property
109    def form_fields(self):
110        cm = getattr(self.context,'current_mode', None)
111        if cm is not None and cm.startswith('pg'):
112            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
113            form_fields['emp_start'].custom_widget = FriendlyDateDisplayWidget('le')
114            form_fields['emp_end'].custom_widget = FriendlyDateDisplayWidget('le')
115            form_fields['emp2_start'].custom_widget = FriendlyDateDisplayWidget('le')
116            form_fields['emp2_end'].custom_widget = FriendlyDateDisplayWidget('le')
117        else:
118            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
119        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
120        form_fields['fst_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
121        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
122        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
123        form_fields['alr_date'].custom_widget = FriendlyDateDisplayWidget('le')
124        return form_fields
125
126class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
127    """ Page to edit student clearance data
128    """
129    grok.context(IStudent)
130
131    @property
132    def form_fields(self):
133        cm = getattr(self.context,'current_mode', None)
134        if cm is not None and cm.startswith('pg'):
135            form_fields = grok.AutoFields(IPGStudentClearance)
136            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
137            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
138            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
139            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
140        else:
141            form_fields = grok.AutoFields(IUGStudentClearance)
142        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
143        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
144        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
145        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
146        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
147
148
149        return form_fields
150
151class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
152    """ View to edit student clearance data by student
153    """
154    grok.context(IStudent)
155
156    @property
157    def form_fields(self):
158        cm = getattr(self.context,'current_mode', None)
159        if cm is not None and cm.startswith('pg'):
160            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
161            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
162            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
163            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
164            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
165        else:
166            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
167        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
168        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
169        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
170        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
171        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
172        return form_fields
173
174    def dataNotComplete(self):
175        store = getUtility(IExtFileStore)
176        if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'):
177            return _('No birth certificate uploaded.')
178        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
179            return _('No referee letter uploaded.')
180        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
181            return _('No acceptance letter uploaded.')
182        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
183            return _('No first sitting result uploaded.')
184        return False
185
Note: See TracBrowser for help on using the repository browser.