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

Last change on this file since 17651 was 17651, checked in by Henrik Bettermann, 12 months ago

First additions for the CDL.

Start customizing STUDY_MODES_DICT.

  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1## $Id: utils.py 17651 2023-11-29 11:21:39Z 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        'cdl': ['Center For Distance Learning', 'CDL'],
67        }
68
69    SEPARATORS_DICT = {
70        'form.applicant_id': _(u'Base Data'),
71        'form.course1': _(u'Programmes/Courses Desired'),
72        'form.hq_type': _(u'Highest Educational Record (Degrees, Diplomas etc.)'),
73        'form.presently': _(u'Course or Programme Presently Attending'),
74        'form.nysc_year': _(u'NYSC Information/Exemption Certificate'),
75        'form.employer': _(u'Employment History'),
76        'form.jamb_fname': _(u'JAMB Data (All Applicants)'),
77        'form.notice': _(u'Application Process Information'),
78        'form.pp_school': _(u'Post Primary School Qualification'),
79        'form.presently_inst': _(u'Presently attending a course or programme'),
80        'form.fst_sit_fname': _(u'First Sitting Record (WAEC/NECO)'),
81        'form.scd_sit_fname': _(u'Second Sitting Record (WAEC/NECO)'),
82        'form.referees': _(u'Referees (will be automatically invited by email after final submission)'),
83        'form.parents_name': _(u'Parents / Guardian'),
84        }
85
86    def sortCertificates(self, context, resultset):
87        """Sort already filtered certificates in `AppCatCertificateSource`.
88        """
89        resultlist = sorted(resultset, key=lambda
90            value: value.__parent__.__parent__.__parent__.code +
91            value.__parent__.__parent__.code +
92            value.code)
93        curr_course = context.course1
94        if curr_course is not None and curr_course not in resultlist:
95            resultlist = [curr_course,] + resultlist
96        return resultlist
97
98    def getCertTitle(self, context, value):
99        """Compose the titles in `AppCatCertificateSource`.
100        """
101        try: title = "%s / %s / %s (%s)" % (
102            value.__parent__.__parent__.__parent__.title,
103            value.__parent__.__parent__.title,
104            value.title, value.code)
105        except AttributeError:
106            title = "NA / %s (%s)" % (value.title, value.code)
107        return title
108
109    def setPaymentDetails(self, container, payment, applicant):
110        """Set the payment data of an applicant.
111        In contrast to its `StudentsUtils` counterpart, the payment ticket
112        must exist and is an argument of this method.
113        """
114        timestamp = ("%d" % int(time()*10000))[1:]
115        if container.year:
116            session = str(container.year)
117            try:
118                session_config = grok.getSite()['configuration'][session]
119            except KeyError:
120                return _(u'Session configuration object is not available.')
121        payment.p_id = "p%s" % timestamp
122        payment.p_item = container.title
123        if container.year:
124            payment.p_session = container.year
125        else:
126            payment.p_session = datetime.now().year
127        payment.amount_auth = 0.0
128        if applicant.special:
129            if applicant.special_application:
130                fee_name = applicant.special_application + '_fee'
131                payment.amount_auth = getattr(session_config, fee_name, None)
132                if payment.amount_auth in (0.0, None):
133                    return _('Amount could not be determined.')
134                payment.p_category = applicant.special_application
135            return
136        elif applicant.container_code.startswith('tsc'):
137            cost = DESTINATION_COST[applicant.charge][1]
138            payment.amount_auth = applicant.no_copies * cost
139            payment.p_category = 'transcript'
140            return
141        else:
142            payment.p_category = 'application'
143            container_fee = container.application_fee
144            if not container_fee:
145                return _('Amount could not be determined.')
146            payment.amount_auth = container_fee
147        return
Note: See TracBrowser for help on using the repository browser.