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

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

Remove some fields from CustomStudentBaseManageFormPage?.

Change headings.

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