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

Last change on this file since 18031 was 18031, checked in by Henrik Bettermann, 13 hours ago

Add fee.
Add Id Card file viewlets.

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