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

Last change on this file since 8188 was 8188, checked in by Henrik Bettermann, 13 years ago

Add missing import.

  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1## $Id: utils.py 8188 2012-04-17 07:28:24Z henrik $
2##
3## Copyright (C) 2012 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"""Customize general helper utilities for Kofa.
19"""
20import os
21import pytz
22from waeup.kofa.utils.utils import KofaUtils, sorted_phone_prefixes
23from waeup.kofa.accesscodes import create_accesscode
24from waeup.uniben.interfaces import MessageFactory as _
25
26def actions_after_payment(student, payment, view):
27    if payment.p_category == 'clearance':
28        # Create CLR access code
29        pin, error = create_accesscode('CLR',0,student.student_id)
30        if error:
31            view.flash(_('Valid callback received. ${a}',
32                mapping = {'a':error}))
33            return
34        payment.ac = pin
35    elif payment.p_category == 'schoolfee':
36        # Create SFE access code
37        pin, error = create_accesscode('SFE',0,student.student_id)
38        if error:
39            view.flash(_('Valid callback received. ${a}',
40                mapping = {'a':error}))
41            return
42        payment.ac = pin
43    elif payment.p_category == 'bed_allocation':
44        # Create HOS access code
45        pin, error = create_accesscode('HOS',0,student.student_id)
46        if error:
47            view.flash(_('Valid callback received. ${a}',
48                mapping = {'a':error}))
49            return
50        payment.ac = pin
51    view.flash(_('Valid callback received.'))
52    return
53
54INT_PHONE_PREFIXES = [
55    (1, _('Nigeria'), '234'),
56    (99, _('Germany'), '49'),
57    (99, _('United States'), '1'),
58    (99, _('Niger'), '227'),
59    (99, _('Benin'), '229'),
60    (99, _('Cameroon'), '237'),
61    (99, _('United Kingdom'), '44'),
62    (99, _('France'), '33'),
63    ]
64
65class KofaUtils(KofaUtils):
66    """A collection of methods subject to customization.
67    """
68    PORTAL_LANGUAGE = 'en'
69
70    # We do not dosplay the language selector at the moment.
71    PREFERRED_LANGUAGES_DICT = {
72        }
73
74    #: A function to return
75    @classmethod
76    def sorted_phone_prefixes(cls, data=INT_PHONE_PREFIXES, request=None):
77        return sorted_phone_prefixes(data, request)
78
79    EXAM_SUBJECTS_DICT = {
80        'accounts': 'Accounts',
81        'add_general_science': 'Add General Science',
82        'add_maths': 'Add Maths',
83        'agricultural_science': 'Agricultural Science',
84        'applied_electricity': 'Applied Electricity',
85        'arabi': 'Arabic',
86        'arithmetics': 'Arithmetics',
87        'art': 'Art',
88        'auto_mechanics': 'Auto Mechanics',
89        'basic_electricity': 'Basic Electricity',
90        'bible_knowledge': 'Bible Knowledge',
91        'biology': 'Biology',
92        'biology_alt_syl': 'Biology (Alt.Syl)',
93        'book_keeping': 'Book Keeping',
94        'building_construction': 'Building Construction',
95        'business_management': 'Business Management',
96        'business_construction_management': 'Business/Construction Management (Adv)',
97        'chemistry': 'Chemistry',
98        'chemistry_alt_syl': 'Chemistry (Alt.Syl)',
99        'christian_religious_studies': 'Christian Religious Studies',
100        'clerical_office_duties': 'Clerical Office Duties',
101        'clothing_and_textiles': 'Clothing and Textiles',
102        'commerce': 'Commerce',
103        'economics': 'Economics',
104        'education': 'Education',
105        'efik': 'Efik',
106        'electronics': 'Electronics',
107        'elementary_surveying': 'Elementary Surveying',
108        'english_language': 'English Language',
109        'engineering_science': 'Engineering Science',
110        'financial_accounting': 'Financial Accounting',
111        'food_and_nutrition': 'Food and Nutrition',
112        'french': 'French',
113        'further_mathematics': 'Further Mathematics',
114        'general_science': 'General Science',
115        'geography': 'Geography',
116        'german': 'German',
117        'government': 'Government',
118        'hausa': 'Hausa',
119        'hausa_literature': 'Hausa Literature',
120        'health_science': 'Health Science',
121        'history': 'History',
122        'home_management': 'Home Management',
123        'industrial_electrical_installation': 'Industrial Elect Installation (Adv)',
124        'intergrated_science': 'Intergrated Science',
125        'islamic_studies': 'Islamic Studies',
126        'literature_in_english': 'Literature in English',
127        'literature_in_nigerian_languages': 'Literature in Nigerian Languages',
128        'igbo': 'Igbo',
129        'igbo_literature': 'Igbo Literature',
130        'yoruba': 'Yoruba',
131        'yoruba_literature': 'Yoruba Literature',
132        'management_in_living': 'Management in Living',
133        'mathematics': 'Mathematics',
134        'metalwork': 'Metalwork',
135        'music': 'Music',
136        'nigerian_language': 'Nigerian Language',
137        'office_practice': 'Office Practice',
138        'physical_education': 'Physical Education',
139        'physical_health_education': 'Physical and Health Education',
140        'physics': 'Physics',
141        'physics_alt_syl': 'Physics (Alt.Syl)',
142        'principles_of_cost_accounting': 'Principles of Cost Accounting',
143        'rural_science': 'Rural Science',
144        'science': 'Science',
145        'secretarial_duties': 'Secretarial Duties',
146        'shorthand': 'Shorthand',
147        'sierra_leone_studies': 'Sierra Leone Studies',
148        'sierra_leone_languages': 'Sierra Leone Languages',
149        'social_studies': 'Social Studies',
150        'statistics': 'Statistics',
151        'teaching_practice': 'Teaching Practice',
152        'technical_drawing': 'Technical Drawing',
153        'typewriting': 'Typewriting',
154        'visual_art': 'Visual Art',
155        'woodwork': 'Woodwork',
156        'winding_elect_machines': 'Winding of Elect Machines and Elect Eng Sc'
157        }
158
159    EXAM_GRADES = (
160        ('A1', 'Excellent (A1)'),
161        ('A2', 'Very Good (A2)'),
162        ('A3', 'Good (A3)'),
163        ('B2', 'Very Good (B2)'),
164        ('B3', 'Good (B3)'),
165        ('C4', 'Credit (C4)'),
166        ('C5', 'Credit (C5)'),
167        ('C6', 'Credit (C6)'),
168        ('A', 'Pass (A)'),
169        ('B', 'Pass (B)'),
170        ('C', 'Pass (C)'),
171        ('U', 'Pass (U)'),
172        ('D7', 'Pass (D7)'),
173        ('P7', 'Pass (P7)'),
174        ('P8', 'Pass (P8)'),
175        ('E8', 'Pass (E8)'),
176        ('F9', 'Fail (F9)'),
177        ('Aa', 'A (a)'),
178        ('Bb', 'B (b)'),
179        ('Cc', 'C (c)'),
180        ('Dd', 'D (d)'),
181        ('Ee', 'E (e)'),
182        ('Ff', 'F (f)'),
183        ('Gg', 'G (g)')
184        )
185
186    INST_TYPES_DICT = {
187        'none': '',
188        'faculty': 'Faculty of',
189        'department': 'Department of',
190        'school': 'School of',
191        'office': 'Office for',
192        'centre': 'Centre for',
193        'institute': 'Institute of',
194        'school_for': 'School for',
195        'college': 'College of',
196        }
197
198    STUDY_MODES_DICT = {
199        'rmd_ft': 'Remedial with deficiencies',
200        'dp_pt': 'Diploma Part Time',
201        'ct_ft': 'Certificate Full Time',
202        'dp_ft': 'Diploma Full Time',
203        'de_pt': 'Direct Entry Part Time',
204        'pg_ft': 'Postgraduate Full Time',
205        'pg_pt': 'Postgraduate Part Time',
206        'jm_ft': 'Joint Matriculation Full Time',
207        'ume_ft': 'UME Full Time',
208        'de_ft': 'Direct Entry Full Time',
209        'ph_ft': 'Post Higher Education Full Time',
210        'transfer_pt': 'Transfer Part Time',
211        'ug_pt': 'Undergraduate Part Time',
212        'transfer_ft': 'Transfer Full Time',
213        'ct_pt': 'Certificate Part Time',
214        'ug_ft': 'Undergraduate Full Time',
215        'rm_ft': 'Remedial'
216        }
217
218    APP_CATS_DICT = {
219        'basic': 'PUME, PDE, PCE, PRENCE',
220        'no': 'no application',
221        'pg_ft': 'Postgraduate Full-Time',
222        'pg_pt': 'Postgraduate Part-Time',
223        'sandwich': 'Sandwich',
224        'cest': 'Part-Time, Diploma, Certificate'
225        }
226
227    @property
228    def tzinfo(self):
229        return pytz.timezone('Africa/Lagos')
Note: See TracBrowser for help on using the repository browser.