[14742] | 1 | ## $Id: interfaces.py 17487 2023-07-14 08:50:47Z 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'), |
---|
[16109] | 47 | ('IJMBE','ijmbe'), |
---|
[17487] | 48 | ('Registered Nursing','rn'), |
---|
| 49 | ('Registered Midwifery','rm'), |
---|
| 50 | ('Bachelor of Nursing Science','bnsc'), |
---|
[14836] | 51 | (_('Awaiting Results'),'a_rslt'), |
---|
[14742] | 52 | ) |
---|
| 53 | |
---|
| 54 | high_grade = SimpleKofaVocabulary( |
---|
| 55 | ('Upper Credit','upper_credit'), |
---|
| 56 | ('Distinction','distinction'), |
---|
| 57 | ('Credit','credit'), |
---|
| 58 | ('Merit','merit'), |
---|
| 59 | ('Lower Credit','lower_credit'), |
---|
| 60 | ('First Class','first_class'), |
---|
| 61 | ('Second Class Upper','second_class_upper'), |
---|
| 62 | ('Second Class Lower','second_class_lower'), |
---|
| 63 | ('Third Class','third_class'), |
---|
| 64 | ('Pass','pass'), |
---|
| 65 | ('A Levels','al'), |
---|
| 66 | ('Unclassified Certificate', 'uc'), |
---|
[14836] | 67 | (_('Awaiting Results'),'a_rslt'), |
---|
[14742] | 68 | ) |
---|
| 69 | |
---|
| 70 | exam_types = SimpleKofaVocabulary( |
---|
| 71 | ('SSCE','ssce'), |
---|
| 72 | ('WAEC','waec'), |
---|
| 73 | ('GCE O\' LEVEL','gce_o_level'), |
---|
| 74 | ('TC II','tc_ii'), |
---|
| 75 | ('RSA','rsa'), |
---|
| 76 | ('NABTEB','nabteb'), |
---|
| 77 | ('NECO','neco'), |
---|
| 78 | ('ACE','ace'), |
---|
| 79 | ('GCE A\' LEVEL','gce_a_level'), |
---|
| 80 | ('IGCSE','igcse'), |
---|
| 81 | ('WAEC Technical Examination','wte'), |
---|
| 82 | ) |
---|
| 83 | |
---|
[17242] | 84 | # Define a validation method for JAMB reg numbers |
---|
[15045] | 85 | class NotJAMBRegNumber(schema.ValidationError): |
---|
| 86 | __doc__ = u"Invalid JAMB registration number" |
---|
| 87 | |
---|
| 88 | #: Regular expression to check jamb_reg_number formats. |
---|
[16962] | 89 | check_jamb_reg_number = re.compile(r"^\d{12}[A-Z]{2}$").match |
---|
[15045] | 90 | |
---|
| 91 | def validate_jamb_reg_number(value): |
---|
| 92 | if not check_jamb_reg_number(value): |
---|
| 93 | raise NotJAMBRegNumber(value) |
---|
| 94 | return True |
---|
| 95 | |
---|
[14742] | 96 | #lgas_vocab = SimpleKofaVocabulary( |
---|
| 97 | # *sorted([(x[1],x[0]) for x in LGAS])) |
---|
| 98 | |
---|
| 99 | class LGASource(BasicSourceFactory): |
---|
| 100 | """A source for school subjects used in exam documentation. |
---|
| 101 | """ |
---|
| 102 | lga_dict = dict(LGAS) |
---|
| 103 | |
---|
| 104 | def getValues(self): |
---|
| 105 | return sorted(self.lga_dict.keys()) |
---|
| 106 | |
---|
| 107 | def getToken(self, value): |
---|
| 108 | return str(value) |
---|
| 109 | |
---|
| 110 | def getTitle(self, value): |
---|
| 111 | return self.lga_dict.get(value, |
---|
| 112 | _('Invalid key: ${a}', mapping = {'a':value})) |
---|
| 113 | |
---|
[15489] | 114 | class DisabilitiesSource(ContextualDictSourceFactoryBase): |
---|
| 115 | """A source for filtering groups of students |
---|
| 116 | """ |
---|
| 117 | #: name of dict to deliver from kofa utils. |
---|
| 118 | DICT_NAME = 'DISABILITIES_DICT' |
---|
| 119 | |
---|
[16508] | 120 | class GradingSystemSource(ContextualDictSourceFactoryBase): |
---|
| 121 | """A application category source delivers all special handling categories |
---|
| 122 | provided for accommodation booking. |
---|
| 123 | """ |
---|
| 124 | #: name of dict to deliver from kofa utils. |
---|
| 125 | DICT_NAME = 'GRADING_SYSTEM_DICT' |
---|
[15489] | 126 | |
---|
[14742] | 127 | class ICustomSessionConfiguration(ISessionConfiguration): |
---|
| 128 | """A session configuration object. |
---|
| 129 | """ |
---|
| 130 | |
---|
| 131 | remita_enabled = schema.Bool( |
---|
| 132 | title = _(u'Remita integration enabled'), |
---|
| 133 | default = False, |
---|
| 134 | ) |
---|
| 135 | |
---|
[14755] | 136 | interswitch_enabled = schema.Bool( |
---|
[16484] | 137 | title = _(u'Interswitch Collegepay integration enabled'), |
---|
[14755] | 138 | default = True, |
---|
| 139 | ) |
---|
| 140 | |
---|
[16484] | 141 | interswitch_paydirect_enabled = schema.Bool( |
---|
| 142 | title = _(u'Interswitch Paydirect integration enabled'), |
---|
| 143 | default = True, |
---|
| 144 | ) |
---|
| 145 | |
---|
[17215] | 146 | interswitch_webcheckout_enabled = schema.Bool( |
---|
| 147 | title = _(u'Interswitch WebCheckout integration enabled'), |
---|
| 148 | default = False, |
---|
| 149 | ) |
---|
| 150 | |
---|
[15702] | 151 | etranzact_webconnect_enabled = schema.Bool( |
---|
| 152 | title = _(u'Etranzact Webconnect integration enabled'), |
---|
[15585] | 153 | default = False, |
---|
| 154 | ) |
---|
| 155 | |
---|
[15702] | 156 | etranzact_payoutlet_enabled = schema.Bool( |
---|
| 157 | title = _(u'Etranzact Payoutlet integration enabled'), |
---|
| 158 | default = False, |
---|
| 159 | ) |
---|
| 160 | |
---|
[17242] | 161 | paypal_enabled = schema.Bool( |
---|
| 162 | title = _(u'Paypal integration enabled'), |
---|
| 163 | default = False, |
---|
| 164 | ) |
---|
| 165 | |
---|
| 166 | |
---|
[14742] | 167 | class ICustomSessionConfigurationAdd(ICustomSessionConfiguration): |
---|
| 168 | """A session configuration object in add mode. |
---|
| 169 | """ |
---|
| 170 | |
---|
| 171 | academic_session = schema.Choice( |
---|
| 172 | title = _(u'Academic Session'), |
---|
| 173 | source = academic_sessions_vocab, |
---|
| 174 | default = None, |
---|
| 175 | required = True, |
---|
| 176 | readonly = False, |
---|
| 177 | ) |
---|
| 178 | |
---|
| 179 | ICustomSessionConfigurationAdd[ |
---|
| 180 | 'academic_session'].order = ICustomSessionConfiguration[ |
---|
| 181 | 'academic_session'].order |
---|