source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/utils.py @ 16311

Last change on this file since 16311 was 16311, checked in by Henrik Bettermann, 4 years ago

WAEC not WEAC

  • Property svn:keywords set to Id
File size: 6.4 KB
Line 
1## $Id: utils.py 16311 2020-11-13 10:36:44Z 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
21import grok
22from time import time
23from datetime import datetime
24from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils
25from waeup.kofa.applicants.workflow import (INITIALIZED,
26    STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED)
27from kofacustom.iuokada.applicants.interfaces import DESTINATION_COST
28from kofacustom.iuokada.interfaces import MessageFactory as _
29
30
31
32class ApplicantsUtils(NigeriaApplicantsUtils):
33    """A collection of parameters and methods subject to customization.
34    """
35
36    ADDITIONAL_FILES = (
37                 ('First Sitting Result (WAEC/NECO)','fst_sit_scan.pdf'),
38                 ('Second Sitting Result (WAEC/NECO)','scd_sit_scan.pdf'),
39                 ('Higher Qualification Result','hq_scan.pdf'),
40                 ('Advanced Level Result','alr_scan.pdf'),
41                 ('JAMB Result','jamb.pdf'),
42                 ('Statement of Result','res_stat.pdf'),
43                 ('NYSC Certificate','nysc.pdf'),
44                 )
45
46    APP_TYPES_DICT = {
47        'pude': ['Post-UDE Screening', 'PUDE'],
48        'sandwich': ['Part-Time Degree in Education', 'SAND'],
49        'pt': ['Part-Time Degree Programmes', 'PTP'],
50        'putme': ['Post-UTME Screening Exercise', 'PUTME'],
51        'app': ['General Studies', 'APP'],
52        'ct': ['Certificate Programmes', 'CTP'],
53        'dp': ['Diploma Programmes', 'DPP'],
54        'pgft': ['Postgraduate Full-Time Programmes', 'PG'],
55        'pgpt': ['Postgraduate Part-Time Programmes', 'PG'],
56        'pre': ['Pre-Degree Studies', 'PRE'],
57        'cbt': ['CBT Practice Test', 'CBT'],
58        'ase': ['Admission Screening Exercise', 'ASE'], # successor of putme
59        'pg': ['Postgraduate Programmes', 'PG'],
60        'ug': ['Undergraduate Programmes', 'UG'],
61        'tscf': ['Transcript Application (without student record)', 'TRF'],
62        'tscs': ['Transcript Application (with student record)', 'TRS'],
63        }
64
65    SEPARATORS_DICT = {
66        'form.applicant_id': _(u'Base Data'),
67        'form.course1': _(u'Programmes/Courses Desired'),
68        'form.hq_type': _(u'Highest Educational Record (Degrees, Diplomas etc.)'),
69        'form.presently': _(u'Course or Programme Presently Attending'),
70        'form.nysc_year': _(u'NYSC Information/Exemption Certificate'),
71        'form.employer': _(u'Employment History'),
72        'form.jamb_subjects': _(u'JAMB Data (All Applicants)'),
73        'form.jamb_subjects_list': _(u'JAMB Data (All Applicants)'),
74        'form.notice': _(u'Application Process Information'),
75        'form.pp_school': _(u'Post Primary School Qualification'),
76        'form.presently_inst': _(u'Presently attending a course or programme'),
77        'form.fst_sit_fname': _(u'First Sitting Record (WAEC/NECO)'),
78        'form.scd_sit_fname': _(u'Second Sitting Record (WAEC/NECO)'),
79        'form.referees': _(u'Referees (will be automatically invited by email after final submission)'),
80        'form.parents_name': _(u'Parents / Guardian'),
81        }
82
83    def sortCertificates(self, context, resultset):
84        """Sort already filtered certificates in `AppCatCertificateSource`.
85        """
86        resultlist = sorted(resultset, key=lambda
87            value: value.__parent__.__parent__.__parent__.code +
88            value.__parent__.__parent__.code +
89            value.code)
90        curr_course = context.course1
91        if curr_course is not None and curr_course not in resultlist:
92            resultlist = [curr_course,] + resultlist
93        return resultlist
94
95    def getCertTitle(self, context, value):
96        """Compose the titles in `AppCatCertificateSource`.
97        """
98        try: title = "%s / %s / %s (%s)" % (
99            value.__parent__.__parent__.__parent__.title,
100            value.__parent__.__parent__.title,
101            value.title, value.code)
102        except AttributeError:
103            title = "NA / %s (%s)" % (value.title, value.code)
104        return title
105
106    def setPaymentDetails(self, container, payment, applicant):
107        """Set the payment data of an applicant.
108        In contrast to its `StudentsUtils` counterpart, the payment ticket
109        must exist and is an argument of this method.
110        """
111        timestamp = ("%d" % int(time()*10000))[1:]
112        if container.year:
113            session = str(container.year)
114            try:
115                session_config = grok.getSite()['configuration'][session]
116            except KeyError:
117                return _(u'Session configuration object is not available.')
118        payment.p_id = "p%s" % timestamp
119        payment.p_item = container.title
120        if container.year:
121            payment.p_session = container.year
122        else:
123            payment.p_session = datetime.now().year
124        payment.amount_auth = 0.0
125        if applicant.special:
126            if applicant.special_application:
127                fee_name = applicant.special_application + '_fee'
128                payment.amount_auth = getattr(session_config, fee_name, None)
129                if payment.amount_auth in (0.0, None):
130                    return _('Amount could not be determined.')
131                payment.p_category = applicant.special_application
132            return
133        elif applicant.container_code.startswith('tsc'):
134            cost = DESTINATION_COST[applicant.charge][1]
135            payment.amount_auth = applicant.no_copies * cost
136            payment.p_category = 'transcript'
137            return
138        else:
139            payment.p_category = 'application'
140            container_fee = container.application_fee
141            if not container_fee:
142                return _('Amount could not be determined.')
143            payment.amount_auth = container_fee
144        return
Note: See TracBrowser for help on using the repository browser.