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

Last change on this file since 17837 was 17797, checked in by Henrik Bettermann, 6 months ago

Customize certificate title.

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