1 | ## $Id: interfaces.py 16484 2021-05-19 07:47:21Z 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 | |
---|
19 | import re |
---|
20 | import zope.i18nmessageid |
---|
21 | from zope import schema |
---|
22 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
23 | from waeup.kofa.interfaces import (SimpleKofaVocabulary, |
---|
24 | ISessionConfiguration, academic_sessions_vocab, |
---|
25 | ContextualDictSourceFactoryBase) |
---|
26 | from kofacustom.nigeria.utils.lgas import LGAS |
---|
27 | |
---|
28 | _ = MessageFactory = zope.i18nmessageid.MessageFactory('kofacustom.nigeria') |
---|
29 | |
---|
30 | high_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 | (_('Awaiting Results'),'a_rslt'), |
---|
49 | ) |
---|
50 | |
---|
51 | high_grade = SimpleKofaVocabulary( |
---|
52 | ('Upper Credit','upper_credit'), |
---|
53 | ('Distinction','distinction'), |
---|
54 | ('Credit','credit'), |
---|
55 | ('Merit','merit'), |
---|
56 | ('Lower Credit','lower_credit'), |
---|
57 | ('First Class','first_class'), |
---|
58 | ('Second Class Upper','second_class_upper'), |
---|
59 | ('Second Class Lower','second_class_lower'), |
---|
60 | ('Third Class','third_class'), |
---|
61 | ('Pass','pass'), |
---|
62 | ('A Levels','al'), |
---|
63 | ('Unclassified Certificate', 'uc'), |
---|
64 | (_('Awaiting Results'),'a_rslt'), |
---|
65 | ) |
---|
66 | |
---|
67 | exam_types = SimpleKofaVocabulary( |
---|
68 | ('SSCE','ssce'), |
---|
69 | ('WAEC','waec'), |
---|
70 | ('GCE O\' LEVEL','gce_o_level'), |
---|
71 | ('TC II','tc_ii'), |
---|
72 | ('RSA','rsa'), |
---|
73 | ('NABTEB','nabteb'), |
---|
74 | ('NECO','neco'), |
---|
75 | ('ACE','ace'), |
---|
76 | ('GCE A\' LEVEL','gce_a_level'), |
---|
77 | ('IGCSE','igcse'), |
---|
78 | ('WAEC Technical Examination','wte'), |
---|
79 | ) |
---|
80 | |
---|
81 | # Define a validation method for JAMB reg numbers |
---|
82 | class NotJAMBRegNumber(schema.ValidationError): |
---|
83 | __doc__ = u"Invalid JAMB registration number" |
---|
84 | |
---|
85 | #: Regular expression to check jamb_reg_number formats. |
---|
86 | check_jamb_reg_number = re.compile(r"^\d{8}[A-Z]{2}$").match |
---|
87 | |
---|
88 | def validate_jamb_reg_number(value): |
---|
89 | if not check_jamb_reg_number(value): |
---|
90 | raise NotJAMBRegNumber(value) |
---|
91 | return True |
---|
92 | |
---|
93 | #lgas_vocab = SimpleKofaVocabulary( |
---|
94 | # *sorted([(x[1],x[0]) for x in LGAS])) |
---|
95 | |
---|
96 | class LGASource(BasicSourceFactory): |
---|
97 | """A source for school subjects used in exam documentation. |
---|
98 | """ |
---|
99 | lga_dict = dict(LGAS) |
---|
100 | |
---|
101 | def getValues(self): |
---|
102 | return sorted(self.lga_dict.keys()) |
---|
103 | |
---|
104 | def getToken(self, value): |
---|
105 | return str(value) |
---|
106 | |
---|
107 | def getTitle(self, value): |
---|
108 | return self.lga_dict.get(value, |
---|
109 | _('Invalid key: ${a}', mapping = {'a':value})) |
---|
110 | |
---|
111 | class DisabilitiesSource(ContextualDictSourceFactoryBase): |
---|
112 | """A source for filtering groups of students |
---|
113 | """ |
---|
114 | #: name of dict to deliver from kofa utils. |
---|
115 | DICT_NAME = 'DISABILITIES_DICT' |
---|
116 | |
---|
117 | |
---|
118 | class ICustomSessionConfiguration(ISessionConfiguration): |
---|
119 | """A session configuration object. |
---|
120 | """ |
---|
121 | |
---|
122 | remita_enabled = schema.Bool( |
---|
123 | title = _(u'Remita integration enabled'), |
---|
124 | default = False, |
---|
125 | ) |
---|
126 | |
---|
127 | interswitch_enabled = schema.Bool( |
---|
128 | title = _(u'Interswitch Collegepay integration enabled'), |
---|
129 | default = True, |
---|
130 | ) |
---|
131 | |
---|
132 | interswitch_paydirect_enabled = schema.Bool( |
---|
133 | title = _(u'Interswitch Paydirect integration enabled'), |
---|
134 | default = True, |
---|
135 | ) |
---|
136 | |
---|
137 | etranzact_webconnect_enabled = schema.Bool( |
---|
138 | title = _(u'Etranzact Webconnect integration enabled'), |
---|
139 | default = False, |
---|
140 | ) |
---|
141 | |
---|
142 | etranzact_payoutlet_enabled = schema.Bool( |
---|
143 | title = _(u'Etranzact Payoutlet integration enabled'), |
---|
144 | default = False, |
---|
145 | ) |
---|
146 | |
---|
147 | class ICustomSessionConfigurationAdd(ICustomSessionConfiguration): |
---|
148 | """A session configuration object in add mode. |
---|
149 | """ |
---|
150 | |
---|
151 | academic_session = schema.Choice( |
---|
152 | title = _(u'Academic Session'), |
---|
153 | source = academic_sessions_vocab, |
---|
154 | default = None, |
---|
155 | required = True, |
---|
156 | readonly = False, |
---|
157 | ) |
---|
158 | |
---|
159 | ICustomSessionConfigurationAdd[ |
---|
160 | 'academic_session'].order = ICustomSessionConfiguration[ |
---|
161 | 'academic_session'].order |
---|