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

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

Change payment categories.

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