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

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

Add three new payment categories.

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