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

Last change on this file since 17487 was 17473, checked in by Henrik Bettermann, 17 months ago

More previous payment categories.

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