source: main/kofacustom.udss/trunk/src/kofacustom/udss/students/browser.py @ 17932

Last change on this file since 17932 was 17737, checked in by Henrik Bettermann, 7 months ago

More adjustments.

  • Property svn:keywords set to Id
File size: 5.6 KB
RevLine 
[16717]1## $Id: browser.py 17737 2024-04-16 06:29:43Z henrik $
[15614]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
[16718]22from zope.security import checkPermission
[17737]23from zope.formlib.textwidgets import BytesDisplayWidget
[15614]24from hurry.workflow.interfaces import IWorkflowInfo
25from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
26from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
27from waeup.kofa.browser.layout import KofaEditFormPage
28from waeup.kofa.browser.layout import action, jsaction
29from waeup.kofa.students.browser import (
[17737]30    StudentPersonalDisplayFormPage,
31    StudentPersonalManageFormPage,
32    StudentPersonalEditFormPage,
33    StudentClearanceDisplayFormPage,
34    StudentClearanceManageFormPage,
35    StudentClearanceEditFormPage,
36    ExportPDFClearanceSlip,
37    StudyLevelEditFormPage,
38    StudyLevelDisplayFormPage,
39    StudentBasePDFFormPage,
40    ExportPDFCourseRegistrationSlip,
41    CourseTicketDisplayFormPage,
42    StudentTriggerTransitionFormPage,
43    PaymentsManageFormPage,
44    msave, emit_lock_message)
[15614]45from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
46from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
47from kofacustom.nigeria.students.browser import (
48    NigeriaOnlinePaymentDisplayFormPage,
49    NigeriaStudentBaseManageFormPage,
50    NigeriaStudentClearanceEditFormPage,
51    NigeriaOnlinePaymentAddFormPage,
52    NigeriaExportPDFPaymentSlip,
53    )
54
[17689]55from kofacustom.udss.students.interfaces import (
[17737]56    ICustomStudentOnlinePayment,
57    ICustomStudentStudyCourse,
58    ICustomStudentStudyLevel,
59    ICustomStudentPersonal,
60    ICustomStudentClearance)
[17689]61from kofacustom.udss.interfaces import MessageFactory as _
[15614]62
[16718]63class CustomPaymentsManageFormPage(PaymentsManageFormPage):
64    """ Page to manage the student payments. This manage form page is for
65    both students and students officers. SKELETON does not allow students
66    to remove any payment ticket.
67    """
68    @property
69    def manage_payments_allowed(self):
[17737]70        return checkPermission('waeup.manageStudent', self.context)
71
72class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
73    """ Page to display student personal data
74    """
75    form_fields = grok.AutoFields(ICustomStudentPersonal)
76    form_fields['perm_address'].custom_widget = BytesDisplayWidget
77    form_fields['mother_res_address'].custom_widget = BytesDisplayWidget
78    form_fields['father_res_address'].custom_widget = BytesDisplayWidget
79    form_fields['sponsor_res_address'].custom_widget = BytesDisplayWidget
80    form_fields[
81        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
82
83class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage):
84    """ Page to edit personal data
85    """
86    form_fields = grok.AutoFields(ICustomStudentPersonal).omit('personal_updated')
87
88class CustomStudentPersonalManageFormPage(StudentPersonalManageFormPage):
89    """ Page to edit personal data
90    """
91    form_fields = grok.AutoFields(ICustomStudentPersonal)
92    form_fields['personal_updated'].for_display = True
93    form_fields[
94        'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
95
96class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
97    """ Page to display student clearance data
98    """
99
100    @property
101    def form_fields(self):
102        form_fields = grok.AutoFields(
103            ICustomStudentClearance).omit('clearance_locked')
104        if not getattr(self.context, 'officer_comment'):
105            form_fields = form_fields.omit('officer_comment')
106        else:
107            form_fields['officer_comment'].custom_widget = BytesDisplayWidget
108        return form_fields
109
110class CustomExportPDFClearanceSlip(ExportPDFClearanceSlip):
111    """Deliver a PDF slip of the context.
112    """
113    omit_fields = ('password', 'suspended', 'suspended_comment',
114        'phone', 'adm_code', 'email', 'date_of_birth', 'current_level',
115        'flash_notice')
116
117    @property
118    def form_fields(self):
119        form_fields = grok.AutoFields(
120            ICustomStudentClearance).omit('clearance_locked')
121        if not getattr(self.context, 'officer_comment'):
122            form_fields = form_fields.omit('officer_comment')
123        return form_fields
124
125class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage):
126    """ Page to edit student clearance data
127    """
128
129    @property
130    def form_fields(self):
131        form_fields = grok.AutoFields(
132            ICustomStudentClearance).omit('clr_code')
133        return form_fields
134
135class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage):
136    """ View to edit student clearance data by student
137    """
138
139    @property
140    def form_fields(self):
141        form_fields = grok.AutoFields(ICustomStudentClearance).omit(
142            'clearance_locked', 'clr_code', 'officer_comment',
143            'physical_clearance_date')
144        return form_fields
Note: See TracBrowser for help on using the repository browser.