source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interfaces.py @ 17586

Last change on this file since 17586 was 17586, checked in by Henrik Bettermann, 12 months ago

Allow two different JAMB reg number versions.

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1## $Id: interfaces.py 17586 2023-09-19 06:27: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
19import re
20import zope.i18nmessageid
21from zope import schema
22from zc.sourcefactory.basic import BasicSourceFactory
23from waeup.kofa.interfaces import (SimpleKofaVocabulary,
24    ISessionConfiguration, academic_sessions_vocab,
25    ContextualDictSourceFactoryBase)
26from kofacustom.nigeria.utils.lgas import LGAS
27
28_ = MessageFactory = zope.i18nmessageid.MessageFactory('kofacustom.nigeria')
29
30high_qual = SimpleKofaVocabulary(
31    ('National Certificate of Education','nce'),
32    ('Pre Degree Programme','pre'),
33    ('Diploma Programme','dip'),
34    ('National Diploma','ond'),
35    ('Bachelors Degree','bd'),
36    ('Masters Degree','md'),
37    ('Professional Qualification','pq'),
38    ('Other Certification','oc'),
39    ('Higher National Diploma','hnd'),
40    ('Post Graduate Diploma','pgd'),
41    ('NCE AL OTH','nce_al_oth'),
42    ('National Defence Academy','nda'),
43    ('RMC','rmc'),
44    ('Ph.D.(Doctor of Philosophy)','phd'),
45    ('M.Phil (Master of Philosophy)','mphil'),
46    ('JUPEB','jupeb'),
47    ('IJMBE','ijmbe'),
48    ('Registered Nursing','rn'),
49    ('Registered Midwifery','rm'),
50    ('Bachelor of Nursing Science','bnsc'),
51    (_('Awaiting Results'),'a_rslt'),
52    )
53
54high_grade = SimpleKofaVocabulary(
55    ('Upper Credit','upper_credit'),
56    ('Distinction','distinction'),
57    ('Credit','credit'),
58    ('Merit','merit'),
59    ('Lower Credit','lower_credit'),
60    ('First Class','first_class'),
61    ('Second Class Upper','second_class_upper'),
62    ('Second Class Lower','second_class_lower'),
63    ('Third Class','third_class'),
64    ('Pass','pass'),
65    ('A Levels','al'),
66    ('Unclassified Certificate', 'uc'),
67    (_('Awaiting Results'),'a_rslt'),
68    )
69
70exam_types = SimpleKofaVocabulary(
71    ('SSCE','ssce'),
72    ('WAEC','waec'),
73    ('GCE O\' LEVEL','gce_o_level'),
74    ('TC II','tc_ii'),
75    ('RSA','rsa'),
76    ('NABTEB','nabteb'),
77    ('NECO','neco'),
78    ('ACE','ace'),
79    ('GCE A\' LEVEL','gce_a_level'),
80    ('IGCSE','igcse'),
81    ('WAEC Technical Examination','wte'),
82    )
83
84# Define a validation method for JAMB reg numbers
85class NotJAMBRegNumber(schema.ValidationError):
86    __doc__ = u"Invalid JAMB registration number"
87
88#: Regular expression to check jamb_reg_number formats.
89check_jamb_reg_number = (
90    re.compile(r"^\d{12}[A-Z]{3}$").match or
91    re.compile(r"^\d{12}[A-Z]{2}$").match
92    )
93
94def validate_jamb_reg_number(value):
95    if not check_jamb_reg_number(value):
96        raise NotJAMBRegNumber(value)
97    return True
98
99#lgas_vocab = SimpleKofaVocabulary(
100#    *sorted([(x[1],x[0]) for x in LGAS]))
101
102class LGASource(BasicSourceFactory):
103    """A source for school subjects used in exam documentation.
104    """
105    lga_dict = dict(LGAS)
106
107    def getValues(self):
108        return sorted(self.lga_dict.keys())
109
110    def getToken(self, value):
111        return str(value)
112
113    def getTitle(self, value):
114        return self.lga_dict.get(value,
115            _('Invalid key: ${a}', mapping = {'a':value}))
116
117class DisabilitiesSource(ContextualDictSourceFactoryBase):
118    """A source for filtering groups of students
119    """
120    #: name of dict to deliver from kofa utils.
121    DICT_NAME = 'DISABILITIES_DICT'
122
123class GradingSystemSource(ContextualDictSourceFactoryBase):
124    """A application category source delivers all special handling categories
125    provided for accommodation booking.
126    """
127    #: name of dict to deliver from kofa utils.
128    DICT_NAME = 'GRADING_SYSTEM_DICT'
129
130class ICustomSessionConfiguration(ISessionConfiguration):
131    """A session configuration object.
132    """
133
134    remita_enabled = schema.Bool(
135        title = _(u'Remita integration enabled'),
136        default = False,
137        )
138
139    interswitch_enabled = schema.Bool(
140        title = _(u'Interswitch Collegepay integration enabled'),
141        default = True,
142        )
143
144    interswitch_paydirect_enabled = schema.Bool(
145        title = _(u'Interswitch Paydirect integration enabled'),
146        default = True,
147        )
148
149    interswitch_webcheckout_enabled = schema.Bool(
150        title = _(u'Interswitch WebCheckout integration enabled'),
151        default = False,
152        )
153
154    etranzact_webconnect_enabled = schema.Bool(
155        title = _(u'Etranzact Webconnect integration enabled'),
156        default = False,
157        )
158
159    etranzact_payoutlet_enabled = schema.Bool(
160        title = _(u'Etranzact Payoutlet integration enabled'),
161        default = False,
162        )
163
164    paypal_enabled = schema.Bool(
165        title = _(u'Paypal integration enabled'),
166        default = False,
167        )
168
169
170class ICustomSessionConfigurationAdd(ICustomSessionConfiguration):
171    """A session configuration object in add mode.
172    """
173
174    academic_session = schema.Choice(
175        title = _(u'Academic Session'),
176        source = academic_sessions_vocab,
177        default = None,
178        required = True,
179        readonly = False,
180        )
181
182ICustomSessionConfigurationAdd[
183    'academic_session'].order =  ICustomSessionConfiguration[
184    'academic_session'].order
Note: See TracBrowser for help on using the repository browser.