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

Last change on this file since 8083 was 8083, checked in by Henrik Bettermann, 12 years ago

Change phone prefix for Niger.

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