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

Last change on this file was 17797, checked in by Henrik Bettermann, 4 months ago

Customize certificate title.

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