[8911] | 1 | ## $Id: browser.py 9945 2013-02-13 10:19:34Z 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 | ## |
---|
| 18 | import grok |
---|
| 19 | from zope.i18n import translate |
---|
[9945] | 20 | from zope.component import getUtility |
---|
[9156] | 21 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[9945] | 22 | from waeup.kofa.interfaces import ADMITTED, IKofaUtils |
---|
[9156] | 23 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[8911] | 24 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[9945] | 25 | from waeup.kofa.students.browser import ( |
---|
| 26 | StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage) |
---|
[8911] | 27 | from kofacustom.nigeria.students.browser import ( |
---|
| 28 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 29 | NigeriaOnlinePaymentAddFormPage, |
---|
[9181] | 30 | NigeriaExportPDFPaymentSlipPage, |
---|
[9190] | 31 | NigeriaStudentClearanceEditFormPage, |
---|
| 32 | ) |
---|
[8911] | 33 | |
---|
[8913] | 34 | from waeup.fceokene.students.interfaces import ICustomStudentOnlinePayment |
---|
[8911] | 35 | |
---|
[9945] | 36 | class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage): |
---|
| 37 | """Deliver a PDF Admission slip. |
---|
| 38 | """ |
---|
| 39 | |
---|
| 40 | @property |
---|
| 41 | def label(self): |
---|
| 42 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 43 | return translate(_('Admission Letter of'), |
---|
| 44 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 45 | + ' %s' % self.context.display_fullname |
---|
| 46 | |
---|
| 47 | @property |
---|
| 48 | def label(self): |
---|
| 49 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 50 | lang = self.request.cookies.get('kofa.language', portal_language) |
---|
| 51 | line0 = '' |
---|
| 52 | if self.context.student.current_mode.startswith('ug'): |
---|
| 53 | line0 = 'IN AFFILIATION WITH UNIVERSITY OF IBADAN\n' |
---|
| 54 | line1 = translate(_('Admission Letter of'), |
---|
| 55 | 'waeup.kofa', target_language=portal_language) \ |
---|
| 56 | + ' %s' % self.context.display_fullname |
---|
| 57 | return '%s%s' % (line0, line1) |
---|
| 58 | |
---|
[8911] | 59 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 60 | """ Page to view an online payment ticket |
---|
| 61 | """ |
---|
| 62 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 63 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
| 64 | 'provider_amt', 'gateway_amt', 'thirdparty_amt') |
---|
[8911] | 65 | form_fields[ |
---|
| 66 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 67 | form_fields[ |
---|
| 68 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 69 | |
---|
| 70 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 71 | """ Page to add an online payment ticket |
---|
| 72 | """ |
---|
| 73 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
| 74 | 'p_category') |
---|
| 75 | |
---|
| 76 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
| 77 | """Deliver a PDF slip of the context. |
---|
| 78 | """ |
---|
| 79 | grok.context(ICustomStudentOnlinePayment) |
---|
[9780] | 80 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
| 81 | 'provider_amt', 'gateway_amt', 'thirdparty_amt') |
---|
[8911] | 82 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9156] | 83 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 84 | |
---|
| 85 | class CustomStartClearancePage(StartClearancePage): |
---|
| 86 | |
---|
| 87 | grok.template('startclearance') |
---|
| 88 | |
---|
| 89 | def update(self, SUBMIT=None): |
---|
| 90 | if not self.context.state == ADMITTED: |
---|
| 91 | self.flash(_("Wrong state")) |
---|
| 92 | self.redirect(self.url(self.context)) |
---|
| 93 | return |
---|
| 94 | if not self.portrait_uploaded: |
---|
| 95 | self.flash(_("No portrait uploaded.")) |
---|
| 96 | self.redirect(self.url(self.context, 'change_portrait')) |
---|
| 97 | return |
---|
| 98 | if not self.all_required_fields_filled: |
---|
| 99 | self.flash(_("Not all required fields filled.")) |
---|
| 100 | self.redirect(self.url(self.context, 'edit_base')) |
---|
| 101 | return |
---|
| 102 | if SUBMIT is None: |
---|
| 103 | return |
---|
| 104 | IWorkflowInfo(self.context).fireTransition('start_clearance') |
---|
| 105 | self.flash(_('Clearance process has been started.')) |
---|
| 106 | self.redirect(self.url(self.context,'cedit')) |
---|
[9181] | 107 | return |
---|
| 108 | |
---|
| 109 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 110 | """ View to edit student clearance data by student |
---|
| 111 | """ |
---|
| 112 | |
---|
| 113 | def dataNotComplete(self): |
---|
[9190] | 114 | return False |
---|
| 115 | |
---|
[9406] | 116 | class CustomBedTicketAddPage(BedTicketAddPage): |
---|
[9190] | 117 | """ Page to add an online payment ticket |
---|
| 118 | """ |
---|
| 119 | grok.template('bookbed') |
---|
| 120 | buttonname = _('Create bed ticket') |
---|
| 121 | notice = '' |
---|
| 122 | with_ac = False |
---|