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

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

Adjust configuration to trunk merged with uli-zc-async.

  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1## $Id: browser.py 9222 2012-09-21 21:07:14Z 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 zope.schema.interfaces import ConstraintNotSatisfied
21from waeup.kofa.interfaces import REQUESTED
22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
23from waeup.kofa.browser.layout import KofaEditFormPage
24from waeup.kofa.browser.viewlets import ManageActionButton
25from waeup.kofa.browser.layout import action
26from waeup.kofa.students.browser import (
27    StudentClearPage, StudentRejectClearancePage,
28    StudyCourseDisplayFormPage, msave, emit_lock_message)
29from kofacustom.nigeria.students.browser import (
30    NigeriaOnlinePaymentDisplayFormPage,
31    NigeriaOnlinePaymentAddFormPage,
32    NigeriaExportPDFPaymentSlipPage)
33
34from waeup.uniben.students.interfaces import (
35    ICustomStudentOnlinePayment, ICustomStudentStudyCourse)
36from waeup.uniben.interfaces import MessageFactory as _
37
38class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
39    """ Page to view an online payment ticket
40    """
41    grok.context(ICustomStudentOnlinePayment)
42    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
43    form_fields[
44        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
45    form_fields[
46        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
47
48class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
49    """ Page to add an online payment ticket
50    """
51    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
52        'p_category')
53
54class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
55    """Deliver a PDF slip of the context.
56    """
57    grok.context(ICustomStudentOnlinePayment)
58    form_fields = grok.AutoFields(ICustomStudentOnlinePayment)
59    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
60    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
61
62
63## In case we need to deactivate clearance
64#class CustomStudentClearPage(StudentClearPage):
65#    """ Clear student by clearance officer
66#    """
67#    def update(self):
68#        self.flash('Clearance temporarily disabled!')
69#        self.redirect(self.url(self.context,'view_clearance'))
70#        return
71
72#class CustomStudentRejectClearancePage(StudentRejectClearancePage):
73#    """ Reject clearance by clearance officers
74#    """
75
76#    def update(self):
77#        self.flash('Clearance temporarily disabled!')
78#        self.redirect(self.url(self.context,'view_clearance'))
79#        return
80
81class StudyCourseEditActionButton(ManageActionButton):
82    grok.order(1)
83    grok.context(ICustomStudentStudyCourse)
84    grok.view(StudyCourseDisplayFormPage)
85    grok.require('waeup.clearStudent')
86    text = _('Edit level')
87    target = 'edit_level'
88
89    @property
90    def target_url(self):
91        if self.context.is_current and self.context.student.state == REQUESTED:
92            return self.view.url(self.view.context, self.target)
93        return False
94
95class StudyCourseCOEditFormPage(KofaEditFormPage):
96    """ Page to edit the student study course data by clearance officers
97
98    This form page is available only in Uniben.
99    """
100    grok.context(ICustomStudentStudyCourse)
101    grok.name('edit_level')
102    grok.require('waeup.clearStudent')
103    label = _('Edit current level')
104    pnav = 4
105    form_fields = grok.AutoFields(
106        ICustomStudentStudyCourse).select('current_level')
107
108    def update(self):
109        if not (self.context.is_current and
110            self.context.student.state == REQUESTED):
111            emit_lock_message(self)
112            return
113        super(StudyCourseCOEditFormPage, self).update()
114        return
115
116    @action(_('Save'), style='primary')
117    def save(self, **data):
118        try:
119            msave(self, **data)
120        except ConstraintNotSatisfied:
121            # The selected level might not exist in certificate
122            self.flash(_('Current level not available for certificate.'))
123            return
124        #notify(grok.ObjectModifiedEvent(self.context.__parent__))
125        return
Note: See TracBrowser for help on using the repository browser.