source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/browser.py @ 9162

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

Customize StartClearancePage?. In Okene the students can just start clearance without entering an activation code.

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1## $Id: browser.py 9156 2012-09-04 11: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.i18n import translate
20from hurry.workflow.interfaces import IWorkflowInfo
21from waeup.kofa.interfaces import ADMITTED
22from waeup.kofa.interfaces import MessageFactory as _
23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
24from waeup.kofa.students.browser import StartClearancePage
25from kofacustom.nigeria.students.browser import (
26    NigeriaOnlinePaymentDisplayFormPage,
27    NigeriaOnlinePaymentAddFormPage,
28    NigeriaExportPDFPaymentSlipPage)
29
30from waeup.fceokene.students.interfaces import ICustomStudentOnlinePayment
31
32class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
33    """ Page to view an online payment ticket
34    """
35    grok.context(ICustomStudentOnlinePayment)
36    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
37    form_fields[
38        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
39    form_fields[
40        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
41
42class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
43    """ Page to add an online payment ticket
44    """
45    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
46        'p_category')
47
48class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
49    """Deliver a PDF slip of the context.
50    """
51    grok.context(ICustomStudentOnlinePayment)
52    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
53    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
54    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
55
56class CustomStartClearancePage(StartClearancePage):
57
58    grok.template('startclearance')
59
60    def update(self, SUBMIT=None):
61        if not self.context.state == ADMITTED:
62            self.flash(_("Wrong state"))
63            self.redirect(self.url(self.context))
64            return
65        if not self.portrait_uploaded:
66            self.flash(_("No portrait uploaded."))
67            self.redirect(self.url(self.context, 'change_portrait'))
68            return
69        if not self.all_required_fields_filled:
70            self.flash(_("Not all required fields filled."))
71            self.redirect(self.url(self.context, 'edit_base'))
72            return
73        if SUBMIT is None:
74            return
75        IWorkflowInfo(self.context).fireTransition('start_clearance')
76        self.flash(_('Clearance process has been started.'))
77        self.redirect(self.url(self.context,'cedit'))
78        return
Note: See TracBrowser for help on using the repository browser.