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

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

Add subject.

  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1## $Id: utils.py 8242 2012-04-21 11:10:39Z 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        'adv_elect_install_maint': 'Adv. Electrical Installation and Maintenance',
84        'agricultural_science': 'Agricultural Science',
85        'applied_electricity': 'Applied Electricity',
86        'arabi': 'Arabic',
87        'arithmetics': 'Arithmetics',
88        'art': 'Art',
89        'auto_mechanics': 'Auto Mechanics',
90        'basic_electricity': 'Basic Electricity',
91        'bible_knowledge': 'Bible Knowledge',
92        'biology': 'Biology',
93        'biology_alt_syl': 'Biology (Alt.Syl)',
94        'book_keeping': 'Book Keeping',
95        'building_construction': 'Building Construction',
96        'business_management': 'Business Management',
97        'business_construction_management': 'Business/Construction Management (Adv)',
98        'chemistry': 'Chemistry',
99        'chemistry_alt_syl': 'Chemistry (Alt.Syl)',
100        'christian_religious_studies': 'Christian Religious Studies',
101        'clerical_office_duties': 'Clerical Office Duties',
102        'clothing_and_textiles': 'Clothing and Textiles',
103        'commerce': 'Commerce',
104        'economics': 'Economics',
105        'education': 'Education',
106        'efik': 'Efik',
107        'electronics': 'Electronics',
108        'elementary_surveying': 'Elementary Surveying',
109        'english_language': 'English Language',
110        'engineering_science': 'Engineering Science',
111        'financial_accounting': 'Financial Accounting',
112        'food_and_nutrition': 'Food and Nutrition',
113        'french': 'French',
114        'further_mathematics': 'Further Mathematics',
115        'general_science': 'General Science',
116        'geography': 'Geography',
117        'german': 'German',
118        'government': 'Government',
119        'hausa': 'Hausa',
120        'hausa_literature': 'Hausa Literature',
121        'health_science': 'Health Science',
122        'history': 'History',
123        'home_management': 'Home Management',
124        'industrial_electrical_installation': 'Industrial Elect Installation (Adv)',
125        'intergrated_science': 'Intergrated Science',
126        'islamic_studies': 'Islamic Studies',
127        'literature_in_english': 'Literature in English',
128        'literature_in_nigerian_languages': 'Literature in Nigerian Languages',
129        'igbo': 'Igbo',
130        'igbo_literature': 'Igbo Literature',
131        'yoruba': 'Yoruba',
132        'yoruba_literature': 'Yoruba Literature',
133        'management_in_living': 'Management in Living',
134        'mathematics': 'Mathematics',
135        'metalwork': 'Metalwork',
136        'music': 'Music',
137        'nigerian_language': 'Nigerian Language',
138        'office_practice': 'Office Practice',
139        'physical_education': 'Physical Education',
140        'physical_health_education': 'Physical and Health Education',
141        'physics': 'Physics',
142        'physics_alt_syl': 'Physics (Alt.Syl)',
143        'principles_of_cost_accounting': 'Principles of Cost Accounting',
144        'rural_science': 'Rural Science',
145        'science': 'Science',
146        'secretarial_duties': 'Secretarial Duties',
147        'shorthand': 'Shorthand',
148        'sierra_leone_studies': 'Sierra Leone Studies',
149        'sierra_leone_languages': 'Sierra Leone Languages',
150        'social_studies': 'Social Studies',
151        'statistics': 'Statistics',
152        'teaching_practice': 'Teaching Practice',
153        'technical_drawing': 'Technical Drawing',
154        'typewriting': 'Typewriting',
155        'visual_art': 'Visual Art',
156        'woodwork': 'Woodwork',
157        'winding_elect_machines': 'Winding of Elect Machines and Elect Eng Sc'
158        }
159
160    EXAM_GRADES = (
161        ('A1', 'Excellent (A1)'),
162        ('A2', 'Very Good (A2)'),
163        ('A3', 'Good (A3)'),
164        ('B2', 'Very Good (B2)'),
165        ('B3', 'Good (B3)'),
166        ('C4', 'Credit (C4)'),
167        ('C5', 'Credit (C5)'),
168        ('C6', 'Credit (C6)'),
169        ('A', 'Pass (A)'),
170        ('B', 'Pass (B)'),
171        ('C', 'Pass (C)'),
172        ('U', 'Pass (U)'),
173        ('D7', 'Pass (D7)'),
174        ('P7', 'Pass (P7)'),
175        ('P8', 'Pass (P8)'),
176        ('E8', 'Pass (E8)'),
177        ('F9', 'Fail (F9)'),
178        ('Aa', 'A (a)'),
179        ('Bb', 'B (b)'),
180        ('Cc', 'C (c)'),
181        ('Dd', 'D (d)'),
182        ('Ee', 'E (e)'),
183        ('Ff', 'F (f)'),
184        ('Gg', 'G (g)')
185        )
186
187    INST_TYPES_DICT = {
188        'none': '',
189        'faculty': 'Faculty of',
190        'department': 'Department of',
191        'school': 'School of',
192        'office': 'Office for',
193        'centre': 'Centre for',
194        'institute': 'Institute of',
195        'school_for': 'School for',
196        'college': 'College of',
197        }
198
199    STUDY_MODES_DICT = {
200        'rmd_ft': 'Remedial with deficiencies',
201        'dp_pt': 'Diploma Part Time',
202        'ct_ft': 'Certificate Full Time',
203        'dp_ft': 'Diploma Full Time',
204        'de_pt': 'Direct Entry Part Time',
205        'pg_ft': 'Postgraduate Full Time',
206        'pg_pt': 'Postgraduate Part Time',
207        'jm_ft': 'Joint Matriculation Full Time',
208        'ume_ft': 'UME Full Time',
209        'de_ft': 'Direct Entry Full Time',
210        'ph_ft': 'Post Higher Education Full Time',
211        'transfer_pt': 'Transfer Part Time',
212        'ug_pt': 'Undergraduate Part Time',
213        'transfer_ft': 'Transfer Full Time',
214        'ct_pt': 'Certificate Part Time',
215        'ug_ft': 'Undergraduate Full Time',
216        'rm_ft': 'Remedial'
217        }
218
219    APP_CATS_DICT = {
220        'basic': 'PUME, PDE, PCE, PRENCE',
221        'no': 'no application',
222        'pg_ft': 'Postgraduate Full-Time',
223        'pg_pt': 'Postgraduate Part-Time',
224        'sandwich': 'Sandwich',
225        'cest': 'Part-Time, Diploma, Certificate'
226        }
227
228    @property
229    def tzinfo(self):
230        return pytz.timezone('Africa/Lagos')
Note: See TracBrowser for help on using the repository browser.