1 | ## $Id: interfaces.py 15045 2018-06-11 07:29:33Z 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 | from kofacustom.nigeria.utils.lgas import LGAS |
---|
26 | |
---|
27 | _ = MessageFactory = zope.i18nmessageid.MessageFactory('kofacustom.nigeria') |
---|
28 | |
---|
29 | high_qual = SimpleKofaVocabulary( |
---|
30 | ('National Certificate of Education','nce'), |
---|
31 | ('Pre Degree Programme','pre'), |
---|
32 | ('Diploma Programme','dip'), |
---|
33 | ('National Diploma','ond'), |
---|
34 | ('Bachelors Degree','bd'), |
---|
35 | ('Masters Degree','md'), |
---|
36 | ('Professional Qualification','pq'), |
---|
37 | ('Other Certification','oc'), |
---|
38 | ('Higher National Diploma','hnd'), |
---|
39 | ('Post Graduate Diploma','pgd'), |
---|
40 | ('NCE AL OTH','nce_al_oth'), |
---|
41 | ('National Defence Academy','nda'), |
---|
42 | ('RMC','rmc'), |
---|
43 | ('Ph.D.(Doctor of Philosophy)','phd'), |
---|
44 | ('M.Phil (Master of Philosophy)','mphil'), |
---|
45 | ('JUPEB','jupeb'), |
---|
46 | (_('Awaiting Results'),'a_rslt'), |
---|
47 | ) |
---|
48 | |
---|
49 | high_grade = SimpleKofaVocabulary( |
---|
50 | ('Upper Credit','upper_credit'), |
---|
51 | ('Distinction','distinction'), |
---|
52 | ('Credit','credit'), |
---|
53 | ('Merit','merit'), |
---|
54 | ('Lower Credit','lower_credit'), |
---|
55 | ('First Class','first_class'), |
---|
56 | ('Second Class Upper','second_class_upper'), |
---|
57 | ('Second Class Lower','second_class_lower'), |
---|
58 | ('Third Class','third_class'), |
---|
59 | ('Pass','pass'), |
---|
60 | ('A Levels','al'), |
---|
61 | ('Unclassified Certificate', 'uc'), |
---|
62 | (_('Awaiting Results'),'a_rslt'), |
---|
63 | ) |
---|
64 | |
---|
65 | exam_types = SimpleKofaVocabulary( |
---|
66 | ('SSCE','ssce'), |
---|
67 | ('WAEC','waec'), |
---|
68 | ('GCE O\' LEVEL','gce_o_level'), |
---|
69 | ('TC II','tc_ii'), |
---|
70 | ('RSA','rsa'), |
---|
71 | ('NABTEB','nabteb'), |
---|
72 | ('NECO','neco'), |
---|
73 | ('ACE','ace'), |
---|
74 | ('GCE A\' LEVEL','gce_a_level'), |
---|
75 | ('IGCSE','igcse'), |
---|
76 | ('WAEC Technical Examination','wte'), |
---|
77 | ) |
---|
78 | |
---|
79 | # Define a validation method for JAMB reg numbers |
---|
80 | class NotJAMBRegNumber(schema.ValidationError): |
---|
81 | __doc__ = u"Invalid JAMB registration number" |
---|
82 | |
---|
83 | #: Regular expression to check jamb_reg_number formats. |
---|
84 | check_jamb_reg_number = re.compile(r"^[A-Z]{2}\d{8}$").match |
---|
85 | |
---|
86 | def validate_jamb_reg_number(value): |
---|
87 | if not check_jamb_reg_number(value): |
---|
88 | raise NotJAMBRegNumber(value) |
---|
89 | return True |
---|
90 | |
---|
91 | #lgas_vocab = SimpleKofaVocabulary( |
---|
92 | # *sorted([(x[1],x[0]) for x in LGAS])) |
---|
93 | |
---|
94 | class LGASource(BasicSourceFactory): |
---|
95 | """A source for school subjects used in exam documentation. |
---|
96 | """ |
---|
97 | lga_dict = dict(LGAS) |
---|
98 | |
---|
99 | def getValues(self): |
---|
100 | return sorted(self.lga_dict.keys()) |
---|
101 | |
---|
102 | def getToken(self, value): |
---|
103 | return str(value) |
---|
104 | |
---|
105 | def getTitle(self, value): |
---|
106 | return self.lga_dict.get(value, |
---|
107 | _('Invalid key: ${a}', mapping = {'a':value})) |
---|
108 | |
---|
109 | class ICustomSessionConfiguration(ISessionConfiguration): |
---|
110 | """A session configuration object. |
---|
111 | """ |
---|
112 | |
---|
113 | remita_enabled = schema.Bool( |
---|
114 | title = _(u'Remita integration enabled'), |
---|
115 | default = False, |
---|
116 | ) |
---|
117 | |
---|
118 | interswitch_enabled = schema.Bool( |
---|
119 | title = _(u'Interswitch integration enabled'), |
---|
120 | default = True, |
---|
121 | ) |
---|
122 | |
---|
123 | class ICustomSessionConfigurationAdd(ICustomSessionConfiguration): |
---|
124 | """A session configuration object in add mode. |
---|
125 | """ |
---|
126 | |
---|
127 | academic_session = schema.Choice( |
---|
128 | title = _(u'Academic Session'), |
---|
129 | source = academic_sessions_vocab, |
---|
130 | default = None, |
---|
131 | required = True, |
---|
132 | readonly = False, |
---|
133 | ) |
---|
134 | |
---|
135 | ICustomSessionConfigurationAdd[ |
---|
136 | 'academic_session'].order = ICustomSessionConfiguration[ |
---|
137 | 'academic_session'].order |
---|