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

Last change on this file since 16497 was 16497, checked in by Henrik Bettermann, 3 years ago

Add application type and category.

  • Property svn:keywords set to Id
File size: 6.4 KB
Line 
1## $Id: utils.py 16497 2021-06-03 06:20:48Z 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        'pgphd': ['Postgraduate PhD/MPhil Programmes', 'PG'],
57        'pre': ['Pre-Degree Studies', 'PRE'],
58        'cbt': ['CBT Practice Test', 'CBT'],
59        'ase': ['Admission Screening Exercise', 'ASE'], # successor of putme
60        'pg': ['Postgraduate Programmes', 'PG'],
61        'ug': ['Undergraduate Programmes', 'UG'],
62        'tscf': ['Transcript Application (without student record)', 'TRF'],
63        'tscs': ['Transcript Application (with student record)', 'TRS'],
64        }
65
66    SEPARATORS_DICT = {
67        'form.applicant_id': _(u'Base Data'),
68        'form.course1': _(u'Programmes/Courses Desired'),
69        'form.hq_type': _(u'Highest Educational Record (Degrees, Diplomas etc.)'),
70        'form.presently': _(u'Course or Programme Presently Attending'),
71        'form.nysc_year': _(u'NYSC Information/Exemption Certificate'),
72        'form.employer': _(u'Employment History'),
73        'form.jamb_subjects': _(u'JAMB Data (All Applicants)'),
74        'form.jamb_subjects_list': _(u'JAMB Data (All Applicants)'),
75        'form.notice': _(u'Application Process Information'),
76        'form.pp_school': _(u'Post Primary School Qualification'),
77        'form.presently_inst': _(u'Presently attending a course or programme'),
78        'form.fst_sit_fname': _(u'First Sitting Record (WAEC/NECO)'),
79        'form.scd_sit_fname': _(u'Second Sitting Record (WAEC/NECO)'),
80        'form.referees': _(u'Referees (will be automatically invited by email after final submission)'),
81        'form.parents_name': _(u'Parents / Guardian'),
82        }
83
84    def sortCertificates(self, context, resultset):
85        """Sort already filtered certificates in `AppCatCertificateSource`.
86        """
87        resultlist = sorted(resultset, key=lambda
88            value: value.__parent__.__parent__.__parent__.code +
89            value.__parent__.__parent__.code +
90            value.code)
91        curr_course = context.course1
92        if curr_course is not None and curr_course not in resultlist:
93            resultlist = [curr_course,] + resultlist
94        return resultlist
95
96    def getCertTitle(self, context, value):
97        """Compose the titles in `AppCatCertificateSource`.
98        """
99        try: title = "%s / %s / %s (%s)" % (
100            value.__parent__.__parent__.__parent__.title,
101            value.__parent__.__parent__.title,
102            value.title, value.code)
103        except AttributeError:
104            title = "NA / %s (%s)" % (value.title, value.code)
105        return title
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:]
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.')
119        payment.p_id = "p%s" % timestamp
120        payment.p_item = container.title
121        if container.year:
122            payment.p_session = container.year
123        else:
124            payment.p_session = datetime.now().year
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                if payment.amount_auth in (0.0, None):
131                    return _('Amount could not be determined.')
132                payment.p_category = applicant.special_application
133            return
134        elif applicant.container_code.startswith('tsc'):
135            cost = DESTINATION_COST[applicant.charge][1]
136            payment.amount_auth = applicant.no_copies * cost
137            payment.p_category = 'transcript'
138            return
139        else:
140            payment.p_category = 'application'
141            container_fee = container.application_fee
142            if not container_fee:
143                return _('Amount could not be determined.')
144            payment.amount_auth = container_fee
145        return
Note: See TracBrowser for help on using the repository browser.