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

Last change on this file since 15976 was 15971, checked in by Henrik Bettermann, 5 years ago

Add three new payment categories.

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