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

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

Define required scans.

  • Property svn:keywords set to Id
File size: 8.2 KB
Line 
1## $Id: browser.py 8137 2012-04-12 20:39:44Z 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)
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 StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
75    """ Page to display student clearance data
76    """
77    grok.context(IStudent)
78
79    @property
80    def form_fields(self):
81        cm = getattr(self.context,'current_mode', None)
82        if cm is not None and cm.startswith('pg'):
83            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
84            form_fields['emp_start'].custom_widget = FriendlyDateDisplayWidget('le')
85            form_fields['emp_end'].custom_widget = FriendlyDateDisplayWidget('le')
86            form_fields['emp2_start'].custom_widget = FriendlyDateDisplayWidget('le')
87            form_fields['emp2_end'].custom_widget = FriendlyDateDisplayWidget('le')
88        else:
89            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
90        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
91        form_fields['fst_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
92        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
93        form_fields['scd_sit_date'].custom_widget = FriendlyDateDisplayWidget('le')
94        form_fields['alr_date'].custom_widget = FriendlyDateDisplayWidget('le')
95        return form_fields
96
97class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
98    """Deliver a PDF slip of the context.
99    """
100    grok.context(IStudent)
101
102    @property
103    def form_fields(self):
104        cm = getattr(self.context,'current_mode', None)
105        if cm is not None and cm.startswith('pg'):
106            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
107            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
108            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
109            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
110            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
111        else:
112            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
113        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
114        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
115        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
116        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
117        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
118        return form_fields
119
120class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
121    """ Page to edit student clearance data
122    """
123    grok.context(IStudent)
124
125    @property
126    def form_fields(self):
127        cm = getattr(self.context,'current_mode', None)
128        if cm is not None and cm.startswith('pg'):
129            form_fields = grok.AutoFields(IPGStudentClearance)
130            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
131            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
132            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
133            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
134        else:
135            form_fields = grok.AutoFields(IUGStudentClearance)
136        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
137        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
138        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
139        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
140        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
141
142
143        return form_fields
144
145class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
146    """ View to edit student clearance data by student
147    """
148    grok.context(IStudent)
149
150    @property
151    def form_fields(self):
152        cm = getattr(self.context,'current_mode', None)
153        if cm is not None and cm.startswith('pg'):
154            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
155            form_fields['emp_start'].custom_widget = FriendlyDateWidget('le-year')
156            form_fields['emp_end'].custom_widget = FriendlyDateWidget('le-year')
157            form_fields['emp2_start'].custom_widget = FriendlyDateWidget('le-year')
158            form_fields['emp2_end'].custom_widget = FriendlyDateWidget('le-year')
159        else:
160            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
161        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
162        form_fields['fst_sit_date'].custom_widget = FriendlyDateWidget('le-year')
163        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
164        form_fields['scd_sit_date'].custom_widget = FriendlyDateWidget('le-year')
165        form_fields['alr_date'].custom_widget = FriendlyDateWidget('le-year')
166        return form_fields
167
168    def dataNotComplete(self):
169        store = getUtility(IExtFileStore)
170        if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'):
171            return _('No birth certificate uploaded.')
172        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
173            return _('No referee letter uploaded.')
174        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
175            return _('No acceptance letter uploaded.')
176        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
177            return _('No first sitting result uploaded.')
178        return False
179
Note: See TracBrowser for help on using the repository browser.