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

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

Customize getUsers.

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