source: main/waeup.aaue/trunk/src/waeup/aaue/utils/utils.py @ 18210

Last change on this file since 18210 was 18210, checked in by Henrik Bettermann, 12 months ago

Make the "University Student Identity Card Levy" be also

available as a single payment item for DSH/Part time students when
selecting payable items.

  • Property svn:keywords set to Id
File size: 16.0 KB
Line 
1## $Id: utils.py 18210 2025-11-21 23:34:59Z 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"""
20
21import string
22import grok
23from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
24from waeup.kofa.students.workflow  import ALUMNI_STATES
25
26class CustomKofaUtils(NigeriaKofaUtils):
27    """A collection of methods subject to customization.
28    """
29
30    PREFERRED_LANGUAGES_DICT = {
31        }
32
33    COURSE_CATEGORY_DICT = {
34        'C':'Core Course (C)',
35        'R':'Required Courses (R)',
36        'E':'Elective Courses (E)',
37        }
38
39    PAYMENT_CATEGORIES = {
40        'schoolfee': 'School Fees',
41        'schoolfee_1': 'School Fees Plus (1st instalment)',
42        'schoolfee_2': 'School Fees (2nd instalment)',
43        'schoolfee_incl': 'School Fees Plus',
44        'clearance': 'Acceptance Fee',
45        'clearance_incl': 'Acceptance Fee Plus',
46        'hostel_maintenance': 'Hostel Accommodation Fee',
47        'hostel_balance': 'Hostel Balance',
48        'application': 'Application Fee',
49        'app_balance': 'Application Fee Balance',
50        'bed_allocation': 'Bed Allocation Fee',
51        'transfer': 'Transfer Fee',
52        'transcript_local': 'Local Transcript Fee',
53        'transcript_inter': 'International Transcript Fee',
54        'late_registration': 'Late Course Registration Fee',
55        'welfare': 'Student Welfare Assurance Fee',
56        'union': 'Student Union Dues',
57        'lapel': 'Lapel/File Fee',
58        'matric_gown': 'Matriculation Gown Fee',
59        'concessional': 'Concessional Fee',
60        'id_card': 'Student ID Card',
61        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
62        'gst_text_book_1': 'Text Book Fee GST101 GST102',
63        'gst_text_book_2': 'Text Book Fee GST111 GST112',
64        'gst_text_book_3': 'Text Book Fee GST222',
65        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
66        'gst_registration_2': 'Registration Fee GST222',
67        'ent_text_book_1': 'Text Book Fee ENT201',
68        'ent_text_book_2': 'Text Book Fee ENT211',
69        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
70        'ent_registration_1': 'Registration Fee ENT201',
71        'ent_registration_2': 'Registration Fee ENT211',
72        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
73        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
74        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
75        'ict': 'ICT/Affidavit Dues',
76        'affidavit': 'Affidavit Dues',
77        'restitution': 'Restitution Fee',
78        'sports': 'Sports Fee',
79        'library': 'UG Library Fee',
80        'library_pg': 'PG Library Fee',
81        'sports_library': 'Sports Development and Library Fee',
82        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
83        'lab_2': 'Laboratory Due (BIO101/BIO111)',
84        'lms_sund': 'LMS + Sundry Fees',
85        'exam': 'IJMBE Examination Fee',
86        'access_card': 'AAU Access Card Fee', # deprecated
87        'access': 'University Student Identity Card Levy',
88        'lmsplus': 'LMS Plus Fee',
89        }
90
91    SELECTABLE_PAYMENT_CATEGORIES = {
92        #'schoolfee': 'School Fees',
93        'schoolfee_1': 'School Fees Plus (1st instalment)',
94        'schoolfee_2': 'School Fees (2nd instalment)',
95        'schoolfee_incl': 'School Fees Plus',
96        'clearance': 'Acceptance Fee',
97        'clearance_incl': 'Acceptance Fee Plus',
98        'hostel_maintenance': 'Hostel Accommodation Fee',
99        'hostel_balance': 'Hostel Balance',
100        #'application': 'Application Fee',
101        'bed_allocation': 'Bed Allocation Fee',
102        #'transfer': 'Transfer Fee',
103        ##'transcript_local': 'Local Transcript Fee',
104        ##'transcript_inter': 'International Transcript Fee',
105        'late_registration': 'Late Course Registration Fee',
106        #'welfare': 'Student Welfare Assurance Fee',
107        #'union': 'Student Union Dues',
108        #'lapel': 'Lapel/File Fee',
109        #'matric_gown': 'Matriculation Gown Fee',
110        ##'concessional': 'Concessional Fee',
111        #'id_card': 'Student ID Card',
112        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
113        'gst_text_book_1': 'Text Book Fee GST101 GST102',
114        'gst_text_book_2': 'Text Book Fee GST111 GST112',
115        'gst_text_book_3': 'Text Book Fee GST222',
116        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
117        'gst_registration_2': 'Registration Fee GST222',
118        'ent_text_book_1': 'Text Book Fee ENT201',
119        'ent_text_book_2': 'Text Book Fee ENT211',
120        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
121        'ent_registration_1': 'Registration Fee ENT201',
122        'ent_registration_2': 'Registration Fee ENT211',
123        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
124        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
125        ##'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
126        ##'ict': 'ICT/Affidavit Dues',
127        ##'affidavit': 'Affidavit Dues',
128        ##'restitution': 'Restitution Fee',
129        ##'sports': 'Sports Fee',
130        ##'library': 'UG Library Fee',
131        ##'library_pg': 'PG Library Fee',
132        ##'sports_library': 'Sports Development and Library Fee',
133        ##'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
134        ##'lab_2': 'Laboratory Due (BIO101/BIO111)',
135        ##'access_card': 'AAU Access Card Fee',
136        'access': 'University Student Identity Card Levy',
137        'lmsplus': 'LMS Plus Fee',
138        }
139
140    ALUMNI_PAYMENT_CATS =  {
141        'transcript_local': 'Transcript Fee Local',
142        'transcript_inter': 'Transcript Fee International',
143        }
144
145    REDUCED_PAYMENT_CATS =  {
146        'clearance': 'Acceptance Fee',
147        'schoolfee_incl': 'School Fees Plus',
148        'late_registration': 'Late Course Registration Fee',
149        ##'sports': 'Sports Fee',
150        ##'library': 'UG Library Fee',
151        ##'library_pg': 'PG Library Fee',
152        ##'sports_library': 'Sports Development and Library Fee',
153        }
154
155    IJMBE_PAYMENT_CATS =  {
156        'clearance': 'Acceptance Fee',
157        'schoolfee': 'School Fees',
158        'schoolfee_1': 'School Fees (1st instalment)',
159        'schoolfee_2': 'School Fees (2nd instalment)',
160        ##'sports': 'Sports Fee',
161        ##'library': 'UG Library Fee',
162        ##'library_pg': 'PG Library Fee',
163        ##'sports_library': 'Sports Development and Library Fee',
164        'exam': 'IJMBE Examination Fee',
165        }
166
167    PT_AND_DSH_PAYMENT_CATS =  {
168        'clearance_incl': 'Acceptance Fee Plus',
169        'schoolfee_incl': 'School Fees Plus',
170        'schoolfee_1': 'School Fees Plus (1st instalment)',
171        'schoolfee_2': 'School Fees (2nd instalment)',
172        'ent_text_book_1': 'Text Book Fee ENT201',
173        'ent_text_book_2': 'Text Book Fee ENT211',
174        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
175        'ent_registration_1': 'Registration Fee ENT201',
176        'ent_registration_2': 'Registration Fee ENT211',
177        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
178        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
179        'gst_registration_2': 'Registration Fee GST222',
180        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
181        'gst_text_book_1': 'Text Book Fee GST101 GST102',
182        'gst_text_book_2': 'Text Book Fee GST111 GST112',
183        'gst_text_book_3': 'Text Book Fee GST222',
184        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
185        'late_registration': 'Late Course Registration Fee',
186        'access': 'University Student Identity Card Levy',
187        ##'sports': 'Sports Fee',
188        ##'library': 'UG Library Fee',
189        ##'library_pg': 'PG Library Fee',
190        ##'sports_library': 'Sports Development and Library Fee',
191        ##'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
192        ##'lab_2': 'Laboratory Due (BIO101/BIO111)',
193        }
194
195    def selectable_payment_categories(self, student):
196        if student.state in ALUMNI_STATES:
197            return self.ALUMNI_PAYMENT_CATS
198        if student.current_mode in (
199            'special_pg_ft', 'special_pg_pt', 'found', 'bridge'):
200            return self.REDUCED_PAYMENT_CATS
201        if student.current_mode in (
202            'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'):
203            return self.PT_AND_DSH_PAYMENT_CATS
204        if student.current_mode == 'ijmbe':
205            return self.IJMBE_PAYMENT_CATS
206        return self.SELECTABLE_PAYMENT_CATEGORIES
207
208    REPORTABLE_PAYMENT_CATEGORIES = {
209        'schoolfee': 'School Fees',
210        'schoolfee_incl': 'School Fees Plus',
211        'schoolfee_1': 'School Fees 1 Plus',
212        'schoolfee_2': 'School Fees 2',
213        'clearance': 'Acceptance Fee',
214        'clearance_incl': 'Acceptance Fee Plus',
215        'hostel_maintenance': 'Hostel Maintenance Fee',
216        }
217
218    BALANCE_PAYMENT_CATEGORIES = {
219        'schoolfee': 'School Fees',
220        'clearance': 'Acceptance Fee',
221        'hostel_maintenance': 'Hostel Maintenance Fee',
222        'hostel_balance': 'Hostel Balance',
223        'late_registration': 'Late Course Registration Fee',
224        #'welfare': 'Student Welfare Assurance Fee',
225        #'union': 'Student Union Dues',
226        #'lapel': 'Lapel/File Fee',
227        #'matric_gown': 'Matriculation Gown Fee',
228        #'id_card': 'Student ID Card',
229        'gst_text_book_1': 'Text Book Fee GST101 GST102',
230        'gst_text_book_2': 'Text Book Fee GST111 GST112',
231        'gst_text_book_3': 'Text Book Fee GST222',
232        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
233        'gst_registration_2': 'Registration Fee GST222',
234        'ent_text_book_1': 'Text Book Fee ENT201',
235        'ent_text_book_2': 'Text Book Fee ENT211',
236        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
237        'ent_registration_1': 'Registration Fee ENT201',
238        'ent_registration_2': 'Registration Fee ENT211',
239        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
240        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
241        #'ict': 'ICT/Affidavit Dues',
242        #'affidavit': 'Affidavit Dues',
243        #'restitution': 'Restitution Fee',
244        }
245
246    PREVIOUS_PAYMENT_CATEGORIES = {
247        'schoolfee_incl': 'School Fees Plus',
248        'schoolfee_1': 'School Fees Plus (1st instalment)',
249        'schoolfee_2': 'School Fees (2nd instalment)',
250        'clearance': 'Acceptance Fee',
251        'late_registration': 'Late Course Registration Fee',
252        }
253
254    APP_CATS_DICT = {
255        'basic': 'PUTME, PUDE, PCE, PRENCE',
256        'no': 'No Application',
257        'pg_ft': 'Postgraduate Full-Time',
258        'pg_pt': 'Postgraduate Part-Time',
259        'cest': 'Part-Time, Diploma, Certificate',
260        'found': 'Foundation',
261        'ptee': 'Part-Time Entrance Examination',
262        'ioe_dp': 'Institute of Education Diploma',
263        'ijmbe': 'IJMBE Preparation',
264        'bridge': 'Bridge',
265        'dsh': 'Science and Humanities',
266
267        }
268
269    STUDY_MODES_DICT = {
270        'ug_ft': 'Undergraduate Full Time',
271        'ug_pt': 'Undergraduate Part Time',
272        'de_ft': 'Direct Entry Full Time',
273        'de_pt': 'Direct Entry Part Time',
274        'dp_pt': 'Diploma Part Time',
275        'dp_ft': 'Diploma Full Time',
276        'special_pg_ft': 'Postgraduate Full Time',
277        'special_pg_pt': 'Postgraduate Part Time',
278        'found': 'Foundation',
279        'transfer': 'Transfer',
280        'transferred': 'Transferred',
281        'mug_ft': 'Undergraduate Full Time Merit List',
282        'mde_ft': 'Direct Entry Full Time Merit List',
283        'ijmbe': 'IJMBE Preparation',
284        'bridge': 'Bridge',
285        'ug_dsh': 'Undergraduate Science and Humanities',
286        'de_dsh': 'Direct Entry Science and Humanities',
287        }
288
289    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
290
291    VERDICTS_DICT = {
292        '0': 'not yet',
293        'A': 'Successful student',
294        'B': 'Student with carryover courses',
295        'C': 'Student on probation',
296        'D': 'Withdrawn from the faculty',
297        #'E': 'Student who were previously on probation',
298        #'F': 'Medical case',
299        #'G': 'Absent from examination',
300        #'H': 'Withheld results',
301        #'I': 'Expelled/rusticated/suspended student',
302        #'J': 'Temporary withdrawn from the university',
303        #'K': 'Unregistered student',
304        #'L': 'Referred student',
305        #'M': 'Reinstatement',
306        #'N': 'Student on transfer',
307        #'O': 'NCE-III repeater',
308        #'Y': 'No previous verdict',
309        #'X': 'New 300 level student',
310        'Z': 'Successful student (provisional)',
311        #'A1': 'First Class',
312        #'A2': 'Second Class Upper',
313        #'A3': 'Second Class Lower',
314        #'A4': 'Third Class',
315        #'A5': 'Pass',
316        #'A6': 'Distinction',
317        #'A7': 'Credit',
318        #'A8': 'Merit',
319        'NER': 'No evidence of registration',
320        'NYV': 'Not yet verified',
321        'FRNS': 'Faculty requirements not satisfied',
322        }
323
324    DISABLE_PAYMENT_GROUP_DICT = {
325        'sf_all': 'School Fees - All Students',
326        'all_returning': 'All Fees - Returning Students',
327        'sf_pg': 'School Fees - Postgraduate Students',
328        'sf_ug_pt': 'School Fees - Undergraduate Part-Time Students',
329        'sf_found': 'School Fees - Foundation Students',
330        'maint_all': 'Accommodation Fee - All Students',
331        'cl_regular': 'Acceptance Fee - Regular Students',
332        }
333
334    MODE_GROUPS = {
335        'All': ('all',),
336        'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'),
337        'Undergraduate Part-Time': ('ug_pt', 'de_pt'),
338        'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'),
339        'Foundation Programme': ('found',),
340        'Institute of Education': ('dp_ft'),
341        'IJMBE Preparation': ('ijmbe',),
342        'Bridge': ('bridge',),
343        }
344
345    #: Maximum number of files listed in `finished` subfolder
346    MAX_FILES = 5000
347
348    def fullname(self, firstname, lastname, middlename=None):
349        """Construct fullname.
350        """
351        try:
352            lastname = lastname.upper()
353        except AttributeError:
354            pass
355        # We remove single initial
356        if firstname and len(firstname) == 1:
357            firstname = ''
358        if middlename and len(middlename) == 1:
359            middlename = ''
360        if lastname and len(lastname) == 1:
361            lastname = ''
362        # We construct givennames
363        givennames = ''
364        if middlename and firstname:
365            givennames = '%s %s' % (firstname, middlename)
366        elif firstname:
367            givennames = firstname
368        elif middlename:
369            givennames = middlename
370        givennames = string.capwords(
371            givennames.replace('-', ' - ')).replace(' - ', '-')
372        # We construct fullname
373        fullname = ''
374        if lastname and givennames:
375            fullname = '%s, %s' % (lastname, givennames)
376        elif lastname:
377            fullname = lastname
378        elif givennames:
379            fullname = givennames
380        if '<' in fullname:
381            return 'XXX'
382        return fullname
383
384    def getUsers(self):
385        users = sorted(
386            grok.getSite()['users'].items(), key=lambda x: x[0])
387        for key, val in users:
388            yield(dict(name=key, val="%s - %s" % (val.name, val.title)))
389
390    def getCertTitle(self, context, value):
391        """Compose the titles in `CertificateSource`.
392        """
393        return "%s - %s" % (value.code.strip('-'), value.title)
Note: See TracBrowser for help on using the repository browser.