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, 39 hours ago

Customize course_category (= curriculum)

  • Property svn:keywords set to Id
File size: 11.1 KB
RevLine 
[7569]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##
[7822]18"""Customize general helper utilities for Kofa.
[7569]19"""
[17401]20from copy import deepcopy
[17824]21from zope.security import checkPermission
[8821]22from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
[7569]23
[8821]24class CustomKofaUtils(NigeriaKofaUtils):
[7569]25    """A collection of methods subject to customization.
26    """
[7845]27
[12589]28    SYSTEM_MAX_LOAD = {
29        'swap-mem': None,
30        'virt-mem': 80.0,
31        'cpu-load': 100.0,
32        }
33
[7845]34    PREFERRED_LANGUAGES_DICT = {
[9635]35        }
36
[18085]37    COURSE_CATEGORY_DICT = {
38        'bmas':'BMAS - Benchmark Minimum Academic Standards',
39        'ccmas':'CCMAS - Core Curriculum Minimum Academic Standards',
40        }
41
[9635]42    APP_CATS_DICT = {
[13947]43        'basic': 'ASE, PUDE, PCE, PRENCE',
[9635]44        'no': 'No Application',
45        'sandwich': 'Sandwich',
46        'cest': 'Part-Time, Diploma, Certificate',
47        'dp_ft': 'Diploma Full-Time Programmes',
[17052]48        'dp': 'Diploma Programmes',
[12575]49        'pt_ext': 'Part-Time (extended application)',
[13011]50        'pg': 'Postgraduate (main advert)',
[17048]51        'coe': 'CoE Programmes',
[13615]52        'pgnils': 'Postgraduate NILS',
[17826]53        'spesse': 'SPESSE Programmes',
[13011]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)',
[13137]59        'pre': 'Pre-Degree Studies',
[14050]60        'asaba': 'FCE Asaba',
61        'akoka': 'FCE Akoka',
62        'akokaj': 'FCE Akoka JUPEB',
[14811]63        'special_ft': 'Special Full-Time',
[14965]64        'cdl': 'Center For Distance Learning',
[16807]65        'french': 'French Language Center',
[17964]66        'afrimal': 'African Institute of Management and Leadership',
[9655]67        }
68
[9757]69    # de modes are only used for entry_mode
[9655]70    MODE_GROUPS = {
71        'All':('all',),
[14811]72        'Undergraduate Full-Time':('ug_ft', 'special_ft'),
[9757]73        'Undergraduate Part-Time':('ug_pt'),
[14808]74        'Diploma/Certificate Full-Time':('dp_ft', 'ct_ft'),
75        'Diploma/Certificate Part-Time':('dp_pt', 'ct_pt'),
[9655]76        'Postgraduate Full-Time':('pg_ft', 'pgd_ft'),
77        'Postgraduate Part-Time':('pg_pt', 'special_pg_pt', 'pgd_pt'),
[9727]78        }
79
80    PAYMENT_CATEGORIES = {
81        'schoolfee': 'School Fee',
[17963]82        'schoolfee_1': 'School Fee (1st instalment)',
83        'secondinstall':'School Fee (2nd instalment)',
[9727]84        'clearance': 'Acceptance Fee',
[13251]85        'bed_allocation': 'Bed Allocation Fee',
86        #'hostel_application': 'Hostel Application Fee',
[9731]87        'hostel_maintenance': 'Hostel Maintenance Fee',
[13251]88        #'tempmaint_1': 'Hall 1-4 M/F Ekehuan',
89        #'tempmaint_2': 'Hall 5 M/F',
90        #'tempmaint_3': 'Clinical Hostel',
[9727]91        'transfer': 'Transfer Fee',
92        'gown': 'Gown Hire Fee',
[10469]93        'application': 'Application Fee',
94        'transcript': 'Transcript Fee',
[11782]95        'admission_checking': 'Admission Checking Fee',
[13785]96        'jupeb': 'JUPEB Examination Fee',
[14358]97        'registration': 'Total Registration Fee',
98        'clinexam':'Clinical Examination Fee',
[14970]99        #'pharmd_1':'Clerkship Fee',
[14960]100        'pharmd_2':'Module 1 Fee',
[15106]101        'develop':'Development Fee',
[15537]102        'carryover':'School Fee (carry over from previous sessions)',
103        'foreign':'School Fee (paid in foreign currency)',
[16386]104        'medical_quest':'Medical Questionnaire Fee',
[16780]105        'plag_test':'Final Year Plagiarism Test',
[16866]106        'flc_modules': 'FLC Modules Fee',
[17542]107        'medical_clearance': 'Medical Clearance Fee',
[18031]108        'stat_result': 'Statement of Result Fee',
[9731]109        }
110
111    SELECTABLE_PAYMENT_CATEGORIES = {
112        'schoolfee': 'School Fee',
113        'clearance': 'Acceptance Fee',
[13251]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',
[9731]120        'gown': 'Gown Hire Fee',
[10469]121        'application': 'Application Fee',
122        'transcript': 'Transcript Fee',
[13576]123        'transfer': 'Transfer Fee',
[13785]124        'jupeb': 'JUPEB Examination Fee',
[14358]125        'clinexam':'Clinical Examination Fee',
[14970]126        #'pharmd_1':'PharmD Clerkship Fee (1st school fee prepayment)',
[14971]127        'pharmd_2':'PharmD Module 1 Fee (school fee prepayment)',
[15108]128        #'develop':'Development Fee',
[16386]129        'medical_quest':'Medical Questionnaire Fee',
[16780]130        'plag_test':'Final Year Plagiarism Test (for final year project or PG thesis)',
[16866]131        'flc_modules': 'FLC Modules Fee',
[17542]132        'medical_clearance': 'Medical Clearance Fee',
[18031]133        'stat_result': 'Statement of Result Fee',
[10441]134        }
135
[16404]136    REPORTABLE_PAYMENT_CATEGORIES = {
137        'schoolfee': 'School Fee',
[17963]138        'schoolfee_1': 'School Fee (1st instalment)',
139        'secondinstall':'School Fee (2nd instalment)',
[16404]140        'clearance': 'Acceptance Fee',
[16522]141        'bed_allocation': 'Bed Allocation Fee',
[16404]142        'hostel_maintenance': 'Hostel Maintenance Fee',
143        'medical_quest':'Medical Questionnaire Fee',
144        }
145
[15437]146    def selectable_payment_categories(self, student):
[17963]147        spc = deepcopy(self.SELECTABLE_PAYMENT_CATEGORIES)
148        if student.is_jupeb:
[17966]149            spc['schoolfee_1'] =  'School Fee (1st instalment)'
[17967]150            spc['secondinstall'] = 'School Fee (2nd instalment)'
[17963]151        return spc
[15437]152
[17401]153    PREVIOUS_PAYMENT_CATEGORIES = deepcopy(SELECTABLE_PAYMENT_CATEGORIES)
154
[13566]155    DISABLE_PAYMENT_GROUP_DICT = {
[16373]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',
[16516]163        'sf_return': 'School Fee - Returning',
[16373]164        'maint_all': 'Accomm. Fee - All',
[17963]165        'cl_all':    'Accept. Fee - All',
[16373]166        'cl_jupeb':  'Accept. Fee - JUPEB',
[16374]167        'cl_allexj': 'Accept. Fee - All except JUPEB',
[13566]168        }
169
[10441]170    SEMESTER_DICT = {
171        1: '1st Semester',
172        2: '2nd Semester',
173        3: 'Combined',
[10471]174        4: '1st Term',
175        5: '2nd Term',
176        6: '3rd Term',
[16813]177        9: 'N/A',
178        11: 'Module I',
179        12: 'Module II',
180        13: 'Module III',
[11669]181        }
182
183    BALANCE_PAYMENT_CATEGORIES = {
184        'schoolfee': 'School Fee',
185        'clearance': 'Clearance Fee',
[13488]186        'hostel_maintenance': 'Hostel Maintenance Fee',
[13514]187        'bed_allocation': 'Bed Allocation Fee',
[15537]188        'carryover':'School Fee (carry over from previous sessions)',
189        'foreign':'School Fee (paid in foreign currency)',
[16866]190        'flc_modules': 'FLC Modules Fee',
[12407]191        }
192
193    EXAM_GRADES = NigeriaKofaUtils.EXAM_GRADES + (('B1', 'B1'), ('P', 'P'),)
[13294]194
195    SPECIAL_HANDLING_DICT = {
196        'regular': 'Regular Hostel',
197        'blocked': 'Blocked Hostel',
[13446]198        'clinical': 'Clinical Hostel',
[13759]199        'ekenwan': 'Ekenwan Campus',
200        'pg': 'Postgraduate Hostel',
[13294]201        }
[14808]202
203    STUDY_MODES_DICT = {
[14811]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',
[14808]217        'ug_sw': 'Undergraduate Sandwich',
[14811]218        'transfer_pt': 'Transfer Part-Time',
219        'transfer_ft': 'Transfer Full-Time',
220        'ct_pt': 'Certificate Part-Time',
[14808]221        'transfer': 'Transfer',
[16829]222        'transferred': 'Transferred',
[14808]223        'found': 'Foundation',
224        'no': 'no application',
[17140]225        'special_ft': 'Special Full-Time',
[17578]226        'cdl': 'Open & Distance Learning',
[14808]227        }
[17377]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
[17824]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):
[17916]263                exporters += [('Bursary Data', 'bursary'),
264                              ('School Fee Payments Overview',
265                               'sfpaymentsoverview'),
266                              ('Session Payments Overview',
267                               'sessionpaymentsoverview')]
[17824]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):
[17851]278                exporters += [('NYSC Indication', 'nysc'),]
[17824]279            return exporters
280
Note: See TracBrowser for help on using the repository browser.