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

Last change on this file since 16161 was 16109, checked in by Henrik Bettermann, 4 years ago

Add high_qual item.

  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1## $Id: interfaces.py 16109 2020-06-05 06:22:05Z 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    (_('Awaiting Results'),'a_rslt'),
49    )
50
51high_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
67exam_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
82class NotJAMBRegNumber(schema.ValidationError):
83    __doc__ = u"Invalid JAMB registration number"
84
85#: Regular expression to check jamb_reg_number formats.
86check_jamb_reg_number = re.compile(r"^\d{8}[A-Z]{2}$").match
87
88def 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
96class 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
111class 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
118class 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 integration enabled'),
129        default = True,
130        )
131
132    etranzact_webconnect_enabled = schema.Bool(
133        title = _(u'Etranzact Webconnect integration enabled'),
134        default = False,
135        )
136
137    etranzact_payoutlet_enabled = schema.Bool(
138        title = _(u'Etranzact Payoutlet integration enabled'),
139        default = False,
140        )
141
142class ICustomSessionConfigurationAdd(ICustomSessionConfiguration):
143    """A session configuration object in add mode.
144    """
145
146    academic_session = schema.Choice(
147        title = _(u'Academic Session'),
148        source = academic_sessions_vocab,
149        default = None,
150        required = True,
151        readonly = False,
152        )
153
154ICustomSessionConfigurationAdd[
155    'academic_session'].order =  ICustomSessionConfiguration[
156    'academic_session'].order
Note: See TracBrowser for help on using the repository browser.