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

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

Show officers's comment in the same way as shown in the base package.

  • Property svn:keywords set to Id
File size: 8.6 KB
RevLine 
[8862]1## $Id: browser.py 9535 2012-11-05 12:13:10Z 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')
[9535]102        if not getattr(self.context, 'officer_comment'):
103            form_fields = form_fields.omit('officer_comment')
104        else:
105            form_fields['officer_comment'].custom_widget = BytesDisplayWidget
[8862]106        return form_fields
107
[8863]108class NigeriaExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
[8862]109    """Deliver a PDF slip of the context.
110    """
[9458]111    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'email')
[8862]112
113    @property
114    def form_fields(self):
[9248]115        if self.context.is_postgrad:
[8862]116            form_fields = grok.AutoFields(
[8863]117                INigeriaPGStudentClearance).omit('clearance_locked')
[8862]118        else:
119            form_fields = grok.AutoFields(
[8863]120                INigeriaUGStudentClearance).omit('clearance_locked')
[9535]121        if not getattr(self.context, 'officer_comment'):
122            form_fields = form_fields.omit('officer_comment')
[8862]123        return form_fields
124
[8863]125class NigeriaStudentClearanceManageFormPage(StudentClearanceManageFormPage):
[8862]126    """ Page to edit student clearance data
127    """
128
129    @property
130    def form_fields(self):
[9248]131        if self.context.is_postgrad:
[9249]132            form_fields = grok.AutoFields(
133                INigeriaPGStudentClearance).omit('clr_code')
[8862]134        else:
[9249]135            form_fields = grok.AutoFields(
136                INigeriaUGStudentClearance).omit('clr_code')
[8862]137        return form_fields
138
[8863]139class NigeriaStudentClearanceEditFormPage(StudentClearanceEditFormPage):
[8862]140    """ View to edit student clearance data by student
141    """
142
143    @property
144    def form_fields(self):
[9248]145        if self.context.is_postgrad:
[8946]146            form_fields = grok.AutoFields(INigeriaPGStudentClearance).omit(
[9535]147            'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment')
[8862]148        else:
[8946]149            form_fields = grok.AutoFields(INigeriaUGStudentClearance).omit(
[9535]150            'clearance_locked', 'clr_code', 'officer_comment')
[8862]151        return form_fields
152
[9376]153class NigeriaExportPDFCourseRegistrationSlipPage(ExportPDFCourseRegistrationSlipPage):
154    """Deliver a PDF slip of the context.
155    """
156    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'sex', 'email')
157
[8863]158class NigeriaOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
[8862]159    """ Page to view an online payment ticket
160    """
[8863]161    grok.context(INigeriaStudentOnlinePayment)
162    form_fields = grok.AutoFields(INigeriaStudentOnlinePayment)
[8862]163    form_fields[
164        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
165    form_fields[
166        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
167
[8863]168class NigeriaOnlinePaymentAddFormPage(OnlinePaymentAddFormPage):
[8862]169    """ Page to add an online payment ticket
170    """
[8863]171    form_fields = grok.AutoFields(INigeriaStudentOnlinePayment).select(
[8862]172        'p_category')
173
[8863]174class NigeriaOnlinePaymentFakeApprovePage(OnlinePaymentFakeApprovePage):
[8862]175    """ Disable payment approval view for students.
176
177    This view is used for browser tests only and
178    has to be neutralized here!
179    """
180    grok.name('fake_approve')
181    grok.require('waeup.managePortal')
182
183    def update(self):
184        return
185
[8863]186class NigeriaExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
[8862]187    """Deliver a PDF slip of the context.
188    """
[8863]189    grok.context(INigeriaStudentOnlinePayment)
190    form_fields = grok.AutoFields(INigeriaStudentOnlinePayment)
[8862]191    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
192    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[9376]193    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'sex', 'email')
[8862]194
[9376]195class NigeriaExportPDFBedTicketSlipPage(ExportPDFBedTicketSlipPage):
196    """Deliver a PDF slip of the context.
197    """
[9458]198    omit_fields = ('password', 'suspended', 'phone', 'adm_code', 'email')
[9376]199
[8862]200class StudentPassportActionButton(StudentPassportActionButton):
201
202    @property
203    def target_url(self):
204        slip = getUtility(IExtFileStore).getFileByContext(
205            self.context, 'application_slip')
206        if self.context.state != ADMITTED or slip is not None:
207            return ''
208        return self.view.url(self.view.context, self.target)
209
[8863]210class NigeriaStudentFilesUploadPage(StudentFilesUploadPage):
[8862]211    """ View to upload passport picture.
212
213    Students are not allowed to change the picture if they
214    passed the regular Kofa application.
215    """
216
217    def update(self):
218        slip = getUtility(IExtFileStore).getFileByContext(
219            self.context, 'application_slip')
220        if self.context.state != ADMITTED or slip is not None:
221            emit_lock_message(self)
222            return
223        super(StudentFilesUploadPage, self).update()
224        return
Note: See TracBrowser for help on using the repository browser.