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

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

Adjust to changes in base package.

  • Property svn:keywords set to Id
File size: 6.4 KB
RevLine 
[10765]1## $Id: utils.py 16546 2021-07-13 16:05:29Z 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
[16142]21import grok
22from time import time
[16244]23from datetime import datetime
[10765]24from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils
25from waeup.kofa.applicants.workflow import (INITIALIZED,
26    STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED)
[16142]27from kofacustom.iuokada.applicants.interfaces import DESTINATION_COST
[15563]28from kofacustom.iuokada.interfaces import MessageFactory as _
[10765]29
30
31
32class ApplicantsUtils(NigeriaApplicantsUtils):
33    """A collection of parameters and methods subject to customization.
34    """
[15738]35
[16014]36    ADDITIONAL_FILES = (
[16546]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'),
[16014]45                 )
[15942]46
[15762]47    APP_TYPES_DICT = {
[15758]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'],
[15738]52        'app': ['General Studies', 'APP'],
[15758]53        'ct': ['Certificate Programmes', 'CTP'],
54        'dp': ['Diploma Programmes', 'DPP'],
55        'pgft': ['Postgraduate Full-Time Programmes', 'PG'],
56        'pgpt': ['Postgraduate Part-Time Programmes', 'PG'],
[16497]57        'pgphd': ['Postgraduate PhD/MPhil Programmes', 'PG'],
[15758]58        'pre': ['Pre-Degree Studies', 'PRE'],
59        'cbt': ['CBT Practice Test', 'CBT'],
60        'ase': ['Admission Screening Exercise', 'ASE'], # successor of putme
[15738]61        'pg': ['Postgraduate Programmes', 'PG'],
[15858]62        'ug': ['Undergraduate Programmes', 'UG'],
[16165]63        'tscf': ['Transcript Application (without student record)', 'TRF'],
64        'tscs': ['Transcript Application (with student record)', 'TRS'],
[15858]65        }
66
67    SEPARATORS_DICT = {
68        'form.applicant_id': _(u'Base Data'),
69        'form.course1': _(u'Programmes/Courses Desired'),
[16050]70        'form.hq_type': _(u'Highest Educational Record (Degrees, Diplomas etc.)'),
[15858]71        'form.presently': _(u'Course or Programme Presently Attending'),
[16049]72        'form.nysc_year': _(u'NYSC Information/Exemption Certificate'),
[15858]73        'form.employer': _(u'Employment History'),
[16533]74        'form.jamb_fname': _(u'JAMB Data (All Applicants)'),
[15858]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'),
[16311]78        'form.fst_sit_fname': _(u'First Sitting Record (WAEC/NECO)'),
79        'form.scd_sit_fname': _(u'Second Sitting Record (WAEC/NECO)'),
[16049]80        'form.referees': _(u'Referees (will be automatically invited by email after final submission)'),
[15863]81        'form.parents_name': _(u'Parents / Guardian'),
[15860]82        }
83
[16054]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
[15860]96    def getCertTitle(self, context, value):
97        """Compose the titles in `AppCatCertificateSource`.
98        """
[16054]99        try: title = "%s / %s / %s (%s)" % (
[16070]100            value.__parent__.__parent__.__parent__.title,
101            value.__parent__.__parent__.title,
[16054]102            value.title, value.code)
103        except AttributeError:
104            title = "NA / %s (%s)" % (value.title, value.code)
105        return title
[16142]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:]
[16244]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.')
[16142]119        payment.p_id = "p%s" % timestamp
120        payment.p_item = container.title
[16244]121        if container.year:
122            payment.p_session = container.year
123        else:
124            payment.p_session = datetime.now().year
[16142]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
[16166]134        elif applicant.container_code.startswith('tsc'):
[16142]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.