source: main/kofacustom.edocons/trunk/src/kofacustom/edocons/applicants/utils.py @ 17683

Last change on this file since 17683 was 17460, checked in by Henrik Bettermann, 17 months ago

Customize application form.

  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1## $Id: utils.py 17460 2023-06-30 07:55: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"""
20from time import time
21from datetime import datetime
22from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils
23from waeup.kofa.applicants.workflow import (INITIALIZED,
24    STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED)
25from kofacustom.edocons.applicants.interfaces import DESTINATION_COST
26from kofacustom.edocons.interfaces import MessageFactory as _
27
28
29
30class ApplicantsUtils(NigeriaApplicantsUtils):
31    """A collection of parameters and methods subject to customization.
32    """
33
34    ADDITIONAL_FILES = (
35                 ('Statement of Result','res_stat'),
36                 ('Testimonial','testimonial'),
37                 ('Notification of Result / RN Certificate (compulsory)','not_res'),
38                 ('Document Upload Form to be filled by School (optional)','docupload'),
39                 ('Document 1','doc_1'),
40                 ('Document 2','doc_2'),
41                 )
42
43    SEPARATORS_DICT = {
44        'form.applicant_id': _(u'Base Data'),
45        'form.course1': _(u'Programmes/Courses Desired'),
46        'form.hq_type': _(u'Higher Education Record'),
47        'form.presently': _(u'Course or Programme Presently Attending'),
48        'form.nysc_year': _(u'NYSC Information'),
49        'form.employer': _(u'Employment History'),
50        #'form.jamb_subjects': _(u'JAMB Data'),
51        #'form.jamb_subjects_list': _(u'JAMB Data'),
52        'form.jamb_reg_number': _(u'JAMB Data'),
53        'form.notice': _(u'Application Process Information'),
54        'form.pp_school': _(u'Post Primary School Qualification'),
55        'form.presently_inst': _(u'Presently attending a course or programme'),
56        'form.fst_sit_fname': _(u'First Sitting Record'),
57        'form.scd_sit_fname': _(u'Second Sitting Record'),
58        'form.referees': _(u'Referees'),
59        'form.cbt_score': _(u'CBT Data'),
60        }
61
62    APP_TYPES_DICT = {
63        'ase': ['Admission Screening Exercise', 'ASE'],
64        'ct': ['Certificate Programmes', 'CTP'],
65        'app': ['General Studies', 'APP'],
66        'tsc': ['Transcript', 'TRF'],
67        }
68
69    def setPaymentDetails(self, container, payment, applicant):
70        """Set the payment data of an applicant.
71        In contrast to its `StudentsUtils` counterpart, the payment ticket
72        must exist and is an argument of this method.
73        """
74        timestamp = ("%d" % int(time()*10000))[1:]
75        payment.p_id = "p%s" % timestamp
76        payment.p_item = container.title
77        if container.year:
78            payment.p_session = container.year
79        else:
80            payment.p_session = datetime.now().year
81        payment.amount_auth = 0.0
82        if applicant.special:
83            if applicant.special_application:
84                try:
85                    session_config = grok.getSite()['configuration'][
86                        str(payment.p_session)]
87                except KeyError:
88                    return _(u'Session configuration object is not available.')   
89                fee_name = applicant.special_application + '_fee'
90                payment.amount_auth = getattr(session_config, fee_name, None)
91                payment.p_category = applicant.special_application
92            if payment.amount_auth in (0.0, None):
93                return _('Amount could not be determined. Have you saved the form?')
94            return
95        elif applicant.container_code.startswith('tsc'):
96            if not applicant.charge:
97                return _(u'No transcript charge selected.')
98            cost = DESTINATION_COST[applicant.charge][1]
99            payment.amount_auth = applicant.no_copies * cost
100            if applicant.curriculum:
101                payment.amount_auth += applicant.no_copies * 5000
102            payment.p_category = 'transcript'
103            return
104        payment.p_category = 'application'
105        container_fee = container.application_fee
106        if not container_fee:
107            return _('Amount could not be determined.')
108        payment.amount_auth = container_fee
109        return       
Note: See TracBrowser for help on using the repository browser.