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

Last change on this file since 17497 was 17473, checked in by Henrik Bettermann, 15 months ago

More previous payment categories.

  • Property svn:keywords set to Id
File size: 15.3 KB
Line 
1## $Id: utils.py 17473 2023-07-09 08:24:39Z 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##
18"""Customize general helper utilities for Kofa.
19"""
20
21import string
22import grok
23from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
24from waeup.kofa.students.workflow  import ALUMNI_STATES
25
26class CustomKofaUtils(NigeriaKofaUtils):
27    """A collection of methods subject to customization.
28    """
29
30    PREFERRED_LANGUAGES_DICT = {
31        }
32
33    COURSE_CATEGORY_DICT = {
34        'C':'Core Course (C)',
35        'R':'Required Courses (R)',
36        'E':'Elective Courses (E)',
37        }
38
39    PAYMENT_CATEGORIES = {
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',
44        'clearance': 'Acceptance Fee',
45        'clearance_incl': 'Acceptance Fee Plus',
46        'hostel_maintenance': 'Hostel Accommodation Fee',
47        'application': 'Application Fee',
48        'app_balance': 'Application Fee Balance',
49        'bed_allocation': 'Bed Allocation Fee',
50        'transfer': 'Transfer Fee',
51        'transcript_local': 'Local Transcript Fee',
52        'transcript_inter': 'International Transcript Fee',
53        'late_registration': 'Late Course Registration Fee',
54        'welfare': 'Student Welfare Assurance Fee',
55        'union': 'Student Union Dues',
56        'lapel': 'Lapel/File Fee',
57        'matric_gown': 'Matriculation Gown Fee',
58        'concessional': 'Concessional Fee',
59        'id_card': 'Student ID Card',
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',
63        'gst_text_book_3': 'Text Book Fee GST222',
64        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
65        'gst_registration_2': 'Registration Fee GST222',
66        'ent_text_book_1': 'Text Book Fee ENT201',
67        'ent_text_book_2': 'Text Book Fee ENT211',
68        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
69        'ent_registration_1': 'Registration Fee ENT201',
70        'ent_registration_2': 'Registration Fee ENT211',
71        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
72        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
73        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
74        'ict': 'ICT/Affidavit Dues',
75        'affidavit': 'Affidavit Dues',
76        'restitution': 'Restitution Fee',
77        'sports': 'Sports Fee',
78        'library': 'UG Library Fee',
79        'library_pg': 'PG Library Fee',
80        'sports_library': 'Sports Development and Library Fee',
81        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
82        'lab_2': 'Laboratory Due (BIO101/BIO111)',
83        'lms_sund': 'LMS + Sundry Fees',
84        'exam': 'IJMBE Examination Fee',
85        'access_card': 'AAU Access Card Fee',
86        }
87
88    SELECTABLE_PAYMENT_CATEGORIES = {
89        #'schoolfee': 'School Fees',
90        'schoolfee_1': 'School Fees Plus (1st instalment)',
91        'schoolfee_2': 'School Fees (2nd instalment)',
92        'schoolfee_incl': 'School Fees Plus',
93        'clearance': 'Acceptance Fee',
94        'clearance_incl': 'Acceptance Fee Plus',
95        'hostel_maintenance': 'Hostel Accommodation Fee',
96        #'application': 'Application Fee',
97        'bed_allocation': 'Bed Allocation Fee',
98        #'transfer': 'Transfer Fee',
99        ##'transcript_local': 'Local Transcript Fee',
100        ##'transcript_inter': 'International Transcript Fee',
101        'late_registration': 'Late Course Registration Fee',
102        #'welfare': 'Student Welfare Assurance Fee',
103        #'union': 'Student Union Dues',
104        #'lapel': 'Lapel/File Fee',
105        #'matric_gown': 'Matriculation Gown Fee',
106        ##'concessional': 'Concessional Fee',
107        #'id_card': 'Student ID Card',
108        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
109        'gst_text_book_1': 'Text Book Fee GST101 GST102',
110        'gst_text_book_2': 'Text Book Fee GST111 GST112',
111        'gst_text_book_3': 'Text Book Fee GST222',
112        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
113        'gst_registration_2': 'Registration Fee GST222',
114        'ent_text_book_1': 'Text Book Fee ENT201',
115        'ent_text_book_2': 'Text Book Fee ENT211',
116        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
117        'ent_registration_1': 'Registration Fee ENT201',
118        'ent_registration_2': 'Registration Fee ENT211',
119        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
120        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
121        ##'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
122        ##'ict': 'ICT/Affidavit Dues',
123        ##'affidavit': 'Affidavit Dues',
124        ##'restitution': 'Restitution Fee',
125        ##'sports': 'Sports Fee',
126        ##'library': 'UG Library Fee',
127        ##'library_pg': 'PG Library Fee',
128        ##'sports_library': 'Sports Development and Library Fee',
129        ##'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
130        ##'lab_2': 'Laboratory Due (BIO101/BIO111)',
131        ##'lms_sund': 'LMS plus Sundry Fees (new UG students only)',
132        ##'access_card': 'AAU Access Card Fee',
133        }
134
135    ALUMNI_PAYMENT_CATS =  {
136        'transcript_local': 'Transcript Fee Local',
137        'transcript_inter': 'Transcript Fee International',
138        }
139
140    REDUCED_PAYMENT_CATS =  {
141        'clearance': 'Acceptance Fee',
142        'schoolfee': 'School Fees',
143        'late_registration': 'Late Course Registration Fee',
144        ##'sports': 'Sports Fee',
145        ##'library': 'UG Library Fee',
146        ##'library_pg': 'PG Library Fee',
147        ##'sports_library': 'Sports Development and Library Fee',
148        }
149
150    IJMBE_PAYMENT_CATS =  {
151        'clearance': 'Acceptance Fee',
152        'schoolfee': 'School Fees',
153        'schoolfee_1': 'School Fees (1st instalment)',
154        'schoolfee_2': 'School Fees (2nd instalment)',
155        ##'sports': 'Sports Fee',
156        ##'library': 'UG Library Fee',
157        ##'library_pg': 'PG Library Fee',
158        ##'sports_library': 'Sports Development and Library Fee',
159        ##'exam': 'IJMBE Examination Fee',
160        }
161
162    PT_AND_DSH_PAYMENT_CATS =  {
163        'clearance_incl': 'Acceptance Fee Plus',
164        'schoolfee_incl': 'School Fees Plus',
165        'ent_text_book_1': 'Text Book Fee ENT201',
166        'ent_text_book_2': 'Text Book Fee ENT211',
167        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
168        'ent_registration_1': 'Registration Fee ENT201',
169        'ent_registration_2': 'Registration Fee ENT211',
170        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
171        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
172        'gst_registration_2': 'Registration Fee GST222',
173        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
174        'gst_text_book_1': 'Text Book Fee GST101 GST102',
175        'gst_text_book_2': 'Text Book Fee GST111 GST112',
176        'gst_text_book_3': 'Text Book Fee GST222',
177        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
178        'late_registration': 'Late Course Registration Fee',
179        ##'sports': 'Sports Fee',
180        ##'library': 'UG Library Fee',
181        ##'library_pg': 'PG Library Fee',
182        ##'sports_library': 'Sports Development and Library Fee',
183        ##'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
184        ##'lab_2': 'Laboratory Due (BIO101/BIO111)',
185        }
186
187    def selectable_payment_categories(self, student):
188        if student.state in ALUMNI_STATES:
189            return self.ALUMNI_PAYMENT_CATS
190        if student.current_mode in (
191            'special_pg_ft', 'special_pg_pt', 'found', 'bridge'):
192            return self.REDUCED_PAYMENT_CATS
193        if student.current_mode in (
194            'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'):
195            return self.PT_AND_DSH_PAYMENT_CATS
196        if student.current_mode == 'ijmbe':
197            return self.IJMBE_PAYMENT_CATS
198        return self.SELECTABLE_PAYMENT_CATEGORIES
199
200    REPORTABLE_PAYMENT_CATEGORIES = {
201        'schoolfee': 'School Fees',
202        'schoolfee_incl': 'School Fees Plus',
203        'schoolfee_1': 'School Fees 1 Plus',
204        'schoolfee_2': 'School Fees 2',
205        'clearance': 'Acceptance Fee',
206        'clearance_incl': 'Acceptance Fee Plus',
207        'hostel_maintenance': 'Hostel Maintenance Fee',
208        }
209
210    BALANCE_PAYMENT_CATEGORIES = {
211        'schoolfee': 'School Fees',
212        'clearance': 'Acceptance Fee',
213        'hostel_maintenance': 'Hostel Maintenance Fee',
214        'late_registration': 'Late Course Registration Fee',
215        #'welfare': 'Student Welfare Assurance Fee',
216        #'union': 'Student Union Dues',
217        #'lapel': 'Lapel/File Fee',
218        #'matric_gown': 'Matriculation Gown Fee',
219        #'id_card': 'Student ID Card',
220        'gst_text_book_1': 'Text Book Fee GST101 GST102',
221        'gst_text_book_2': 'Text Book Fee GST111 GST112',
222        'gst_text_book_3': 'Text Book Fee GST222',
223        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
224        'gst_registration_2': 'Registration Fee GST222',
225        'ent_text_book_1': 'Text Book Fee ENT201',
226        'ent_text_book_2': 'Text Book Fee ENT211',
227        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
228        'ent_registration_1': 'Registration Fee ENT201',
229        'ent_registration_2': 'Registration Fee ENT211',
230        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
231        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
232        #'ict': 'ICT/Affidavit Dues',
233        #'affidavit': 'Affidavit Dues',
234        #'restitution': 'Restitution Fee',
235        }
236
237    PREVIOUS_PAYMENT_CATEGORIES = {
238        'schoolfee_incl': 'School Fees Plus',
239        'schoolfee_1': 'School Fees Plus (1st instalment)',
240        'schoolfee_2': 'School Fees (2nd instalment)',
241        'clearance': 'Acceptance Fee',
242        'late_registration': 'Late Course Registration Fee',
243        }
244
245    APP_CATS_DICT = {
246        'basic': 'PUTME, PUDE, PCE, PRENCE',
247        'no': 'No Application',
248        'pg_ft': 'Postgraduate Full-Time',
249        'pg_pt': 'Postgraduate Part-Time',
250        'cest': 'Part-Time, Diploma, Certificate',
251        'found': 'Foundation',
252        'ptee': 'Part-Time Entrance Examination',
253        'ioe_dp': 'Institute of Education Diploma',
254        'ijmbe': 'IJMBE Preparation',
255        'bridge': 'Bridge',
256        'dsh': 'Science and Humanities',
257
258        }
259
260    STUDY_MODES_DICT = {
261        'ug_ft': 'Undergraduate Full Time',
262        'ug_pt': 'Undergraduate Part Time',
263        'de_ft': 'Direct Entry Full Time',
264        'de_pt': 'Direct Entry Part Time',
265        'dp_pt': 'Diploma Part Time',
266        'dp_ft': 'Diploma Full Time',
267        'special_pg_ft': 'Postgraduate Full Time',
268        'special_pg_pt': 'Postgraduate Part Time',
269        'found': 'Foundation',
270        'transfer': 'Transfer',
271        'transferred': 'Transferred',
272        'mug_ft': 'Undergraduate Full Time Merit List',
273        'mde_ft': 'Direct Entry Full Time Merit List',
274        'ijmbe': 'IJMBE Preparation',
275        'bridge': 'Bridge',
276        'ug_dsh': 'Undergraduate Science and Humanities',
277        'de_dsh': 'Direct Entry Science and Humanities',
278        }
279
280    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
281
282    VERDICTS_DICT = {
283        '0': 'not yet',
284        'A': 'Successful student',
285        'B': 'Student with carryover courses',
286        'C': 'Student on probation',
287        'D': 'Withdrawn from the faculty',
288        #'E': 'Student who were previously on probation',
289        #'F': 'Medical case',
290        #'G': 'Absent from examination',
291        #'H': 'Withheld results',
292        #'I': 'Expelled/rusticated/suspended student',
293        #'J': 'Temporary withdrawn from the university',
294        #'K': 'Unregistered student',
295        #'L': 'Referred student',
296        #'M': 'Reinstatement',
297        #'N': 'Student on transfer',
298        #'O': 'NCE-III repeater',
299        #'Y': 'No previous verdict',
300        #'X': 'New 300 level student',
301        'Z': 'Successful student (provisional)',
302        #'A1': 'First Class',
303        #'A2': 'Second Class Upper',
304        #'A3': 'Second Class Lower',
305        #'A4': 'Third Class',
306        #'A5': 'Pass',
307        #'A6': 'Distinction',
308        #'A7': 'Credit',
309        #'A8': 'Merit',
310        'NER': 'No evidence of registration',
311        'NYV': 'Not yet verified',
312        'FRNS': 'Faculty requirements not satisfied',
313        }
314
315    DISABLE_PAYMENT_GROUP_DICT = {
316        'sf_all': 'School Fees - All Students',
317        'sf_pg': 'School Fees - Postgraduate Students',
318        'sf_ug_pt': 'School Fees - Undergraduate Part-Time Students',
319        'sf_found': 'School Fees - Foundation Students',
320        'maint_all': 'Accommodation Fee - All Students',
321        'cl_regular': 'Acceptance Fee - Regular Students',
322        }
323
324    MODE_GROUPS = {
325        'All': ('all',),
326        'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'),
327        'Undergraduate Part-Time': ('ug_pt', 'de_pt'),
328        'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'),
329        'Foundation Programme': ('found',),
330        'Institute of Education': ('dp_ft'),
331        'IJMBE Preparation': ('ijmbe',),
332        'Bridge': ('bridge',),
333        }
334
335    #: Maximum number of files listed in `finished` subfolder
336    MAX_FILES = 5000
337
338    def fullname(self, firstname, lastname, middlename=None):
339        """Construct fullname.
340        """
341        try:
342            lastname = lastname.upper()
343        except AttributeError:
344            pass
345        # We remove single initial
346        if firstname and len(firstname) == 1:
347            firstname = ''
348        if middlename and len(middlename) == 1:
349            middlename = ''
350        if lastname and len(lastname) == 1:
351            lastname = ''
352        # We construct givennames
353        givennames = ''
354        if middlename and firstname:
355            givennames = '%s %s' % (firstname, middlename)
356        elif firstname:
357            givennames = firstname
358        elif middlename:
359            givennames = middlename
360        givennames = string.capwords(
361            givennames.replace('-', ' - ')).replace(' - ', '-')
362        # We construct fullname
363        fullname = ''
364        if lastname and givennames:
365            fullname = '%s, %s' % (lastname, givennames)
366        elif lastname:
367            fullname = lastname
368        elif givennames:
369            fullname = givennames
370        if '<' in fullname:
371            return 'XXX'
372        return fullname
373
374    def getUsers(self):
375        users = sorted(
376            grok.getSite()['users'].items(), key=lambda x: x[0])
377        for key, val in users:
378            yield(dict(name=key, val="%s - %s" % (val.name, val.title)))
Note: See TracBrowser for help on using the repository browser.