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

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

Disable displaying transaction code.

Students are not allowed to change their portrait if they passed the regular Kofa application
and thus their application picture exists.

  • Property svn:keywords set to Id
File size: 8.8 KB
RevLine 
[7505]1## $Id: browser.py 8720 2012-06-14 07:18:20Z 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
[8137]20from zope.component import getUtility
[8259]21from zope.i18n import translate
[8247]22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[8137]23from waeup.kofa.interfaces import IExtFileStore
[8247]24from waeup.kofa.browser.layout import action
[7822]25from waeup.kofa.students.browser import (
[8129]26    StudentPersonalDisplayFormPage,
[7525]27    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
[8421]28    StudentClearanceDisplayFormPage, OnlinePaymentFakeApprovePage,
[8076]29    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
[8247]30    StudentBaseEditFormPage, StudentPersonalEditFormPage,
31    OnlinePaymentDisplayFormPage, OnlinePaymentAddFormPage,
[8720]32    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
33    StudentFilesUploadPage, emit_lock_message)
[8259]34from waeup.kofa.students.viewlets import (
[8720]35    PaymentReceiptActionButton, StudentPassportActionButton)
[8020]36from waeup.uniben.students.interfaces import (
[8204]37    ICustomStudentBase, ICustomStudent, ICustomStudentPersonal,
38    ICustomUGStudentClearance,ICustomPGStudentClearance,
[8247]39    ICustomStudentOnlinePayment,
[7879]40    )
[8720]41from waeup.kofa.students.workflow import ADMITTED
[8020]42from waeup.uniben.interfaces import MessageFactory as _
[7505]43
[8259]44#class RequestCallbackActionButton(RequestCallbackActionButton):
45#    """ Display the base package callback button in custom pages.
46#    """
47#    grok.context(ICustomStudentOnlinePayment)
48
49#class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
50#    """ Activate callback simulation view
51#    """
52#    grok.context(ICustomStudentOnlinePayment)
53
[8247]54class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
55    """A breadcrumb for payments.
56    """
57    grok.context(ICustomStudentOnlinePayment)
58
[8259]59class PaymentReceiptActionButton(PaymentReceiptActionButton):
60    grok.order(4)
61    grok.context(ICustomStudentOnlinePayment)
[7998]62
[8204]63class CustomStudentBaseManageFormPage(StudentBaseManageFormPage):
[8076]64    """ View to manage student base data
65    """
[8204]66    form_fields = grok.AutoFields(ICustomStudentBase).omit('student_id')
[8076]67
[8204]68class CustomStudentBaseEditFormPage(StudentBaseEditFormPage):
[8076]69    """ View to edit student base data
70    """
[8204]71    form_fields = grok.AutoFields(ICustomStudentBase).select(
[8076]72        'email', 'phone')
73
74
[8204]75class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
[7505]76    """ Page to display student personal data
77    """
[8204]78    grok.context(ICustomStudent)
79    form_fields = grok.AutoFields(ICustomStudentPersonal)
[7505]80    form_fields['perm_address'].custom_widget = BytesDisplayWidget
81
82
[8204]83class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage):
[8140]84    """ Page to edit personal data
85    """
[8204]86    form_fields = grok.AutoFields(ICustomStudentPersonal)
[8140]87
88
[8204]89class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
[7525]90    """ Page to display student clearance data
91    """
[8204]92    grok.context(ICustomStudent)
[7525]93
[7995]94    @property
95    def form_fields(self):
96        cm = getattr(self.context,'current_mode', None)
97        if cm is not None and cm.startswith('pg'):
[8204]98            form_fields = grok.AutoFields(
99                ICustomPGStudentClearance).omit('clearance_locked')
[7995]100        else:
[8204]101            form_fields = grok.AutoFields(
102                ICustomUGStudentClearance).omit('clearance_locked')
[7995]103        return form_fields
104
[8204]105class CustomExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
[7995]106    """Deliver a PDF slip of the context.
107    """
[8204]108    grok.context(ICustomStudent)
[7995]109
110    @property
111    def form_fields(self):
112        cm = getattr(self.context,'current_mode', None)
113        if cm is not None and cm.startswith('pg'):
[8204]114            form_fields = grok.AutoFields(
115                ICustomPGStudentClearance).omit('clearance_locked')
[7995]116        else:
[8204]117            form_fields = grok.AutoFields(
118                ICustomUGStudentClearance).omit('clearance_locked')
[7995]119        return form_fields
120
[8204]121class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage):
[7525]122    """ Page to edit student clearance data
123    """
[8204]124    grok.context(ICustomStudent)
[7525]125
[7995]126    @property
127    def form_fields(self):
128        cm = getattr(self.context,'current_mode', None)
129        if cm is not None and cm.startswith('pg'):
[8204]130            form_fields = grok.AutoFields(ICustomPGStudentClearance)
[7995]131        else:
[8204]132            form_fields = grok.AutoFields(ICustomUGStudentClearance)
[7995]133        return form_fields
134
[8204]135class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage):
[7525]136    """ View to edit student clearance data by student
137    """
[8204]138    grok.context(ICustomStudent)
[7525]139
[7995]140    @property
141    def form_fields(self):
142        cm = getattr(self.context,'current_mode', None)
143        if cm is not None and cm.startswith('pg'):
[8204]144            form_fields = grok.AutoFields(ICustomPGStudentClearance).omit('clearance_locked')
[7995]145        else:
[8204]146            form_fields = grok.AutoFields(ICustomUGStudentClearance).omit('clearance_locked')
[7995]147        return form_fields
148
[8137]149    def dataNotComplete(self):
150        store = getUtility(IExtFileStore)
151        if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'):
152            return _('No birth certificate uploaded.')
153        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
154            return _('No referee letter uploaded.')
155        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
156            return _('No acceptance letter uploaded.')
157        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
158            return _('No first sitting result uploaded.')
159        return False
160
[8247]161class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
162    """ Page to view an online payment ticket
163    """
164    grok.context(ICustomStudentOnlinePayment)
165    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
166    form_fields[
167        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
168    form_fields[
169        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
[8720]170    #grok.template('payment_view')
[8247]171
[8720]172    #@property
173    #def transaction_code(self):
174    #    tcode = self.context.p_id
175    #    return tcode[len(tcode)-8:len(tcode)]
[8247]176
177class CustomOnlinePaymentAddFormPage(OnlinePaymentAddFormPage):
178    """ Page to add an online payment ticket
179    """
180    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
181        'p_category')
182
[8421]183class CustomOnlinePaymentFakeApprovePage(OnlinePaymentFakeApprovePage):
184    """ Disable payment approval view for students.
185
186    This view is used for browser tests only and
187    has to be neutralized here!
188    """
189
190    grok.name('fake_approve')
191    grok.require('waeup.managePortal')
192
193    def update(self):
194        return
195
[8259]196class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
197    """Deliver a PDF slip of the context.
198    """
199    grok.context(ICustomStudentOnlinePayment)
200    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
201    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
202    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
203
[8720]204#    @property
205#    def note(self):
206#        tcode = self.context.p_id
207#        tcode = tcode[len(tcode)-8:len(tcode)]
208#        amount = self.context.amount_auth
209#        note = translate(_(
210#            u"""<br /><br /><br />
211#The tranzaction code is <strong>${a}</strong>.""",
212#            mapping = {'a':tcode}))
213#        return note
214
215class StudentPassportActionButton(StudentPassportActionButton):
216
[8259]217    @property
[8720]218    def target_url(self):
219        slip = getUtility(IExtFileStore).getFileByContext(
220            self.context, 'application_slip')
221        if self.context.state != ADMITTED or slip is not None:
222            return ''
223        return self.view.url(self.view.context, self.target)
224
225class CustomStudentFilesUploadPage(StudentFilesUploadPage):
226    """ View to upload passport picture.
227
228    Students are not allowed to change the picture if they
229    passed the regular Kofa application.
230    """
231
232    def update(self):
233        slip = getUtility(IExtFileStore).getFileByContext(
234            self.context, 'application_slip')
235        if self.context.state != ADMITTED or slip is not None:
236            emit_lock_message(self)
237            return
238        super(StudentFilesUploadPage, self).update()
239        return
Note: See TracBrowser for help on using the repository browser.