source: main/waeup.uniben/trunk/src/waeup/uniben/utils/utils.py @ 17824

Last change on this file since 17824 was 17824, checked in by Henrik Bettermann, 5 months ago

Add permission and role for NYSC Officers.

  • Property svn:keywords set to Id
File size: 10.1 KB
Line 
1## $Id: utils.py 17824 2024-06-27 09:55:33Z 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"""Customize general helper utilities for Kofa.
19"""
20from copy import deepcopy
21from zope.security import checkPermission
22from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
23
24class CustomKofaUtils(NigeriaKofaUtils):
25    """A collection of methods subject to customization.
26    """
27
28    SYSTEM_MAX_LOAD = {
29        'swap-mem': None,
30        'virt-mem': 80.0,
31        'cpu-load': 100.0,
32        }
33
34    PREFERRED_LANGUAGES_DICT = {
35        }
36
37    APP_CATS_DICT = {
38        'basic': 'ASE, PUDE, PCE, PRENCE',
39        'no': 'No Application',
40        'sandwich': 'Sandwich',
41        'cest': 'Part-Time, Diploma, Certificate',
42        'dp_ft': 'Diploma Full-Time Programmes',
43        'dp': 'Diploma Programmes',
44        'pt_ext': 'Part-Time (extended application)',
45        'pg': 'Postgraduate (main advert)',
46        'coe': 'CoE Programmes',
47        'pgnils': 'Postgraduate NILS',
48        'pg_ft': 'Postgraduate Full-Time (deprecated)',
49        'pg_pt': 'Postgraduate Part-Time (deprecated)',
50        'pg_ext': 'Postgraduate (extended application, deprecated)',
51        'pg_new': 'Postgraduate (supplementary application #1, deprecated)',
52        'pg_new2': 'Postgraduate (supplementary application #2, deprecated)',
53        'pre': 'Pre-Degree Studies',
54        'asaba': 'FCE Asaba',
55        'akoka': 'FCE Akoka',
56        'akokaj': 'FCE Akoka JUPEB',
57        'special_ft': 'Special Full-Time',
58        'cdl': 'Center For Distance Learning',
59        'french': 'French Language Center',
60        }
61
62    # de modes are only used for entry_mode
63    MODE_GROUPS = {
64        'All':('all',),
65        'Undergraduate Full-Time':('ug_ft', 'special_ft'),
66        'Undergraduate Part-Time':('ug_pt'),
67        'Diploma/Certificate Full-Time':('dp_ft', 'ct_ft'),
68        'Diploma/Certificate Part-Time':('dp_pt', 'ct_pt'),
69        'Postgraduate Full-Time':('pg_ft', 'pgd_ft'),
70        'Postgraduate Part-Time':('pg_pt', 'special_pg_pt', 'pgd_pt'),
71        }
72
73    PAYMENT_CATEGORIES = {
74        'schoolfee': 'School Fee',
75        'clearance': 'Acceptance Fee',
76        'bed_allocation': 'Bed Allocation Fee',
77        #'hostel_application': 'Hostel Application Fee',
78        'hostel_maintenance': 'Hostel Maintenance Fee',
79        #'tempmaint_1': 'Hall 1-4 M/F Ekehuan',
80        #'tempmaint_2': 'Hall 5 M/F',
81        #'tempmaint_3': 'Clinical Hostel',
82        'transfer': 'Transfer Fee',
83        'gown': 'Gown Hire Fee',
84        'application': 'Application Fee',
85        'transcript': 'Transcript Fee',
86        'admission_checking': 'Admission Checking Fee',
87        'jupeb': 'JUPEB Examination Fee',
88        'registration': 'Total Registration Fee',
89        'clinexam':'Clinical Examination Fee',
90        #'pharmd_1':'Clerkship Fee',
91        'pharmd_2':'Module 1 Fee',
92        'develop':'Development Fee',
93        'carryover':'School Fee (carry over from previous sessions)',
94        'foreign':'School Fee (paid in foreign currency)',
95        'medical_quest':'Medical Questionnaire Fee',
96        'plag_test':'Final Year Plagiarism Test',
97        'flc_modules': 'FLC Modules Fee',
98        'medical_clearance': 'Medical Clearance Fee',
99        }
100
101    SELECTABLE_PAYMENT_CATEGORIES = {
102        'schoolfee': 'School Fee',
103        'clearance': 'Acceptance Fee',
104        'bed_allocation': 'Bed Allocation Fee',
105        #'hostel_application': 'Hostel Application Fee',
106        'hostel_maintenance': 'Hostel Maintenance Fee',
107        #'tempmaint_1': 'Hall 1-4 M/F Ekehuan Maintenance Fee',
108        #'tempmaint_2': 'Hall 5 M/F Maintenance Fee',
109        #'tempmaint_3': 'Clinical Hostel Maintenance Fee',
110        'gown': 'Gown Hire Fee',
111        'application': 'Application Fee',
112        'transcript': 'Transcript Fee',
113        'transfer': 'Transfer Fee',
114        'jupeb': 'JUPEB Examination Fee',
115        'clinexam':'Clinical Examination Fee',
116        #'pharmd_1':'PharmD Clerkship Fee (1st school fee prepayment)',
117        'pharmd_2':'PharmD Module 1 Fee (school fee prepayment)',
118        #'develop':'Development Fee',
119        'medical_quest':'Medical Questionnaire Fee',
120        'plag_test':'Final Year Plagiarism Test (for final year project or PG thesis)',
121        'flc_modules': 'FLC Modules Fee',
122        'medical_clearance': 'Medical Clearance Fee',
123        }
124
125    REPORTABLE_PAYMENT_CATEGORIES = {
126        'schoolfee': 'School Fee',
127        'clearance': 'Acceptance Fee',
128        'bed_allocation': 'Bed Allocation Fee',
129        'hostel_maintenance': 'Hostel Maintenance Fee',
130        'medical_quest':'Medical Questionnaire Fee',
131        }
132
133    def selectable_payment_categories(self, student):
134        return self.SELECTABLE_PAYMENT_CATEGORIES
135
136    PREVIOUS_PAYMENT_CATEGORIES = deepcopy(SELECTABLE_PAYMENT_CATEGORIES)
137
138    DISABLE_PAYMENT_GROUP_DICT = {
139        'sf_all':    'School Fee - All',
140        'sf_found':  'School Fee - Foundation',
141        'sf_pg':     'School Fee - PG',
142        'sf_pt':     'School Fee - UG PT',
143        'sf_ft':     'School Fee - UG FT',
144        'sf_sw':     'School Fee - Sandwich',
145        'sf_dp':     'School Fee - Diploma',
146        'sf_return': 'School Fee - Returning',
147        'maint_all': 'Accomm. Fee - All',
148        'cl_all':    'Accept. Fee- All',
149        'cl_jupeb':  'Accept. Fee - JUPEB',
150        'cl_allexj': 'Accept. Fee - All except JUPEB',
151        }
152
153    SEMESTER_DICT = {
154        1: '1st Semester',
155        2: '2nd Semester',
156        3: 'Combined',
157        4: '1st Term',
158        5: '2nd Term',
159        6: '3rd Term',
160        9: 'N/A',
161        11: 'Module I',
162        12: 'Module II',
163        13: 'Module III',
164        }
165
166    BALANCE_PAYMENT_CATEGORIES = {
167        'schoolfee': 'School Fee',
168        'clearance': 'Clearance Fee',
169        'hostel_maintenance': 'Hostel Maintenance Fee',
170        'bed_allocation': 'Bed Allocation Fee',
171        'carryover':'School Fee (carry over from previous sessions)',
172        'foreign':'School Fee (paid in foreign currency)',
173        'flc_modules': 'FLC Modules Fee',
174        }
175
176    EXAM_GRADES = NigeriaKofaUtils.EXAM_GRADES + (('B1', 'B1'), ('P', 'P'),)
177
178    SPECIAL_HANDLING_DICT = {
179        'regular': 'Regular Hostel',
180        'blocked': 'Blocked Hostel',
181        'clinical': 'Clinical Hostel',
182        'ekenwan': 'Ekenwan Campus',
183        'pg': 'Postgraduate Hostel',
184        }
185
186    STUDY_MODES_DICT = {
187        'ume_ft': 'UME Full-Time',
188        'ug_ft': 'Undergraduate Full-Time',
189        'ug_pt': 'Undergraduate Part-Time',
190        'dp_pt': 'Diploma Part-Time',
191        'ct_ft': 'Certificate Full-Time',
192        'dp_ft': 'Diploma Full-Time',
193        'de_ft': 'Direct Entry Full-Time',
194        'de_pt': 'Direct Entry Part-Time',
195        'pg_ft': 'Postgraduate Full-Time',
196        'pg_pt': 'Postgraduate Part-Time',
197        'pgd_ft': 'Postgraduate Diploma Full-Time',
198        'pgd_pt': 'Postgraduate Diploma Part-Time',
199        'special_pg_pt': 'Special Postgraduate Part-Time',
200        'ug_sw': 'Undergraduate Sandwich',
201        'transfer_pt': 'Transfer Part-Time',
202        'transfer_ft': 'Transfer Full-Time',
203        'ct_pt': 'Certificate Part-Time',
204        'transfer': 'Transfer',
205        'transferred': 'Transferred',
206        'found': 'Foundation',
207        'no': 'no application',
208        'special_ft': 'Special Full-Time',
209        'cdl': 'Open & Distance Learning',
210        }
211
212    def sortCertificates(self, context, resultset):
213        """Sort already filtered certificates in `CertificateSource`.
214        """
215        resultlist = sorted(resultset, key=lambda
216            value: value.__parent__.__parent__.__parent__.code +
217            value.__parent__.__parent__.code +
218            value.code)
219        return resultlist
220
221    def getCertTitle(self, context, value):
222        """Compose the titles in `CertificateSource`.
223        """
224        try: title = "%s / %s / %s (%s)" % (
225            value.__parent__.__parent__.__parent__.title,
226            value.__parent__.__parent__.title,
227            value.title, value.code)
228        except AttributeError:
229            title = "NA / %s (%s)" % (value.title, value.code)
230        return title
231
232    def collect_exporters(self, context):
233        # Used for `ExportJobContainerJobConfig`.
234        # We provide all student exporters, nothing else, yet.
235        # Bursary, Department or Accommodation Officers don't
236        # have the general exportData
237        # permission and are only allowed to export bursary, payments
238        # overview or accommodation data respectively.
239        # This is the only place where waeup.exportAccommodationData,
240        # waeup.exportBursaryData and waeup.exportPaymentsOverview
241        # are used.
242        # Uniben: Add NYSC Officers.
243        exporters = []
244        if not checkPermission('waeup.exportData', context):
245            if checkPermission('waeup.exportBursaryData', context):
246                exporters += [('Bursary Data', 'bursary')]
247            if checkPermission('waeup.exportPaymentsOverview', context):
248                exporters += [('School Fee Payments Overview',
249                               'sfpaymentsoverview'),
250                              ('Session Payments Overview',
251                               'sessionpaymentsoverview')]
252            if checkPermission('waeup.exportAccommodationData', context):
253                exporters += [('Bed Tickets', 'bedtickets'),
254                              ('Accommodation Payments',
255                               'accommodationpayments')]
256            if checkPermission('waeup.exportNYSCData', context):
257                exporters += [('NYSC Data', 'NYSC'),]
258            return exporters
259
Note: See TracBrowser for help on using the repository browser.