source: main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/browser.py @ 17025

Last change on this file since 17025 was 17025, checked in by Henrik Bettermann, 2 years ago

Add continuous assessment (ca) field.

  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1## $Id: browser.py 17025 2022-07-17 08:50: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 zope.component import getUtility
22from zope.security import checkPermission
23from hurry.workflow.interfaces import IWorkflowInfo
24from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
25from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
26from waeup.kofa.browser.layout import KofaEditFormPage
27from waeup.kofa.browser.layout import action, jsaction
28from waeup.kofa.students.browser import (
29    StudyLevelEditFormPage, StudyLevelDisplayFormPage, StudyLevelManageFormPage,
30    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
31    CourseTicketDisplayFormPage, CourseTicketManageFormPage,
32    StudentTriggerTransitionFormPage,
33    PaymentsManageFormPage, msave, emit_lock_message)
34from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
35from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
36from kofacustom.nigeria.students.browser import (
37    NigeriaOnlinePaymentDisplayFormPage,
38    NigeriaStudentBaseManageFormPage,
39    NigeriaStudentClearanceEditFormPage,
40    NigeriaOnlinePaymentAddFormPage,
41    NigeriaExportPDFPaymentSlip,
42    NigeriaExportPDFClearanceSlip,
43    NigeriaBedTicketAddPage,
44    NigeriaAccommodationDisplayFormPage,
45    NigeriaAccommodationManageFormPage,
46    )
47from kofacustom.unidel.students.interfaces import (
48    ICustomStudentOnlinePayment,
49    ICustomStudentStudyCourse,
50    ICustomStudentStudyLevel,
51    ICustomUGStudentClearance,
52    ICustomPGStudentClearance,
53    ICustomCourseTicket)
54from kofacustom.unidel.interfaces import MessageFactory as _
55
56class CustomBedTicketAddPage(NigeriaBedTicketAddPage):
57    with_ac = False
58
59class CustomAccommodationDisplayFormPage(NigeriaAccommodationDisplayFormPage):
60    """ Page to view bed tickets.
61    """
62    with_hostel_selection = True
63
64class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
65    """ Page to manage bed tickets.
66    This manage form page is for both students and students officers.
67    """
68    with_hostel_selection = True
69
70class CustomPaymentsManageFormPage(PaymentsManageFormPage):
71    """ Page to manage the student payments. This manage form page is for
72    both students and students officers. UNIDEL does not allow students
73    to remove any payment ticket.
74    """
75    @property
76    def manage_payments_allowed(self):
77        return checkPermission('waeup.manageStudent', self.context)
78
79class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
80    """ View to edit student clearance data by student
81    """
82    @property
83    def form_fields(self):
84        if self.context.is_postgrad:
85            form_fields = grok.AutoFields(ICustomPGStudentClearance).omit(
86            'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment',
87            'physical_clearance_date')
88        else:
89            form_fields = grok.AutoFields(ICustomUGStudentClearance).omit(
90            'clearance_locked', 'clr_code', 'officer_comment',
91            'physical_clearance_date')
92            form_fields['date_of_birth'].for_display = True
93            form_fields['nationality'].for_display = True
94            form_fields['lga'].for_display = True
95        return form_fields
96
97class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
98    """ Page to view an online payment ticket
99    """
100    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
101        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item','p_combi',
102        'net_amt')
103    form_fields[
104        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
105    form_fields[
106        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
107
108class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip):
109    """Deliver a PDF slip of the context.
110    """
111    form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
112        'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item',
113        'p_split_data','p_combi', 'net_amt')
114    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
115    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
116
117class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
118    """ Page to display student study levels
119    """
120    #grok.template('studylevelpage')
121    grok.context(ICustomStudentStudyLevel)
122
123    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
124        'level',)
125    form_fields[
126        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
127
128class CustomStudyLevelManageFormPage(StudyLevelManageFormPage):
129    """ Page to edit the student study level data
130    """
131    grok.context(ICustomStudentStudyLevel)
132
133    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
134        'validation_date', 'validated_by', 'total_credits', 'gpa', 'level',
135        'total_credits_s1', 'total_credits_s2')
136
137class CustomExportPDFCourseRegistrationSlip(ExportPDFCourseRegistrationSlip):
138    """Deliver a PDF slip of the context.
139    """
140    grok.context(ICustomStudentStudyLevel)
141    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
142        'level', 'gpa', 'transcript_remark')
143    form_fields[
144        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
145    #prefix = 'form'
146    omit_fields = (
147        'password', 'suspended', 'phone', 'date_of_birth',
148        'adm_code', 'sex', 'suspended_comment', 'current_level',
149        'flash_notice')
150
151    def _signatures(self):
152        return ([_('Academic Adviser\'s Signature')],
153                [_('Faculty Officer\'s Signature')],
154                [_('Student\'s Signature')])
155
156class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage):
157    """ Page to display course tickets
158    """
159
160    @property
161    def form_fields(self):
162        return grok.AutoFields(ICustomCourseTicket).omit('course_category',
163            'ticket_session')
164
165class CustomCourseTicketManageFormPage(CourseTicketManageFormPage):
166    """ Page to manage course tickets
167    """
168   
169    form_fields = grok.AutoFields(ICustomCourseTicket).omit('course_category')
170    form_fields['title'].for_display = True
171    form_fields['fcode'].for_display = True
172    form_fields['dcode'].for_display = True
173    form_fields['semester'].for_display = True
174    form_fields['passmark'].for_display = True
175    form_fields['credits'].for_display = True
176    form_fields['mandatory'].for_display = False
177    form_fields['automatic'].for_display = True
178    form_fields['carry_over'].for_display = True
179    form_fields['ticket_session'].for_display = True
Note: See TracBrowser for help on using the repository browser.