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

Last change on this file since 16179 was 16179, checked in by Henrik Bettermann, 4 years ago

ICT/Affidavit Dues still remains.

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