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

Last change on this file since 17414 was 17106, checked in by Henrik Bettermann, 2 years ago

Customize transcript application.

  • Property svn:keywords set to Id
File size: 4.7 KB
RevLine 
[16639]1## $Id: utils.py 17106 2022-09-23 13:18:58Z 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 = (
[17106]35                 ('Statement of Result','res_stat'),
[17043]36                 ('Testimonial','testimonial'),
[17106]37                 ('Notification of Result / RN Certificate (compulsory)','not_res'),
38                 ('Document Upload Form to be filled by School (optional)','docupload'),
[17095]39                 ('Document 1','doc_1'),
40                 ('Document 2','doc_2'),
[17041]41                 )
42
[16767]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.notice': _(u'Application Process Information'),
53        'form.pp_school': _(u'Post Primary School Qualification'),
54        'form.presently_inst': _(u'Presently attending a course or programme'),
55        'form.fst_sit_fname': _(u'First Sitting Record'),
56        'form.scd_sit_fname': _(u'Second Sitting Record'),
57        'form.referees': _(u'Referees'),
58        'form.cbt_score': _(u'CBT Data'),
[17029]59        }
60
61    APP_TYPES_DICT = {
[17030]62        'ase': ['Admission Screening Exercise', 'ASE'],
63        'ct': ['Certificate Programmes', 'CTP'],
[17029]64        'app': ['General Studies', 'APP'],
65        'tsc': ['Transcript', 'TRF'],
66        }
[17038]67
68    def setPaymentDetails(self, container, payment, applicant):
69        """Set the payment data of an applicant.
70        In contrast to its `StudentsUtils` counterpart, the payment ticket
71        must exist and is an argument of this method.
72        """
73        timestamp = ("%d" % int(time()*10000))[1:]
74        payment.p_id = "p%s" % timestamp
75        payment.p_item = container.title
76        if container.year:
77            payment.p_session = container.year
78        else:
79            payment.p_session = datetime.now().year
80        payment.amount_auth = 0.0
81        if applicant.special:
82            if applicant.special_application:
83                try:
84                    session_config = grok.getSite()['configuration'][
85                        str(payment.p_session)]
86                except KeyError:
87                    return _(u'Session configuration object is not available.')   
88                fee_name = applicant.special_application + '_fee'
89                payment.amount_auth = getattr(session_config, fee_name, None)
90                payment.p_category = applicant.special_application
91            if payment.amount_auth in (0.0, None):
92                return _('Amount could not be determined. Have you saved the form?')
93            return
[17039]94        elif applicant.container_code.startswith('tsc'):
95            if not applicant.charge:
96                return _(u'No transcript charge selected.')
97            cost = DESTINATION_COST[applicant.charge][1]
98            payment.amount_auth = applicant.no_copies * cost
99            if applicant.curriculum:
100                payment.amount_auth += applicant.no_copies * 5000
101            payment.p_category = 'transcript'
102            return
[17038]103        payment.p_category = 'application'
104        container_fee = container.application_fee
105        if not container_fee:
106            return _('Amount could not be determined.')
107        payment.amount_auth = container_fee
108        return       
Note: See TracBrowser for help on using the repository browser.