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

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

Use transcript payment category for transcript application payments.

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