1 | ## $Id: utils.py 16461 2021-04-15 10:01:13Z 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 | import string |
---|
21 | from copy import deepcopy |
---|
22 | from kofacustom.nigeria.utils.utils import NigeriaKofaUtils |
---|
23 | from waeup.fceokene.interfaces import MessageFactory as _ |
---|
24 | |
---|
25 | class CustomKofaUtils(NigeriaKofaUtils): |
---|
26 | """A collection of methods subject to customization. |
---|
27 | """ |
---|
28 | |
---|
29 | STUDY_MODES_DICT = { |
---|
30 | #'ume_ft': 'UME Full Time', |
---|
31 | 'ug_ft': 'Undergraduate Full Time', |
---|
32 | #'ug_pt': 'Undergraduate Part Time', |
---|
33 | #'dp_pt': 'Diploma Part Time', |
---|
34 | 'ct_ft': 'Certificate Full Time', |
---|
35 | #'dp_ft': 'Diploma Full Time', |
---|
36 | 'de_ft': 'Direct Entry Full Time', |
---|
37 | 'de_pt': 'Direct Entry Part Time', |
---|
38 | #'nd_ft': 'National Diploma Full Time', |
---|
39 | #'nd_pt': 'National Diploma Part Time', |
---|
40 | #'hnd_ft': 'Higher National Diploma Full Time', |
---|
41 | #'hnd_pt': 'Higher National Diploma Part Time', |
---|
42 | #'pg_ft': 'Postgraduate Full Time', |
---|
43 | #'pg_pt': 'Postgraduate Part Time', |
---|
44 | #'pgd_ft': 'Postgraduate Diploma Full Time', |
---|
45 | #'pgd_pt': 'Postgraduate Diploma Part Time', |
---|
46 | #'special_pg_pt': 'Special Postgraduate Part Time', |
---|
47 | 'nce_ft': 'NCE Full Time', |
---|
48 | #'nce_pt': 'NCE Part Time', |
---|
49 | #'ug_sw': 'Undergraduate Sandwich', |
---|
50 | 'nce_sw': 'NCE Sandwich', |
---|
51 | #'jm_ft': 'Joint Matriculation Full Time', |
---|
52 | #'ph_ft': 'Post Higher Education Full Time', |
---|
53 | #'transfer_pt': 'Transfer Part Time', |
---|
54 | #'transfer_ft': 'Transfer Full Time', |
---|
55 | #'ct_pt': 'Certificate Part Time', |
---|
56 | #'rmd_ft': 'Remedial with deficiencies', |
---|
57 | #'rm_ft': 'Remedial', |
---|
58 | 'transfer': 'Transfer', |
---|
59 | 'prence': 'Pre-NCE/Pre-Degree', |
---|
60 | #'prend': 'Pre-ND', |
---|
61 | #'pce': 'PCE', |
---|
62 | 'pd_ft': 'Professional Diploma in Education', |
---|
63 | #'found': 'Foundation', |
---|
64 | 'no': 'no application', |
---|
65 | } |
---|
66 | |
---|
67 | PREFERRED_LANGUAGES_DICT = { |
---|
68 | } |
---|
69 | |
---|
70 | APP_CATS_DICT = { |
---|
71 | 'basic': 'UTME, DE, PCE, PRENCE', |
---|
72 | 'no': 'No Application', |
---|
73 | 'sandwich': 'Sandwich', |
---|
74 | 'cest': 'Part-Time, Diploma, Certificate', |
---|
75 | 'bec': 'Bachelor of Education Certificate Programmes', |
---|
76 | 'pre': 'Pre-Degree Studies', |
---|
77 | 'prence': 'Pre-NCE/Pre-Degree Programmes', |
---|
78 | } |
---|
79 | |
---|
80 | SPECIAL_HANDLING_DICT = { |
---|
81 | 'regular': 'Regular Hostel', |
---|
82 | 'blocked': 'Blocked Hostel', |
---|
83 | 'ugft': 'Undergraduate Fulltime Hostel' |
---|
84 | } |
---|
85 | |
---|
86 | PAYMENT_CATEGORIES = { |
---|
87 | 'schoolfee': 'School Fee', |
---|
88 | 'schoolfee_pde1': 'School Fee 1st instalment (new PDE students only)', |
---|
89 | 'clearance': 'Acceptance Fee', |
---|
90 | 'bed_allocation': 'Bed Allocation Fee', |
---|
91 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
92 | 'application': 'Application Fee', |
---|
93 | 'third_semester': 'NCE Third Semester Fee', |
---|
94 | } |
---|
95 | |
---|
96 | DISABLE_PAYMENT_GROUP_DICT = { |
---|
97 | 'sf_all': 'School Fee - All Students', |
---|
98 | 'sf_nce1': 'School Fee - NCE I Fresh Students', |
---|
99 | } |
---|
100 | |
---|
101 | def selectable_payment_categories(self, student): |
---|
102 | return self.PAYMENT_CATEGORIES |
---|
103 | |
---|
104 | VERDICTS_DICT = { |
---|
105 | '0': 'not yet', |
---|
106 | 'A': 'Successful student', |
---|
107 | 'B': 'Student with carryover courses', |
---|
108 | 'C': 'Student on probation', |
---|
109 | 'D': 'Withdrawn from the faculty', |
---|
110 | #'E': 'Student who were previously on probation', |
---|
111 | #'F': 'Medical case', |
---|
112 | 'G': 'Absent from examination', |
---|
113 | #'H': 'Withheld results', |
---|
114 | 'I': 'Expelled/rusticated/suspended student', |
---|
115 | 'J': 'Temporary withdrawn from the university', |
---|
116 | #'K': 'Unregistered student', |
---|
117 | 'L': 'Referred student', |
---|
118 | 'M': 'Reinstatement', |
---|
119 | #'N': 'Student on transfer', |
---|
120 | 'O': 'NCE-III repeater', |
---|
121 | #'Y': 'No previous verdict', |
---|
122 | #'X': 'New 300 level student (Uniben)', |
---|
123 | 'Z': 'Successful student (provisional)', |
---|
124 | 'A1': 'First Class', |
---|
125 | 'A2': 'Second Class Upper', |
---|
126 | 'A3': 'Second Class Lower', |
---|
127 | 'A4': 'Third Class', |
---|
128 | 'A5': 'Pass', |
---|
129 | 'A6': 'Distinction', |
---|
130 | 'A7': 'Credit', |
---|
131 | 'A8': 'Merit', |
---|
132 | 'OPDE': 'PDE repeater', |
---|
133 | } |
---|
134 | |
---|
135 | def getPaymentItem(self, payment): |
---|
136 | """Return payment item. |
---|
137 | |
---|
138 | Bed coordinates are only visible after payment. |
---|
139 | """ |
---|
140 | if 'maintenance' in payment.p_category and payment.p_state != 'paid': |
---|
141 | return _('(visible after successful payment)') |
---|
142 | return payment.p_item |
---|
143 | |
---|
144 | def fullname(self, firstname, lastname, middlename=None): |
---|
145 | """Construct fullname. |
---|
146 | """ |
---|
147 | try: |
---|
148 | lastname = lastname.upper() |
---|
149 | except AttributeError: |
---|
150 | pass |
---|
151 | # We remove single initial |
---|
152 | if firstname and len(firstname) == 1: |
---|
153 | firstname = '' |
---|
154 | if middlename and len(middlename) == 1: |
---|
155 | middlename = '' |
---|
156 | if lastname and len(lastname) == 1: |
---|
157 | lastname = '' |
---|
158 | # We construct givennames |
---|
159 | givennames = '' |
---|
160 | if middlename and firstname: |
---|
161 | givennames = '%s %s' % (firstname, middlename) |
---|
162 | elif firstname: |
---|
163 | givennames = firstname |
---|
164 | elif middlename: |
---|
165 | givennames = middlename |
---|
166 | givennames = string.capwords( |
---|
167 | givennames.replace('-', ' - ')).replace(' - ', '-') |
---|
168 | # We construct fullname |
---|
169 | fullname = '' |
---|
170 | if lastname and givennames: |
---|
171 | fullname = '%s %s' % (givennames, lastname) |
---|
172 | elif lastname: |
---|
173 | fullname = lastname |
---|
174 | elif givennames: |
---|
175 | fullname = givennames |
---|
176 | if '<' in fullname: |
---|
177 | return 'XXX' |
---|
178 | return fullname |
---|