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

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

Change sports and library fee options again.

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