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

Last change on this file since 16841 was 16830, checked in by Henrik Bettermann, 3 years ago

Adjust to base package.

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