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

Last change on this file since 15978 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
Line 
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##
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        }
75
76    SELECTABLE_PAYMENT_CATEGORIES = {
77        'schoolfee': 'School Fee without additional fees',
78        'schoolfee_1': 'School Fee (1st instalment) incl. additional fees',
79        'schoolfee_2': 'School Fee (2nd instalment)',
80        'schoolfee_incl': 'School Fee incl. additional fees',
81        'clearance': 'Acceptance Fee without additional fees',
82        'clearance_incl': 'Acceptance Fee incl. additional fees',
83        'hostel_maintenance': 'Hostel Accommodation Fee',
84        #'application': 'Application Fee',
85        #'bed_allocation': 'Bed Allocation Fee',
86        #'transfer': 'Transfer Fee',
87        'transcript_local': 'Local Transcript Fee',
88        'transcript_inter': 'International Transcript Fee',
89        'late_registration': 'Late Course Registration Fee',
90        #'welfare': 'Student Welfare Assurance Fee',
91        #'union': 'Student Union Dues',
92        #'lapel': 'Lapel/File Fee',
93        #'matric_gown': 'Matriculation Gown Fee',
94        'concessional': 'Concessional Fee',
95        #'id_card': 'Student ID Card',
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',
99        'gst_text_book_3': 'Text Book Fee GST222',
100        'ent_text_book_1': 'Text Book Fee ENT201',
101        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
102        'gst_registration_2': 'Registration Fee GST222',
103        'ent_registration_1': 'Registration Fee ENT201',
104        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
105        'restitution': 'Restitution Fee',
106        #'sports': 'Sports Fee',
107        #'library': 'Library Fee UG',
108        #'library_pg': 'Library Fee PG',
109        'sports_library': 'Sports Development and UG Library Fee',
110        }
111
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',
120        'late_registration': 'Late Course Registration Fee',
121        #'library_pg': 'Library Fee PG',
122        'sports_library': 'Sports Development and UG Library Fee',
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)',
130        #'sports': 'Sports Fee',
131        #'library': 'Library Fee UG',
132        'sports_library': 'Sports Development and UG Library Fee',
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',
146        'late_registration': 'Late Course Registration Fee',
147        #'sports': 'Sports Fee',
148        #'library': 'Library Fee UG',
149        'sports_library': 'Sports Development and UG Library Fee',
150        }
151
152    def selectable_payment_categories(self, student):
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
163        return self.SELECTABLE_PAYMENT_CATEGORIES
164
165    REPORTABLE_PAYMENT_CATEGORIES = {
166        'schoolfee': 'School Fee',
167        'schoolfee_incl': 'School Fee Plus',
168        'schoolfee_1': 'School Fee 1 Plus',
169        'schoolfee_2': 'School Fee 2',
170        'clearance': 'Acceptance Fee',
171        'clearance_incl': 'Acceptance Fee Plus',
172        'hostel_maintenance': 'Hostel Maintenance Fee',
173        }
174
175    BALANCE_PAYMENT_CATEGORIES = {
176        'schoolfee': 'School Fee',
177        'clearance': 'Acceptance Fee',
178        'hostel_maintenance': 'Hostel Maintenance Fee',
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',
184        'id_card': 'Student ID Card',
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',
188        'ent_text_book_1': 'Text Book Fee ENT201',
189        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
190        'gst_registration_2': 'Registration Fee GST222',
191        'ent_registration_1': 'Registration Fee ENT201',
192        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
193        'restitution': 'Restitution Fee',
194        }
195
196    PREVIOUS_PAYMENT_CATEGORIES = {
197        'schoolfee': 'School Fee',
198        'clearance': 'Acceptance Fee',
199        }
200
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',
208        'ptee': 'Part-Time Entrance Examination',
209        'ioe_dp': 'Institute of Education Diploma',
210        'ijmbe': 'IJMBE Preparation',
211        'bridge': 'Bridge',
212        'dsh': 'Science and Humanities',
213
214        }
215
216    STUDY_MODES_DICT = {
217        'ug_ft': 'Undergraduate Full Time',
218        'ug_pt': 'Undergraduate Part Time',
219        'de_ft': 'Direct Entry Full Time',
220        'de_pt': 'Direct Entry Part Time',
221        'dp_pt': 'Diploma Part Time',
222        'dp_ft': 'Diploma Full Time',
223        'special_pg_ft': 'Postgraduate Full Time',
224        'special_pg_pt': 'Postgraduate Part Time',
225        'found': 'Foundation',
226        'transfer': 'Transfer',
227        'mug_ft': 'Undergraduate Full Time Merit List',
228        'mde_ft': 'Direct Entry Full Time Merit List',
229        'ijmbe': 'IJMBE Preparation',
230        'bridge': 'Bridge',
231        'ug_dsh': 'Undergraduate Science and Humanities',
232        'de_dsh': 'Direct Entry Science and Humanities',
233        }
234
235    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
236
237    VERDICTS_DICT = {
238        '0': 'not yet',
239        'A': 'Successful student',
240        'B': 'Student with carryover courses',
241        'C': 'Student on probation',
242        'D': 'Withdrawn from the faculty',
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',
265        'NER': 'No evidence of registration',
266        'NYV': 'Not yet verified',
267        'FRNS': 'Faculty requirements not satisfied',
268        }
269
270    DISABLE_PAYMENT_GROUP_DICT = {
271        'sf_all': 'School Fee - All Students',
272        'sf_pg': 'School Fee - Postgraduate Students',
273        'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students',
274        'sf_found': 'School Fee - Foundation Students',
275        'maint_all': 'Accommodation Fee - All Students',
276        'cl_regular': 'Acceptance Fee - Regular Students',
277        }
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'),
286        'IJMBE Preparation': ('ijmbe',),
287        'Bridge': ('bridge',),
288        }
289
290    #: Maximum number of files listed in `finished` subfolder
291    MAX_FILES = 5000
292
293    def fullname(self, firstname, lastname, middlename=None):
294        """Construct fullname.
295        """
296        try:
297            lastname = lastname.upper()
298        except AttributeError:
299            pass
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:
310            givennames = '%s %s' % (firstname, middlename)
311        elif firstname:
312            givennames = firstname
313        elif middlename:
314            givennames = middlename
315        givennames = string.capwords(
316            givennames.replace('-', ' - ')).replace(' - ', '-')
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
325        if '<' in fullname:
326            return 'XXX'
327        return fullname
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.