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