source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py @ 15942

Last change on this file since 15942 was 15937, checked in by Henrik Bettermann, 5 years ago

Implement multiple resit fee payment.

  • Property svn:keywords set to Id
File size: 7.2 KB
RevLine 
[10765]1## $Id: browser.py 15937 2020-01-17 15:23:05Z 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 zope.component import getUtility
22from hurry.workflow.interfaces import IWorkflowInfo
23from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
24from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[15802]25from waeup.kofa.browser.layout import (
26    action, jsaction, UtilityView, KofaEditFormPage)
[10765]27from waeup.kofa.students.browser import (
28    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
[13062]29    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
[10765]30    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
[15937]31    StartClearancePage,
[10765]32    msave, emit_lock_message)
[15802]33from waeup.kofa.students.interfaces import (
34    IStudentsUtils, ICourseTicket, IStudent)
[10765]35from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
36from kofacustom.nigeria.students.browser import (
37    NigeriaOnlinePaymentDisplayFormPage,
[15704]38    NigeriaStudentBaseDisplayFormPage,
[10765]39    NigeriaStudentBaseManageFormPage,
40    NigeriaStudentClearanceEditFormPage,
41    NigeriaOnlinePaymentAddFormPage,
[13062]42    NigeriaExportPDFPaymentSlip,
43    NigeriaExportPDFClearanceSlip,
[15696]44    NigeriaExportPDFCourseRegistrationSlip,
[15704]45    NigeriaStudentBaseEditFormPage,
[15722]46    NigeriaBedTicketAddPage,
47    NigeriaAccommodationManageFormPage
[10765]48    )
49
[15563]50from kofacustom.iuokada.students.interfaces import (
[10765]51    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
[15859]52    ICustomStudentStudyLevel, ICustomStudentBase, ICustomStudent)
[15563]53from kofacustom.iuokada.interfaces import MessageFactory as _
[10765]54
[15704]55class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage):
56    """ Page to display student base data
57    """
58    form_fields = grok.AutoFields(ICustomStudentBase).omit(
59        'password', 'suspended', 'suspended_comment', 'flash_notice')
60
61class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage):
62    """ View to manage student base data
63    """
64    form_fields = grok.AutoFields(ICustomStudentBase).omit(
[15870]65        'student_id', 'adm_code', 'suspended',
66        'financially_cleared_by', 'financial_clearance_date')
[15704]67
68class StudentBaseEditFormPage(NigeriaStudentBaseEditFormPage):
69    """ View to edit student base data
70    """
71    form_fields = grok.AutoFields(ICustomStudentBase).select(
72        'email', 'email2', 'parents_email', 'phone',)
73
[15696]74class CustomExportPDFCourseRegistrationSlip(
75    NigeriaExportPDFCourseRegistrationSlip):
76    """Deliver a PDF slip of the context.
77    """
78
79    def _signatures(self):
80        return (
81                ['Student Signature'],
82                ['HoD / Course Adviser Signature'],
83                ['College Officer Signature'],
84                ['Dean Signature']
85                )
86
87    #def _sigsInFooter(self):
88    #    return (_('Student'),
89    #            _('HoD / Course Adviser'),
90    #            _('College Officer'),
91    #            _('Dean'),
92    #            )
[15720]93    #    return ()
94
[15722]95class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
96    """ Page to manage bed tickets.
97    This manage form page is for both students and students officers.
98    """
99    with_hostel_selection = True
100
[15720]101class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
102    """ Page to add a bed ticket
103    """
104    with_ac = False
[15802]105    with_bedselection = True
106
107class StudentGetMatricNumberPage(UtilityView, grok.View):
108    """ Construct and set the matriculation number.
109    """
110    grok.context(IStudent)
111    grok.name('get_matric_number')
[15805]112    grok.require('waeup.manageStudent')
[15802]113
114    def update(self):
115        students_utils = getUtility(IStudentsUtils)
116        msg, mnumber = students_utils.setMatricNumber(self.context)
117        if msg:
118            self.flash(msg, type="danger")
119        else:
120            self.flash(_('Matriculation number %s assigned.' % mnumber))
121            self.context.writeLogMessage(self, '%s assigned' % mnumber)
122        self.redirect(self.url(self.context))
123        return
124
125    def render(self):
[15859]126        return
127
128class SwitchLibraryAccessView(UtilityView, grok.View):
129    """ Switch the library attribute
130    """
131    grok.context(ICustomStudent)
132    grok.name('switch_library_access')
133    grok.require('waeup.switchLibraryAccess')
134
135    def update(self):
136        if self.context.library:
137            self.context.library = False
138            self.context.writeLogMessage(self, 'library access disabled')
139            self.flash(_('Library access disabled'))
140        else:
141            self.context.library = True
142            self.context.writeLogMessage(self, 'library access enabled')
143            self.flash(_('Library access enabled'))
144        self.redirect(self.url(self.context))
145        return
146
147    def render(self):
148        return
149
150class ExportLibIdCard(UtilityView, grok.View):
151    """Deliver an id card for the library.
152    """
153    grok.context(ICustomStudent)
154    grok.name('lib_idcard.pdf')
155    grok.require('waeup.viewStudent')
156    prefix = 'form'
157
158    label = u"Library Clearance"
159
160    omit_fields = (
161        'suspended', 'email', 'phone',
162        'adm_code', 'suspended_comment',
163        'date_of_birth',
164        'current_mode', 'certificate',
165        'entry_session',
166        'flash_notice')
167
168    form_fields = []
169
170    def _sigsInFooter(self):
171        isStudent = getattr(
172            self.request.principal, 'user_type', None) == 'student'
173        if isStudent:
174            return ''
175        return (_("Date, Reader's Signature"),
176                _("Date, Circulation Librarian's Signature"),
177                )
178
179    def update(self):
180        if not self.context.library:
181            self.flash(_('Forbidden!'), type="danger")
182            self.redirect(self.url(self.context))
183        return
184
185    @property
186    def note(self):
187        return """
188<br /><br /><br /><br /><font size='12'>
189This is to certify that the bearer whose photograph and other details appear
190 overleaf is a registered user of the <b>University Library</b>.
191 The card is not transferable. A replacement fee is charged for a loss,
192 mutilation or otherwise. If found, please, return to the University Library,
193 Igbinedion University, Okada.
194</font>
195
196"""
197        return
198
199    def render(self):
200        studentview = StudentBasePDFFormPage(self.context.student,
201            self.request, self.omit_fields)
202        students_utils = getUtility(IStudentsUtils)
203        return students_utils.renderPDF(
204            self, 'lib_idcard',
205            self.context.student, studentview,
206            omit_fields=self.omit_fields,
207            sigs_in_footer=self._sigsInFooter(),
[15937]208            note=self.note)
209
210class CustomStartClearancePage(StartClearancePage):
211    with_ac = False
Note: See TracBrowser for help on using the repository browser.