[7696] | 1 | ## $Id: utils.py 16807 2022-02-15 17:42:22Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 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 | """General helper functions and utilities for the application section. |
---|
| 19 | """ |
---|
| 20 | |
---|
[13816] | 21 | import grok |
---|
| 22 | from time import time |
---|
[16245] | 23 | from datetime import datetime |
---|
[8821] | 24 | from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils |
---|
[8647] | 25 | from waeup.kofa.applicants.workflow import (INITIALIZED, |
---|
| 26 | STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED) |
---|
[16131] | 27 | from waeup.uniben.applicants.interfaces import REGISTRATION_CATS, DESTINATION_COST |
---|
[8051] | 28 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[7696] | 29 | |
---|
[11782] | 30 | class CustomApplicantsUtils(NigeriaApplicantsUtils): |
---|
[7696] | 31 | """A collection of parameters and methods subject to customization. |
---|
| 32 | """ |
---|
| 33 | |
---|
[16164] | 34 | ADDITIONAL_FILES = ( |
---|
[16547] | 35 | ('Eligibility Form','eligibility'), |
---|
| 36 | ('Statement of Result','res_stat'), |
---|
[16164] | 37 | ) |
---|
| 38 | |
---|
[9635] | 39 | APP_TYPES_DICT = { |
---|
| 40 | 'pude': ['Post-UDE Screening', 'PUDE'], |
---|
| 41 | 'sandwich': ['Part-Time Degree in Education', 'SAND'], |
---|
| 42 | 'pt': ['Part-Time Degree Programmes', 'PTP'], |
---|
[11827] | 43 | 'ptext': ['Part-Time Degree Programmes (extended application)', 'PTP'], |
---|
[9635] | 44 | 'putme': ['Post-UTME Screening Exercise', 'PUTME'], |
---|
| 45 | 'app': ['General Studies', 'APP'], |
---|
| 46 | 'cest': ['Common Entry Screening Test', 'CEST'], |
---|
| 47 | 'ct': ['Certificate Programmes', 'CTP'], |
---|
| 48 | 'dp': ['Diploma Programmes', 'DPP'], |
---|
| 49 | 'dpft': ['Diploma Full-Time Programmes', 'DPP'], |
---|
[13011] | 50 | 'pg': ['Postgraduate Programmes (main advert)', 'PG'], |
---|
| 51 | 'pga': ['Postgraduate Programmes (1st supplementary advert)', 'PG'], |
---|
| 52 | 'pgb': ['Postgraduate Programmes (2nd supplementary advert)', 'PG'], |
---|
| 53 | 'pgc': ['Postgraduate Programmes (3rd supplementary advert)', 'PG'], |
---|
[13245] | 54 | 'pgd': ['Postgraduate Programmes (4th supplementary advert)', 'PG'], |
---|
[13615] | 55 | 'pgn': ['NILS Postgraduate Programmes', 'PG'], |
---|
[14691] | 56 | 'pre': ['JUPEB Pre-Degree (Foundation) Studies', 'PRE'], |
---|
[13151] | 57 | 'cbt': ['UNIBEN CBT Practice Test', 'CBT'], |
---|
[14061] | 58 | 'ab': ['Asaba Programmes', 'ASA'], |
---|
| 59 | 'ak': ['Akoka Programmes', 'AKO'], |
---|
| 60 | 'akj': ['Akoka JUPEB', 'AKO'], |
---|
[13796] | 61 | 'ictwk': ['ICT Week Registration', 'ICT'], |
---|
[13947] | 62 | 'ase': ['Uniben Admission Screening Exercise', 'ASE'], |
---|
[14162] | 63 | 'asea': ['Uniben Admission Screening Exercise ' |
---|
| 64 | '(1st supplementary advert)', 'ASE'], |
---|
| 65 | 'aseb': ['Uniben Admission Screening Exercise ' |
---|
| 66 | '(2nd supplementary advert)', 'ASE'], |
---|
[14811] | 67 | 'spft': ['Special Full-Time Programmes', 'SP'], |
---|
[16175] | 68 | 'tscf': ['Transcript (without student record)', 'TRF'], |
---|
| 69 | 'tscs': ['Transcript (with student record)', 'TRS'], |
---|
[16807] | 70 | 'flc': ['French Language Centre', 'FR'], |
---|
[9635] | 71 | } |
---|
| 72 | |
---|
[14867] | 73 | SEPARATORS_DICT = { |
---|
| 74 | 'form.applicant_id': _(u'Base Data'), |
---|
| 75 | 'form.course1': _(u'Programmes/Courses Desired'), |
---|
| 76 | 'form.hq_type': _(u'Higher Education Record'), |
---|
| 77 | 'form.presently': _(u'Course or Programme Presently Attending'), |
---|
| 78 | 'form.nysc_year': _(u'NYSC Information'), |
---|
| 79 | 'form.employer': _(u'Employment History'), |
---|
| 80 | 'form.jamb_subjects': _(u'JAMB Data'), |
---|
| 81 | 'form.jamb_subjects_list': _(u'JAMB Data'), |
---|
| 82 | 'form.notice': _(u'Application Process Information'), |
---|
| 83 | 'form.pp_school': _(u'Post Primary School Qualification'), |
---|
| 84 | 'form.presently_inst': _(u'Presently attending a course or programme'), |
---|
| 85 | 'form.fst_sit_fname': _(u'Ordinary Level First Sitting Record'), |
---|
| 86 | 'form.scd_sit_fname': _(u'Ordinary Level Second Sitting Record'), |
---|
| 87 | 'form.referees': _(u'Referees'), |
---|
| 88 | } |
---|
[9635] | 89 | |
---|
[14867] | 90 | |
---|
[8647] | 91 | # Temporarily disabled |
---|
| 92 | def xxx_getApplicantsStatistics(self, container): |
---|
| 93 | state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0, |
---|
| 94 | ADMITTED:0, NOT_ADMITTED:0, CREATED:0} |
---|
| 95 | faculty_keys = grok.getSite()['faculties'].keys() |
---|
| 96 | fac_stats = dict([(i,0) for i in faculty_keys]) |
---|
| 97 | for key in container.keys(): |
---|
| 98 | state = container[key].state |
---|
| 99 | state_stats[state] += 1 |
---|
| 100 | cert = getattr(container[key],'course1',None) |
---|
| 101 | if cert is not None and state == SUBMITTED: |
---|
| 102 | faculty = cert.__parent__.__parent__.__parent__ |
---|
| 103 | fac_stats[faculty.__name__] += 1 |
---|
| 104 | return state_stats, fac_stats |
---|
[13815] | 105 | |
---|
| 106 | |
---|
| 107 | def setPaymentDetails(self, container, payment, applicant): |
---|
| 108 | """Set the payment data of an applicant. |
---|
| 109 | In contrast to its `StudentsUtils` counterpart, the payment ticket |
---|
| 110 | must exist and is an argument of this method. |
---|
| 111 | """ |
---|
| 112 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
[16245] | 113 | if container.year: |
---|
| 114 | session = str(container.year) |
---|
| 115 | try: |
---|
| 116 | session_config = grok.getSite()['configuration'][session] |
---|
| 117 | except KeyError: |
---|
| 118 | return _(u'Session configuration object is not available.') |
---|
[13815] | 119 | payment.p_id = "p%s" % timestamp |
---|
| 120 | payment.p_item = container.title |
---|
[16245] | 121 | if container.year: |
---|
| 122 | payment.p_session = container.year |
---|
| 123 | else: |
---|
| 124 | payment.p_session = datetime.now().year |
---|
[13815] | 125 | payment.amount_auth = 0.0 |
---|
| 126 | if applicant.special: |
---|
| 127 | if applicant.special_application: |
---|
| 128 | fee_name = applicant.special_application + '_fee' |
---|
| 129 | payment.amount_auth = getattr(session_config, fee_name, None) |
---|
| 130 | payment.p_category = applicant.special_application |
---|
| 131 | return |
---|
[13816] | 132 | elif applicant.__parent__.prefix == 'ictwk': |
---|
| 133 | payment.p_category = 'registration' |
---|
| 134 | for cat in applicant.registration_cats: |
---|
| 135 | payment.amount_auth += REGISTRATION_CATS[cat][1] |
---|
[16144] | 136 | return |
---|
[16173] | 137 | elif applicant.container_code.startswith('tsc'): |
---|
[16216] | 138 | if not applicant.charge: |
---|
| 139 | return _(u'No transcript charge selected.') |
---|
[16131] | 140 | cost = DESTINATION_COST[applicant.charge][1] |
---|
| 141 | payment.amount_auth = applicant.no_copies * cost |
---|
[16226] | 142 | payment.p_category = 'transcript' |
---|
[16144] | 143 | return |
---|
[13816] | 144 | else: |
---|
| 145 | payment.p_category = 'application' |
---|
| 146 | container_fee = container.application_fee |
---|
[13887] | 147 | if not container_fee: |
---|
| 148 | return _('Amount could not be determined.') |
---|
| 149 | payment.amount_auth = container_fee |
---|
[13815] | 150 | return |
---|
[16199] | 151 | |
---|
| 152 | def isPictureEditable(self, container): |
---|
| 153 | """False if applicants are not allowed to edit uploaded pictures. |
---|
| 154 | """ |
---|
| 155 | if container.code.startswith('ase'): |
---|
| 156 | return False |
---|
[16314] | 157 | if container.code.startswith('pude'): |
---|
| 158 | return False |
---|
[16199] | 159 | return container.with_picture |
---|