1 | ## $Id: utils.py 13815 2016-04-08 04:31:35Z 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 | |
---|
21 | from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils |
---|
22 | from waeup.kofa.applicants.workflow import (INITIALIZED, |
---|
23 | STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED) |
---|
24 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | class CustomApplicantsUtils(NigeriaApplicantsUtils): |
---|
29 | """A collection of parameters and methods subject to customization. |
---|
30 | """ |
---|
31 | |
---|
32 | APP_TYPES_DICT = { |
---|
33 | 'pude': ['Post-UDE Screening', 'PUDE'], |
---|
34 | 'sandwich': ['Part-Time Degree in Education', 'SAND'], |
---|
35 | 'pt': ['Part-Time Degree Programmes', 'PTP'], |
---|
36 | 'ptext': ['Part-Time Degree Programmes (extended application)', 'PTP'], |
---|
37 | 'putme': ['Post-UTME Screening Exercise', 'PUTME'], |
---|
38 | 'app': ['General Studies', 'APP'], |
---|
39 | 'cest': ['Common Entry Screening Test', 'CEST'], |
---|
40 | 'ct': ['Certificate Programmes', 'CTP'], |
---|
41 | 'dp': ['Diploma Programmes', 'DPP'], |
---|
42 | 'dpft': ['Diploma Full-Time Programmes', 'DPP'], |
---|
43 | 'pg': ['Postgraduate Programmes (main advert)', 'PG'], |
---|
44 | 'pga': ['Postgraduate Programmes (1st supplementary advert)', 'PG'], |
---|
45 | 'pgb': ['Postgraduate Programmes (2nd supplementary advert)', 'PG'], |
---|
46 | 'pgc': ['Postgraduate Programmes (3rd supplementary advert)', 'PG'], |
---|
47 | 'pgd': ['Postgraduate Programmes (4th supplementary advert)', 'PG'], |
---|
48 | 'pgn': ['NILS Postgraduate Programmes', 'PG'], |
---|
49 | 'pre': ['Pre-Degree Studies', 'PRE'], |
---|
50 | 'cbt': ['UNIBEN CBT Practice Test', 'CBT'], |
---|
51 | 'afas': ['Asaba Programmes', 'ASA'], |
---|
52 | 'afak': ['Akoka Programmes', 'AKO'], |
---|
53 | 'ictwk': ['ICT Week Registration', 'ICT'], |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | # Temporarily disabled |
---|
58 | def xxx_getApplicantsStatistics(self, container): |
---|
59 | state_stats = {INITIALIZED:0, STARTED:0, PAID:0, SUBMITTED:0, |
---|
60 | ADMITTED:0, NOT_ADMITTED:0, CREATED:0} |
---|
61 | faculty_keys = grok.getSite()['faculties'].keys() |
---|
62 | fac_stats = dict([(i,0) for i in faculty_keys]) |
---|
63 | for key in container.keys(): |
---|
64 | state = container[key].state |
---|
65 | state_stats[state] += 1 |
---|
66 | cert = getattr(container[key],'course1',None) |
---|
67 | if cert is not None and state == SUBMITTED: |
---|
68 | faculty = cert.__parent__.__parent__.__parent__ |
---|
69 | fac_stats[faculty.__name__] += 1 |
---|
70 | return state_stats, fac_stats |
---|
71 | |
---|
72 | |
---|
73 | def setPaymentDetails(self, container, payment, applicant): |
---|
74 | """Set the payment data of an applicant. |
---|
75 | In contrast to its `StudentsUtils` counterpart, the payment ticket |
---|
76 | must exist and is an argument of this method. |
---|
77 | """ |
---|
78 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
79 | session = str(container.year) |
---|
80 | try: |
---|
81 | session_config = grok.getSite()['configuration'][session] |
---|
82 | except KeyError: |
---|
83 | return _(u'Session configuration object is not available.') |
---|
84 | payment.p_id = "p%s" % timestamp |
---|
85 | payment.p_item = container.title |
---|
86 | payment.p_session = container.year |
---|
87 | payment.amount_auth = 0.0 |
---|
88 | if applicant.special: |
---|
89 | if applicant.special_application: |
---|
90 | fee_name = applicant.special_application + '_fee' |
---|
91 | payment.amount_auth = getattr(session_config, fee_name, None) |
---|
92 | if payment.amount_auth in (0.0, None): |
---|
93 | return _('Amount could not be determined.') |
---|
94 | payment.p_category = applicant.special_application |
---|
95 | return |
---|
96 | payment.p_category = 'application' |
---|
97 | container_fee = container.application_fee |
---|
98 | if container_fee: |
---|
99 | payment.amount_auth = container_fee |
---|
100 | return |
---|
101 | payment.amount_auth = session_config.application_fee |
---|
102 | if payment.amount_auth in (0.0, None): |
---|
103 | return _('Amount could not be determined.') |
---|
104 | return |
---|
105 | |
---|