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

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

Affidavit dues are now separate fees.

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