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

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

Testimonial and not eligibilty form.

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