1 | ## $Id: browser.py 15805 2019-11-13 10:38:16Z 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 |
---|
20 | from zope.schema.interfaces import ConstraintNotSatisfied |
---|
21 | from zope.component import getUtility |
---|
22 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
23 | from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils |
---|
24 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
25 | from waeup.kofa.browser.layout import ( |
---|
26 | action, jsaction, UtilityView, KofaEditFormPage) |
---|
27 | from waeup.kofa.students.browser import ( |
---|
28 | StudyLevelEditFormPage, StudyLevelDisplayFormPage, |
---|
29 | StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip, |
---|
30 | CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage, |
---|
31 | msave, emit_lock_message) |
---|
32 | from waeup.kofa.students.interfaces import ( |
---|
33 | IStudentsUtils, ICourseTicket, IStudent) |
---|
34 | from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS |
---|
35 | from 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 | |
---|
49 | from kofacustom.iuokada.students.interfaces import ( |
---|
50 | ICustomStudentOnlinePayment, ICustomStudentStudyCourse, |
---|
51 | ICustomStudentStudyLevel, ICustomStudentBase) |
---|
52 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
53 | |
---|
54 | class 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 | |
---|
60 | class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage): |
---|
61 | """ View to manage student base data |
---|
62 | """ |
---|
63 | form_fields = grok.AutoFields(ICustomStudentBase).omit( |
---|
64 | 'student_id', 'adm_code', 'suspended') |
---|
65 | |
---|
66 | class StudentBaseEditFormPage(NigeriaStudentBaseEditFormPage): |
---|
67 | """ View to edit student base data |
---|
68 | """ |
---|
69 | form_fields = grok.AutoFields(ICustomStudentBase).select( |
---|
70 | 'email', 'email2', 'parents_email', 'phone',) |
---|
71 | |
---|
72 | class CustomExportPDFCourseRegistrationSlip( |
---|
73 | NigeriaExportPDFCourseRegistrationSlip): |
---|
74 | """Deliver a PDF slip of the context. |
---|
75 | """ |
---|
76 | |
---|
77 | def _signatures(self): |
---|
78 | return ( |
---|
79 | ['Student Signature'], |
---|
80 | ['HoD / Course Adviser Signature'], |
---|
81 | ['College Officer Signature'], |
---|
82 | ['Dean Signature'] |
---|
83 | ) |
---|
84 | |
---|
85 | #def _sigsInFooter(self): |
---|
86 | # return (_('Student'), |
---|
87 | # _('HoD / Course Adviser'), |
---|
88 | # _('College Officer'), |
---|
89 | # _('Dean'), |
---|
90 | # ) |
---|
91 | # return () |
---|
92 | |
---|
93 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
94 | """ Page to manage bed tickets. |
---|
95 | This manage form page is for both students and students officers. |
---|
96 | """ |
---|
97 | with_hostel_selection = True |
---|
98 | |
---|
99 | class CustomBedTicketAddPage(NigeriaBedTicketAddPage): |
---|
100 | """ Page to add a bed ticket |
---|
101 | """ |
---|
102 | with_ac = False |
---|
103 | with_bedselection = True |
---|
104 | |
---|
105 | class StudentGetMatricNumberPage(UtilityView, grok.View): |
---|
106 | """ Construct and set the matriculation number. |
---|
107 | """ |
---|
108 | grok.context(IStudent) |
---|
109 | grok.name('get_matric_number') |
---|
110 | grok.require('waeup.manageStudent') |
---|
111 | |
---|
112 | def update(self): |
---|
113 | students_utils = getUtility(IStudentsUtils) |
---|
114 | msg, mnumber = students_utils.setMatricNumber(self.context) |
---|
115 | if msg: |
---|
116 | self.flash(msg, type="danger") |
---|
117 | else: |
---|
118 | self.flash(_('Matriculation number %s assigned.' % mnumber)) |
---|
119 | self.context.writeLogMessage(self, '%s assigned' % mnumber) |
---|
120 | self.redirect(self.url(self.context)) |
---|
121 | return |
---|
122 | |
---|
123 | def render(self): |
---|
124 | return |
---|