source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py @ 16161

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

Configure DESTINATION_COST.

  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1## $Id: utils.py 16144 2020-07-05 21:01:00Z 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 kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils
24from waeup.kofa.applicants.workflow import (INITIALIZED,
25    STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED)
26from waeup.uniben.applicants.interfaces import REGISTRATION_CATS, DESTINATION_COST
27from waeup.uniben.interfaces import MessageFactory as _
28
29class CustomApplicantsUtils(NigeriaApplicantsUtils):
30    """A collection of parameters and methods subject to customization.
31    """
32
33    APP_TYPES_DICT = {
34        'pude': ['Post-UDE Screening', 'PUDE'],
35        'sandwich': ['Part-Time Degree in Education', 'SAND'],
36        'pt': ['Part-Time Degree Programmes', 'PTP'],
37        'ptext': ['Part-Time Degree Programmes (extended application)', 'PTP'],
38        'putme': ['Post-UTME Screening Exercise', 'PUTME'],
39        'app': ['General Studies', 'APP'],
40        'cest': ['Common Entry Screening Test', 'CEST'],
41        'ct': ['Certificate Programmes', 'CTP'],
42        'dp': ['Diploma Programmes', 'DPP'],
43        'dpft': ['Diploma Full-Time Programmes', 'DPP'],
44        'pg': ['Postgraduate Programmes (main advert)', 'PG'],
45        'pga': ['Postgraduate Programmes (1st supplementary advert)', 'PG'],
46        'pgb': ['Postgraduate Programmes (2nd supplementary advert)', 'PG'],
47        'pgc': ['Postgraduate Programmes (3rd supplementary advert)', 'PG'],
48        'pgd': ['Postgraduate Programmes (4th supplementary advert)', 'PG'],
49        'pgn': ['NILS Postgraduate Programmes', 'PG'],
50        'pre': ['JUPEB Pre-Degree (Foundation) Studies', 'PRE'],
51        'cbt': ['UNIBEN CBT Practice Test', 'CBT'],
52        'ab': ['Asaba Programmes', 'ASA'],
53        'ak': ['Akoka Programmes', 'AKO'],
54        'akj': ['Akoka JUPEB', 'AKO'],
55        'ictwk': ['ICT Week Registration', 'ICT'],
56        'ase': ['Uniben Admission Screening Exercise', 'ASE'],
57        'asea': ['Uniben Admission Screening Exercise '
58                 '(1st supplementary advert)', 'ASE'],
59        'aseb': ['Uniben Admission Screening Exercise '
60                 '(2nd supplementary advert)', 'ASE'],
61        'spft': ['Special Full-Time Programmes', 'SP'],
62        'transfull': ['Transcript Application (without student record)', 'TRF'],
63        'transshort': ['Transcript Application (with student record)', 'TRS'],
64        }
65
66    SEPARATORS_DICT = {
67        'form.applicant_id': _(u'Base Data'),
68        'form.course1': _(u'Programmes/Courses Desired'),
69        'form.hq_type': _(u'Higher Education Record'),
70        'form.presently': _(u'Course or Programme Presently Attending'),
71        'form.nysc_year': _(u'NYSC Information'),
72        'form.employer': _(u'Employment History'),
73        'form.jamb_subjects': _(u'JAMB Data'),
74        'form.jamb_subjects_list': _(u'JAMB Data'),
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'),
78        'form.fst_sit_fname': _(u'Ordinary Level First Sitting Record'),
79        'form.scd_sit_fname': _(u'Ordinary Level Second Sitting Record'),
80        'form.referees': _(u'Referees'),
81        }
82
83
84    # Temporarily disabled
85    def xxx_getApplicantsStatistics(self, container):
86        state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0,
87            ADMITTED:0, NOT_ADMITTED:0, CREATED:0}
88        faculty_keys = grok.getSite()['faculties'].keys()
89        fac_stats = dict([(i,0) for i in faculty_keys])
90        for key in container.keys():
91            state = container[key].state
92            state_stats[state] += 1
93            cert = getattr(container[key],'course1',None)
94            if  cert is not None and state == SUBMITTED:
95                faculty = cert.__parent__.__parent__.__parent__
96                fac_stats[faculty.__name__] += 1
97        return state_stats, fac_stats
98
99
100    def setPaymentDetails(self, container, payment, applicant):
101        """Set the payment data of an applicant.
102        In contrast to its `StudentsUtils` counterpart, the payment ticket
103        must exist and is an argument of this method.
104        """
105        timestamp = ("%d" % int(time()*10000))[1:]
106        session = str(container.year)
107        try:
108            session_config = grok.getSite()['configuration'][session]
109        except KeyError:
110            return _(u'Session configuration object is not available.')
111        payment.p_id = "p%s" % timestamp
112        payment.p_item = container.title
113        payment.p_session = container.year
114        payment.amount_auth = 0.0
115        if applicant.special:
116            if applicant.special_application:
117                fee_name = applicant.special_application + '_fee'
118                payment.amount_auth = getattr(session_config, fee_name, None)
119                payment.p_category = applicant.special_application
120            return
121        elif applicant.__parent__.prefix == 'ictwk':
122            payment.p_category = 'registration'
123            for cat in applicant.registration_cats:
124                payment.amount_auth += REGISTRATION_CATS[cat][1]
125            return
126        elif applicant.container_code.startswith('trans'):
127            cost = DESTINATION_COST[applicant.charge][1]
128            payment.amount_auth = applicant.no_copies * cost
129            payment.p_category = 'transcript'
130            return
131        else:
132            payment.p_category = 'application'
133            container_fee = container.application_fee
134            if not container_fee:
135                return _('Amount could not be determined.')
136            payment.amount_auth = container_fee
137        return
Note: See TracBrowser for help on using the repository browser.