source: main/waeup.fceokene/trunk/src/waeup/fceokene/utils/utils.py @ 18058

Last change on this file since 18058 was 18057, checked in by Henrik Bettermann, 3 months ago

Add reg2sandwich payment category.

  • Property svn:keywords set to Id
File size: 7.4 KB
RevLine 
[7569]1## $Id: utils.py 18057 2025-04-09 10:10:39Z 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##
[7822]18"""Customize general helper utilities for Kofa.
[7569]19"""
[15427]20import string
[11913]21from copy import deepcopy
[8834]22from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
[9989]23from waeup.fceokene.interfaces import MessageFactory as _
[7569]24
[8834]25class CustomKofaUtils(NigeriaKofaUtils):
[7569]26    """A collection of methods subject to customization.
27    """
[7845]28
[14590]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',
[14936]36        'de_ft': 'Direct Entry Full Time',
37        'de_pt': 'Direct Entry Part Time',
[14590]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',
[14812]59        'prence': 'Pre-NCE/Pre-Degree',
[14590]60        #'prend': 'Pre-ND',
61        #'pce': 'PCE',
62        'pd_ft': 'Professional Diploma in Education',
63        #'found': 'Foundation',
64        'no': 'no application',
65        }
66
[7845]67    PREFERRED_LANGUAGES_DICT = {
68        }
[9461]69
70    APP_CATS_DICT = {
[10570]71        'basic': 'UTME, DE, PCE, PRENCE',
[9461]72        'no': 'No Application',
73        'sandwich': 'Sandwich',
74        'cest': 'Part-Time, Diploma, Certificate',
75        'bec': 'Bachelor of Education Certificate Programmes',
[14812]76        'pre': 'Pre-Degree Studies',
77        'prence': 'Pre-NCE/Pre-Degree Programmes',
[16868]78        #'tpu': 'Teaching Practice Unit Courses'  use basic instead!!
[9461]79        }
[9989]80
[13614]81    SPECIAL_HANDLING_DICT = {
82        'regular': 'Regular Hostel',
83        'blocked': 'Blocked Hostel',
84        'ugft': 'Undergraduate Fulltime Hostel'
85        }
[11913]86
87    PAYMENT_CATEGORIES = {
88        'schoolfee': 'School Fee',
[17734]89        'schoolfee_pde1': 'New PDE students first instalment',
90        'schoolfee_ug_new': 'Undergraduate new students first instalment',
91        'schoolfee_ug_ret': 'Undergraduate returning students first instalment',
[16899]92        'schoolfee_third': 'NCE Third Semester Fee (6 courses)',
[11913]93        'clearance': 'Acceptance Fee',
94        'bed_allocation': 'Bed Allocation Fee',
95        'hostel_maintenance': 'Hostel Maintenance Fee',
96        'application': 'Application Fee',
[18057]97        'reg2sandwich': 'Regular to Sandwich (14 courses)',
[11913]98        }
99
[16899]100    SELECTABLE_PAYMENT_CATEGORIES = {
101        'schoolfee': 'School Fee',
[17734]102        'schoolfee_pde1': 'New PDE students first instalment',
103        'schoolfee_ug_new': 'Undergraduate new students first instalment',
104        'schoolfee_ug_ret': 'Undergraduate returning students first instalment',
[16899]105        'schoolfee_third': 'NCE Third Semester Fee (6 courses)',
106        'clearance': 'Acceptance Fee',
107        'bed_allocation': 'Bed Allocation Fee',
108        'hostel_maintenance': 'Hostel Maintenance Fee',
109        'application': 'Application Fee',
110        #'third_semester': 'NCE Third Semester Fee (additional courses)',
[18057]111        'reg2sandwich': 'Regular to Sandwich (14 courses)',
[16899]112        }
113
[13030]114    DISABLE_PAYMENT_GROUP_DICT = {
115        'sf_all': 'School Fee - All Students',
116        'sf_nce1': 'School Fee - NCE I Fresh Students',
[16554]117        'cl_except_ug': 'Acceptance Fee - All Students except UG Full Time',
[13030]118        }
119
[16899]120    BALANCE_PAYMENT_CATEGORIES = {
121        'schoolfee': 'School Fee',
122        'third_semester': 'NCE Third Semester Fee (N2000 per additional course)',
123        }
124
[15435]125    def selectable_payment_categories(self, student):
[16899]126        return self.SELECTABLE_PAYMENT_CATEGORIES
[11913]127
[13128]128    VERDICTS_DICT = {
129        '0': 'not yet',
130        'A': 'Successful student',
131        'B': 'Student with carryover courses',
132        'C': 'Student on probation',
133        'D': 'Withdrawn from the faculty',
134        #'E': 'Student who were previously on probation',
135        #'F': 'Medical case',
136        'G': 'Absent from examination',
137        #'H': 'Withheld results',
138        'I': 'Expelled/rusticated/suspended student',
139        'J': 'Temporary withdrawn from the university',
140        #'K': 'Unregistered student',
141        'L': 'Referred student',
142        'M': 'Reinstatement',
143        #'N': 'Student on transfer',
144        'O': 'NCE-III repeater',
145        #'Y': 'No previous verdict',
146        #'X': 'New 300 level student (Uniben)',
147        'Z': 'Successful student (provisional)',
148        'A1': 'First Class',
149        'A2': 'Second Class Upper',
150        'A3': 'Second Class Lower',
151        'A4': 'Third Class',
152        'A5': 'Pass',
153        'A6': 'Distinction',
154        'A7': 'Credit',
155        'A8': 'Merit',
156        'OPDE': 'PDE repeater',
157        }
158
[9989]159    def getPaymentItem(self, payment):
160        """Return payment item.
161
162        Bed coordinates are only visible after payment.
163        """
164        if 'maintenance' in payment.p_category and payment.p_state != 'paid':
165            return _('(visible after successful payment)')
[15427]166        return payment.p_item
167
168    def fullname(self, firstname, lastname, middlename=None):
169        """Construct fullname.
170        """
171        try:
172            lastname = lastname.upper()
173        except AttributeError:
174            pass
175        # We remove single initial
176        if firstname and len(firstname) == 1:
177            firstname = ''
178        if middlename and len(middlename) == 1:
179            middlename = ''
180        if lastname and len(lastname) == 1:
181            lastname = ''
182        # We construct givennames
183        givennames = ''
184        if middlename and firstname:
185            givennames = '%s %s' % (firstname, middlename)
186        elif firstname:
187            givennames = firstname
188        elif middlename:
189            givennames = middlename
190        givennames = string.capwords(
191            givennames.replace('-', ' - ')).replace(' - ', '-')
192        # We construct fullname
193        fullname = ''
194        if lastname and givennames:
195            fullname = '%s %s' % (givennames, lastname)
196        elif lastname:
197            fullname = lastname
198        elif givennames:
199            fullname = givennames
200        if '<' in fullname:
201            return 'XXX'
202        return fullname
Note: See TracBrowser for help on using the repository browser.