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

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

new application category and type.

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