## $Id: utils.py 16754 2022-01-25 08:25:36Z henrik $ ## ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """Customize general helper utilities for Kofa. """ import string import grok from kofacustom.nigeria.utils.utils import NigeriaKofaUtils from waeup.kofa.students.workflow import ALUMNI_STATES class CustomKofaUtils(NigeriaKofaUtils): """A collection of methods subject to customization. """ PREFERRED_LANGUAGES_DICT = { } COURSE_CATEGORY_DICT = { 'C':'Core Course (C)', 'R':'Required Courses (R)', 'E':'Elective Courses (E)', } PAYMENT_CATEGORIES = { 'schoolfee': 'School Fee', 'schoolfee_1': 'School Fee Plus (1st instalment)', 'schoolfee_2': 'School Fee (2nd instalment)', 'schoolfee_incl': 'School Fee Plus', 'clearance': 'Acceptance Fee', 'clearance_incl': 'Acceptance Fee Plus', 'hostel_maintenance': 'Hostel Accommodation Fee', 'application': 'Application Fee', 'app_balance': 'Application Fee Balance', 'bed_allocation': 'Bed Allocation Fee', 'transfer': 'Transfer Fee', 'transcript_local': 'Local Transcript Fee', 'transcript_inter': 'International Transcript Fee', 'late_registration': 'Late Course Registration Fee', 'welfare': 'Student Welfare Assurance Fee', 'union': 'Student Union Dues', 'lapel': 'Lapel/File Fee', 'matric_gown': 'Matriculation Gown Fee', 'concessional': 'Concessional Fee', 'id_card': 'Student ID Card', 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', 'gst_text_book_1': 'Text Book Fee GST101 GST102', 'gst_text_book_2': 'Text Book Fee GST111 GST112', 'gst_text_book_3': 'Text Book Fee GST222', 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', 'gst_registration_2': 'Registration Fee GST222', 'ent_text_book_1': 'Text Book Fee ENT201', 'ent_text_book_2': 'Text Book Fee ENT211', 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', 'ent_registration_1': 'Registration Fee ENT201', 'ent_registration_2': 'Registration Fee ENT211', 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', 'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', 'ict': 'ICT/Affidavit Dues', 'affidavit': 'Affidavit Dues', 'restitution': 'Restitution Fee', 'sports': 'Sports Fee', 'library': 'UG Library Fee', 'library_pg': 'PG Library Fee', 'sports_library': 'Sports Development and Library Fee', 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', 'lab_2': 'Laboratory Due (BIO101/BIO111)', } SELECTABLE_PAYMENT_CATEGORIES = { 'schoolfee': 'School Fee without additional fees', 'schoolfee_1': 'School Fee (1st instalment) incl. additional fees', 'schoolfee_2': 'School Fee (2nd instalment)', 'schoolfee_incl': 'School Fee incl. additional fees', 'clearance': 'Acceptance Fee without additional fees', 'clearance_incl': 'Acceptance Fee incl. additional fees', 'hostel_maintenance': 'Hostel Accommodation Fee', #'application': 'Application Fee', #'bed_allocation': 'Bed Allocation Fee', #'transfer': 'Transfer Fee', 'transcript_local': 'Local Transcript Fee', 'transcript_inter': 'International Transcript Fee', 'late_registration': 'Late Course Registration Fee', #'welfare': 'Student Welfare Assurance Fee', #'union': 'Student Union Dues', #'lapel': 'Lapel/File Fee', #'matric_gown': 'Matriculation Gown Fee', 'concessional': 'Concessional Fee', #'id_card': 'Student ID Card', 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', 'gst_text_book_1': 'Text Book Fee GST101 GST102', 'gst_text_book_2': 'Text Book Fee GST111 GST112', 'gst_text_book_3': 'Text Book Fee GST222', 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', 'gst_registration_2': 'Registration Fee GST222', 'ent_text_book_1': 'Text Book Fee ENT201', 'ent_text_book_2': 'Text Book Fee ENT211', 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', 'ent_registration_1': 'Registration Fee ENT201', 'ent_registration_2': 'Registration Fee ENT211', 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', 'ict': 'ICT/Affidavit Dues', #'affidavit': 'Affidavit Dues', 'restitution': 'Restitution Fee', 'sports': 'Sports Fee', 'library': 'UG Library Fee', 'library_pg': 'PG Library Fee', 'sports_library': 'Sports Development and Library Fee', 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', 'lab_2': 'Laboratory Due (BIO101/BIO111)', } ALUMNI_PAYMENT_CATS = { 'transcript_local': 'Transcript Fee Local', 'transcript_inter': 'Transcript Fee International', } REDUCED_PAYMENT_CATS = { 'clearance': 'Acceptance Fee', 'schoolfee': 'School Fee', 'late_registration': 'Late Course Registration Fee', 'sports': 'Sports Fee', 'library': 'UG Library Fee', 'library_pg': 'PG Library Fee', 'sports_library': 'Sports Development and Library Fee', } IJMBE_PAYMENT_CATS = { 'clearance': 'Acceptance Fee', 'schoolfee': 'School Fee', 'schoolfee_1': 'School Fee (1st instalment)', 'schoolfee_2': 'School Fee (2nd instalment)', 'sports': 'Sports Fee', 'library': 'UG Library Fee', 'library_pg': 'PG Library Fee', 'sports_library': 'Sports Development and Library Fee', } PT_AND_DSH_PAYMENT_CATS = { 'clearance_incl': 'Acceptance Fee Plus', 'schoolfee_incl': 'School Fee Plus', 'ent_text_book_1': 'Text Book Fee ENT201', 'ent_text_book_2': 'Text Book Fee ENT211', 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', 'ent_registration_1': 'Registration Fee ENT201', 'ent_registration_2': 'Registration Fee ENT211', 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', 'gst_registration_2': 'Registration Fee GST222', 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', 'gst_text_book_1': 'Text Book Fee GST101 GST102', 'gst_text_book_2': 'Text Book Fee GST111 GST112', 'gst_text_book_3': 'Text Book Fee GST222', 'late_registration': 'Late Course Registration Fee', 'sports': 'Sports Fee', 'library': 'UG Library Fee', 'library_pg': 'PG Library Fee', 'sports_library': 'Sports Development and Library Fee', 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', 'lab_2': 'Laboratory Due (BIO101/BIO111)', } def selectable_payment_categories(self, student): if student.state in ALUMNI_STATES: return self.ALUMNI_PAYMENT_CATS if student.current_mode in ( 'special_pg_ft', 'special_pg_pt', 'found', 'bridge'): return self.REDUCED_PAYMENT_CATS if student.current_mode in ( 'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'): return self.PT_AND_DSH_PAYMENT_CATS if student.current_mode == 'ijmbe': return self.IJMBE_PAYMENT_CATS return self.SELECTABLE_PAYMENT_CATEGORIES REPORTABLE_PAYMENT_CATEGORIES = { 'schoolfee': 'School Fee', 'schoolfee_incl': 'School Fee Plus', 'schoolfee_1': 'School Fee 1 Plus', 'schoolfee_2': 'School Fee 2', 'clearance': 'Acceptance Fee', 'clearance_incl': 'Acceptance Fee Plus', 'hostel_maintenance': 'Hostel Maintenance Fee', } BALANCE_PAYMENT_CATEGORIES = { 'schoolfee': 'School Fee', 'clearance': 'Acceptance Fee', 'hostel_maintenance': 'Hostel Maintenance Fee', 'late_registration': 'Late Course Registration Fee', 'welfare': 'Student Welfare Assurance Fee', 'union': 'Student Union Dues', 'lapel': 'Lapel/File Fee', 'matric_gown': 'Matriculation Gown Fee', 'id_card': 'Student ID Card', 'gst_text_book_1': 'Text Book Fee GST101 GST102', 'gst_text_book_2': 'Text Book Fee GST111 GST112', 'gst_text_book_3': 'Text Book Fee GST222', 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', 'gst_registration_2': 'Registration Fee GST222', 'ent_text_book_1': 'Text Book Fee ENT201', 'ent_text_book_2': 'Text Book Fee ENT211', 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', 'ent_registration_1': 'Registration Fee ENT201', 'ent_registration_2': 'Registration Fee ENT211', 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', 'ict': 'ICT/Affidavit Dues', #'affidavit': 'Affidavit Dues', 'restitution': 'Restitution Fee', } PREVIOUS_PAYMENT_CATEGORIES = { 'schoolfee': 'School Fee', 'clearance': 'Acceptance Fee', 'late_registration': 'Late Course Registration Fee', } APP_CATS_DICT = { 'basic': 'PUTME, PUDE, PCE, PRENCE', 'no': 'No Application', 'pg_ft': 'Postgraduate Full-Time', 'pg_pt': 'Postgraduate Part-Time', 'cest': 'Part-Time, Diploma, Certificate', 'found': 'Foundation', 'ptee': 'Part-Time Entrance Examination', 'ioe_dp': 'Institute of Education Diploma', 'ijmbe': 'IJMBE Preparation', 'bridge': 'Bridge', 'dsh': 'Science and Humanities', } STUDY_MODES_DICT = { 'ug_ft': 'Undergraduate Full Time', 'ug_pt': 'Undergraduate Part Time', 'de_ft': 'Direct Entry Full Time', 'de_pt': 'Direct Entry Part Time', 'dp_pt': 'Diploma Part Time', 'dp_ft': 'Diploma Full Time', 'special_pg_ft': 'Postgraduate Full Time', 'special_pg_pt': 'Postgraduate Part Time', 'found': 'Foundation', 'transfer': 'Transfer', 'mug_ft': 'Undergraduate Full Time Merit List', 'mde_ft': 'Direct Entry Full Time Merit List', 'ijmbe': 'IJMBE Preparation', 'bridge': 'Bridge', 'ug_dsh': 'Undergraduate Science and Humanities', 'de_dsh': 'Direct Entry Science and Humanities', } ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT VERDICTS_DICT = { '0': 'not yet', 'A': 'Successful student', 'B': 'Student with carryover courses', 'C': 'Student on probation', 'D': 'Withdrawn from the faculty', #'E': 'Student who were previously on probation', #'F': 'Medical case', #'G': 'Absent from examination', #'H': 'Withheld results', #'I': 'Expelled/rusticated/suspended student', #'J': 'Temporary withdrawn from the university', #'K': 'Unregistered student', #'L': 'Referred student', #'M': 'Reinstatement', #'N': 'Student on transfer', #'O': 'NCE-III repeater', #'Y': 'No previous verdict', #'X': 'New 300 level student', 'Z': 'Successful student (provisional)', #'A1': 'First Class', #'A2': 'Second Class Upper', #'A3': 'Second Class Lower', #'A4': 'Third Class', #'A5': 'Pass', #'A6': 'Distinction', #'A7': 'Credit', #'A8': 'Merit', 'NER': 'No evidence of registration', 'NYV': 'Not yet verified', 'FRNS': 'Faculty requirements not satisfied', } DISABLE_PAYMENT_GROUP_DICT = { 'sf_all': 'School Fee - All Students', 'sf_pg': 'School Fee - Postgraduate Students', 'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students', 'sf_found': 'School Fee - Foundation Students', 'maint_all': 'Accommodation Fee - All Students', 'cl_regular': 'Acceptance Fee - Regular Students', } MODE_GROUPS = { 'All': ('all',), 'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'), 'Undergraduate Part-Time': ('ug_pt', 'de_pt'), 'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'), 'Foundation Programme': ('found',), 'Institute of Education': ('dp_ft'), 'IJMBE Preparation': ('ijmbe',), 'Bridge': ('bridge',), } #: Maximum number of files listed in `finished` subfolder MAX_FILES = 5000 def fullname(self, firstname, lastname, middlename=None): """Construct fullname. """ try: lastname = lastname.upper() except AttributeError: pass # We remove single initial if firstname and len(firstname) == 1: firstname = '' if middlename and len(middlename) == 1: middlename = '' if lastname and len(lastname) == 1: lastname = '' # We construct givennames givennames = '' if middlename and firstname: givennames = '%s %s' % (firstname, middlename) elif firstname: givennames = firstname elif middlename: givennames = middlename givennames = string.capwords( givennames.replace('-', ' - ')).replace(' - ', '-') # We construct fullname fullname = '' if lastname and givennames: fullname = '%s, %s' % (lastname, givennames) elif lastname: fullname = lastname elif givennames: fullname = givennames if '<' in fullname: return 'XXX' return fullname def getUsers(self): users = sorted( grok.getSite()['users'].items(), key=lambda x: x[0]) for key, val in users: yield(dict(name=key, val="%s - %s" % (val.name, val.title)))