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

Last change on this file since 18085 was 18085, checked in by Henrik Bettermann, 29 hours ago

Customize course_category (= curriculum)

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