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

Last change on this file since 15185 was 15046, checked in by Henrik Bettermann, 6 years ago

Fix format.

  • Property svn:keywords set to Id
File size: 4.2 KB
RevLine 
[14742]1## $Id: interfaces.py 15046 2018-06-11 07:34:16Z 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
[15045]19import re
[14742]20import zope.i18nmessageid
21from zope import schema
22from zc.sourcefactory.basic import BasicSourceFactory
23from waeup.kofa.interfaces import (SimpleKofaVocabulary,
24    ISessionConfiguration, academic_sessions_vocab)
25from kofacustom.nigeria.utils.lgas import LGAS
26
27_ = MessageFactory = zope.i18nmessageid.MessageFactory('kofacustom.nigeria')
28
29high_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'),
[14866]45    ('JUPEB','jupeb'),
[14836]46    (_('Awaiting Results'),'a_rslt'),
[14742]47    )
48
49high_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'),
[14836]62    (_('Awaiting Results'),'a_rslt'),
[14742]63    )
64
65exam_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
[15045]79# Define a validation method for JAMB reg numbers
80class NotJAMBRegNumber(schema.ValidationError):
81    __doc__ = u"Invalid JAMB registration number"
82
83#: Regular expression to check jamb_reg_number formats.
[15046]84check_jamb_reg_number = re.compile(r"^\d{8}[A-Z]{2}$").match
[15045]85
86def validate_jamb_reg_number(value):
87    if not check_jamb_reg_number(value):
88        raise NotJAMBRegNumber(value)
89    return True
90
[14742]91#lgas_vocab = SimpleKofaVocabulary(
92#    *sorted([(x[1],x[0]) for x in LGAS]))
93
94class 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
109class 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
[14755]118    interswitch_enabled = schema.Bool(
119        title = _(u'Interswitch integration enabled'),
120        default = True,
121        )
122
[14742]123class 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
135ICustomSessionConfigurationAdd[
136    'academic_session'].order =  ICustomSessionConfiguration[
137    'academic_session'].order
Note: See TracBrowser for help on using the repository browser.