source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/browser.py @ 9458

Last change on this file since 9458 was 9458, checked in by Henrik Bettermann, 12 years ago

Show sex field on clearance slip and bed ticket slip.

  • Property svn:keywords set to Id
File size: 8.3 KB
RevLine 
[8862]1## $Id: browser.py 9458 2012-10-29 13:06: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 zope.i18n import translate
22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
23from waeup.kofa.interfaces import IExtFileStore
24from waeup.kofa.browser.layout import action
25from waeup.kofa.students.browser import (
[8904]26    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
[8862]27    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
28    StudentClearanceDisplayFormPage, OnlinePaymentFakeApprovePage,
29    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
[8966]30    StudentBaseDisplayFormPage,
[8862]31    StudentBaseEditFormPage, StudentPersonalEditFormPage,
32    OnlinePaymentDisplayFormPage, OnlinePaymentAddFormPage,
33    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
[9376]34    ExportPDFCourseRegistrationSlipPage,
35    ExportPDFBedTicketSlipPage,
[8862]36    StudentFilesUploadPage, emit_lock_message)
37from waeup.kofa.students.viewlets import (
38    PaymentReceiptActionButton, StudentPassportActionButton)
39from kofacustom.nigeria.students.interfaces import (
[8863]40    INigeriaStudentBase, INigeriaStudent, INigeriaStudentPersonal,
41    INigeriaUGStudentClearance,INigeriaPGStudentClearance,
[8904]42    INigeriaStudentOnlinePayment
[8862]43    )
44from waeup.kofa.students.workflow import ADMITTED
45from kofacustom.nigeria.interfaces import MessageFactory as _
46
[8863]47class NigeriaOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
[8862]48    """A breadcrumb for payments.
49    """
[8863]50    grok.context(INigeriaStudentOnlinePayment)
[8862]51
52class PaymentReceiptActionButton(PaymentReceiptActionButton):
53    grok.order(4)
[8863]54    grok.context(INigeriaStudentOnlinePayment)
[8862]55
[8966]56class NigeriaStudentBaseDisplayFormPage(StudentBaseDisplayFormPage):
57    """ Page to display student base data
58    """
[9144]59    form_fields = grok.AutoFields(INigeriaStudentBase).omit('password', 'suspended')
[8966]60
[8863]61class NigeriaStudentBaseManageFormPage(StudentBaseManageFormPage):
[8862]62    """ View to manage student base data
63    """
[9144]64    form_fields = grok.AutoFields(INigeriaStudentBase).omit(
65        'student_id', 'adm_code', 'suspended')
[8862]66
[8863]67class NigeriaStudentBaseEditFormPage(StudentBaseEditFormPage):
[8862]68    """ View to edit student base data
69    """
[8863]70    form_fields = grok.AutoFields(INigeriaStudentBase).select(
[8862]71        'email', 'phone')
72
[8863]73class NigeriaStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
[8862]74    """ Page to display student personal data
75    """
[8863]76    form_fields = grok.AutoFields(INigeriaStudentPersonal)
[8862]77    form_fields['perm_address'].custom_widget = BytesDisplayWidget
[9053]78    form_fields['next_kin_address'].custom_widget = BytesDisplayWidget
[8862]79
[8863]80class NigeriaStudentPersonalEditFormPage(StudentPersonalEditFormPage):
[8862]81    """ Page to edit personal data
82    """
[8863]83    form_fields = grok.AutoFields(INigeriaStudentPersonal)
[8862]84
[8904]85class NigeriaStudentPersonalManageFormPage(StudentPersonalManageFormPage):
86    """ Page to edit personal data
87    """
88    form_fields = grok.AutoFields(INigeriaStudentPersonal)
89
[8863]90class NigeriaStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
[8862]91    """ Page to display student clearance data
92    """
93
94    @property
95    def form_fields(self):
[9248]96        if self.context.is_postgrad:
[8862]97            form_fields = grok.AutoFields(
[8863]98                INigeriaPGStudentClearance).omit('clearance_locked')
[8862]99        else:
100            form_fields = grok.AutoFields(
[8863]101                INigeriaUGStudentClearance).omit('clearance_locked')
[8862]102        return form_fields
103
[8863]104class NigeriaExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
[8862]105    """Deliver a PDF slip of the context.
106    """
[9458]107    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'email')
[8862]108
109    @property
110    def form_fields(self):
[9248]111        if self.context.is_postgrad:
[8862]112            form_fields = grok.AutoFields(
[8863]113                INigeriaPGStudentClearance).omit('clearance_locked')
[8862]114        else:
115            form_fields = grok.AutoFields(
[8863]116                INigeriaUGStudentClearance).omit('clearance_locked')
[8862]117        return form_fields
118
[8863]119class NigeriaStudentClearanceManageFormPage(StudentClearanceManageFormPage):
[8862]120    """ Page to edit student clearance data
121    """
122
123    @property
124    def form_fields(self):
[9248]125        if self.context.is_postgrad:
[9249]126            form_fields = grok.AutoFields(
127                INigeriaPGStudentClearance).omit('clr_code')
[8862]128        else:
[9249]129            form_fields = grok.AutoFields(
130                INigeriaUGStudentClearance).omit('clr_code')
[8862]131        return form_fields
132
[8863]133class NigeriaStudentClearanceEditFormPage(StudentClearanceEditFormPage):
[8862]134    """ View to edit student clearance data by student
135    """
136
137    @property
138    def form_fields(self):
[9248]139        if self.context.is_postgrad:
[8946]140            form_fields = grok.AutoFields(INigeriaPGStudentClearance).omit(
[9249]141            'clearance_locked', 'nysc_location', 'clr_code')
[8862]142        else:
[8946]143            form_fields = grok.AutoFields(INigeriaUGStudentClearance).omit(
[9249]144            'clearance_locked', 'clr_code')
[8862]145        return form_fields
146
[9376]147class NigeriaExportPDFCourseRegistrationSlipPage(ExportPDFCourseRegistrationSlipPage):
148    """Deliver a PDF slip of the context.
149    """
150    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'sex', 'email')
151
[8863]152class NigeriaOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
[8862]153    """ Page to view an online payment ticket
154    """
[8863]155    grok.context(INigeriaStudentOnlinePayment)
156    form_fields = grok.AutoFields(INigeriaStudentOnlinePayment)
[8862]157    form_fields[
158        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
159    form_fields[
160        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
161
[8863]162class NigeriaOnlinePaymentAddFormPage(OnlinePaymentAddFormPage):
[8862]163    """ Page to add an online payment ticket
164    """
[8863]165    form_fields = grok.AutoFields(INigeriaStudentOnlinePayment).select(
[8862]166        'p_category')
167
[8863]168class NigeriaOnlinePaymentFakeApprovePage(OnlinePaymentFakeApprovePage):
[8862]169    """ Disable payment approval view for students.
170
171    This view is used for browser tests only and
172    has to be neutralized here!
173    """
174    grok.name('fake_approve')
175    grok.require('waeup.managePortal')
176
177    def update(self):
178        return
179
[8863]180class NigeriaExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
[8862]181    """Deliver a PDF slip of the context.
182    """
[8863]183    grok.context(INigeriaStudentOnlinePayment)
184    form_fields = grok.AutoFields(INigeriaStudentOnlinePayment)
[8862]185    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
186    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9376]187    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'sex', 'email')
[8862]188
[9376]189class NigeriaExportPDFBedTicketSlipPage(ExportPDFBedTicketSlipPage):
190    """Deliver a PDF slip of the context.
191    """
[9458]192    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'email')
[9376]193
[8862]194class StudentPassportActionButton(StudentPassportActionButton):
195
196    @property
197    def target_url(self):
198        slip = getUtility(IExtFileStore).getFileByContext(
199            self.context, 'application_slip')
200        if self.context.state != ADMITTED or slip is not None:
201            return ''
202        return self.view.url(self.view.context, self.target)
203
[8863]204class NigeriaStudentFilesUploadPage(StudentFilesUploadPage):
[8862]205    """ View to upload passport picture.
206
207    Students are not allowed to change the picture if they
208    passed the regular Kofa application.
209    """
210
211    def update(self):
212        slip = getUtility(IExtFileStore).getFileByContext(
213            self.context, 'application_slip')
214        if self.context.state != ADMITTED or slip is not None:
215            emit_lock_message(self)
216            return
217        super(StudentFilesUploadPage, self).update()
218        return
Note: See TracBrowser for help on using the repository browser.