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

Last change on this file since 17930 was 17916, checked in by Henrik Bettermann, 2 months ago

Bursaries are also allowed to export school fee payment overviews.

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