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

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

Combine sports and library fees.

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