Changeset 18156


Ignore:
Timestamp:
18 Aug 2025, 06:25:21 (7 hours ago)
Author:
Henrik Bettermann
Message:

Implement tpu zone application.

Location:
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/browser.py

    r17748 r18156  
    192192            form_fields['matric_number'].for_display = True
    193193            form_fields['subj_comb'].field.required = True
    194             form_fields['school_tpu'].field.required = True
     194            #form_fields['school_tpu'].field.required = True
     195            form_fields['zone_tpu'].field.required = True
    195196            return form_fields
    196197        if target == 'utp':
     
    244245        return False
    245246
     247    MAX_ZONE = {
     248        'z1': 120,
     249        'z2': 24,
     250        'z3': 16,
     251        'z4': 22,
     252        'z5': 4,
     253        'z6': 10,
     254        'z7': 22,
     255        'z8': 40,
     256        'z9': 10,
     257        'z10': 22,
     258        'z11': 48,
     259        'z12': 6,
     260        'z13': 0,
     261        'z14': 0,
     262        'z15': 6,
     263        }
     264
     265    def _students_per_zone_exceeded(self, data):
     266        container = self.context.__parent__
     267        counter_zone = 0
     268        for appl in container.values():
     269            zone = data.get('zone_tpu').split('_')[0]
     270            max_zone = self.MAX_ZONE[zone]
     271            if appl != self.context \
     272                and appl.state in (SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED):
     273                if getattr(appl, 'zone_tpu').split(
     274                    '_')[0] == data.get('zone_tpu').split('_')[0]:
     275                    counter_zone += 1
     276                if counter_zone == max_zone:
     277                    return True
     278        return False
     279
    246280    def dataNotComplete(self, data):
    247281        target = getattr(self.context.__parent__, 'prefix', None)
    248         if target in ('tpu', 'utp'):
     282        if target in ('utp',):
    249283            if self._students_per_school_exceeded(data):
    250284                return ("1st Choice School: "
    251285                        "Maximum number of applications per school exceeded. "
     286                        "Please select another first choice school.")
     287        if target in ('tpu',):
     288            if self._students_per_zone_exceeded(data):
     289                return ("1st Choice School Zone: "
     290                        "Maximum number of applications per zone exceeded. "
    252291                        "Please select another first choice school.")
    253292        super(CustomApplicantEditFormPage, self).dataNotComplete(data)
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py

    r18067 r18156  
    4646from waeup.fceokene.applicants.schools_tpu import SCHOOLS_TPU
    4747from waeup.fceokene.applicants.schools_utp import SCHOOLS_UTP
     48from waeup.fceokene.applicants.zones import ZONES_TPU
    4849from waeup.fceokene.interfaces import MessageFactory as _
    4950
     
    9293            SCHOOLS_TPU[value][2],)
    9394
     95class TPUZoneSource(BasicSourceFactory):
     96    """A source that delivers all kinds of TPU zones.
     97    """
     98    def getValues(self):
     99        sorted_items = sorted(
     100            ZONES_TPU.items(),
     101            key=lambda element: int(element[1][0].split()[1]))
     102        return [item[0] for item in sorted_items]
     103
     104    def getToken(self, value):
     105        return value
     106
     107    def getTitle(self, value):
     108        if not ZONES_TPU.get(value, None):
     109            return u"none-existent"
     110        return u"%s: %s" % (
     111            ZONES_TPU[value][0],
     112            ZONES_TPU[value][1],)
     113
    94114class UTPSchoolSource(BasicSourceFactory):
    95115    """A source that delivers all kinds of UTP schools.
     
    192212        )
    193213
    194     school_tpu = schema.Choice(
    195         title = _(u'1st Choice TPZ and School'),
    196         source = TPUSchoolSource(),
     214    #school_tpu = schema.Choice(
     215    #    title = _(u'1st Choice TPZ and School'),
     216    #    source = TPUSchoolSource(),
     217    #    required = False,
     218    #    )
     219
     220    zone_tpu = schema.Choice(
     221        title = _(u'1st Choice TPZ'),
     222        source = TPUZoneSource(),
    197223        required = False,
    198224        )
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py

    r17962 r18156  
    218218        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    219219       
    220     def test_final_submit_tpu(self):
     220    def disable_test_final_submit_tpu(self):
    221221        # Create NCE certificate
    222222        certificate1 = createObject('waeup.Certificate')
     
    297297        self.browser.getControl("Finally Submit").click()
    298298        self.assertEqual(self.tpuapplicant.state, 'submitted')
     299        return
     300
     301    def test_final_submit_tpu(self):
     302        # Create NCE certificate
     303        certificate1 = createObject('waeup.Certificate')
     304        certificate1.application_category = 'basic'
     305        certificate1.code = 'NCECERT1'
     306        certificate1.title = 'NCECert1'
     307        certificate1.start_level = 100
     308        certificate1.end_level = 500
     309        certificate1.study_mode = u'nce_ft'
     310        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     311            certificate1)
     312        IWorkflowState(self.tpuapplicant).setState('paid')
     313        self.browser.open(self.login_path)
     314        self.browser.getControl(
     315            name="form.login").value = self.tpuapplicant.applicant_id
     316        self.browser.getControl(name="form.password").value = 'apwd'
     317        self.browser.getControl("Login").click()
     318        self.browser.open(self.tpuapplicant_path + '/edit')
     319        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     320        self.browser.getControl(name="form.zone_tpu").value = ['z5_001']
     321        self.browser.getControl(name="form.subj_comb").value = ['NCECERT1']
     322        image = open(SAMPLE_IMAGE, 'rb')
     323        ctrl = self.browser.getControl(name='form.passport')
     324        file_ctrl = ctrl.mech_control
     325        file_ctrl.add_file(image, filename='myphoto.jpg')
     326        self.browser.getControl(name="confirm_passport").value = True
     327        self.browser.getControl("Save").click()
     328        self.browser.getControl("Finally Submit").click()
     329        self.assertTrue(
     330            'Application submitted' in self.browser.contents)
     331        # Create 5 applicants who already selected z5_001
     332        for i in range(1,6):
     333            dummy = createObject(u'waeup.Applicant')
     334            dummy.firstname = u'John'
     335            dummy.lastname = u'Doe %s' %i
     336            dummy.zone_tpu = 'z5_001'
     337            self.app['applicants'][
     338                self.tpucontainer.code].addApplicant(dummy)
     339            IWorkflowState(dummy).setState('submitted')
     340        IWorkflowState(self.tpuapplicant).setState('paid')
     341        self.tpuapplicant.locked = False
     342        self.browser.open(self.tpuapplicant_path + '/edit')
     343        self.browser.getControl(name="form.zone_tpu").value = ['z5_001']
     344        self.browser.getControl("Finally Submit").click()
     345        self.assertTrue("Maximum number of applications per zone exceeded."
     346            in self.browser.contents)
     347        self.assertEqual(self.tpuapplicant.state, 'paid')
    299348        return
    300349
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/zones.py

    r18155 r18156  
    1 ZONES = {
    2         'tpu0001': ('Zone 1','Otite'),
    3         'tpu0002': ('Zone 1','Nagazi'),
    4         'tpu0003': ('Zone 1','Nagazi-Eba'),
    5         'tpu0004': ('Zone 1','Kabba Junction'),
    6         'tpu0005': ('Zone 1','Oziokutu'),
    7         'tpu0006': ('Zone 1','Ogaminana'),
    8         'tpu0007': ('Zone 1','Ozuri'),
    9         'tpu0008': ('Zone 1','Obangede'),
    10         'tpu0009': ('Zone 1','Camp 2'),
    11         'tpu0010': ('Zone 1','Itakpe'),
    12         'tpu0011': ('Zone 1','Aku'),
    13         'tpu0012': ('Zone 1','Osara'),
    14         'tpu0013': ('Zone 2','Okunchi'),
    15         'tpu0014': ('Zone 2','Ozuwaya'),
    16         'tpu0015': ('Zone 2','Lafia'),
    17         'tpu0016': ('Zone 2','Agassa'),
    18         'tpu0017': ('Zone 2','Inike-Etahi'),
    19         'tpu0018': ('Zone 2','Checkpoint'),
    20         'tpu0019': ('Zone 2','Otutu'),
    21         'tpu0020': ('Zone 3','Kuroko'),
    22         'tpu0021': ('Zone 3','Inoziomi'),
    23         'tpu0022': ('Zone 3','Karaworo'),
    24         'tpu0023': ('Zone 3','Iresuha'),
    25         'tpu0024': ('Zone 3','Ebogogo'),
    26         'tpu0025': ('Zone 3','Eika-Ohizenyi'),
    27         'tpu0026': ('Zone 3','GRA'),
    28         'tpu0027': ('Zone 4','Okengwe'),
    29         'tpu0028': ('Zone 4','Ihima'),
    30         'tpu0029': ('Zone 4','Adavi-Eba'),
    31         'tpu0030': ('Zone 4','Ege'),
    32         'tpu0031': ('Zone 5','Adogo'),
    33         'tpu0032': ('Zone 5','Eganyi'),
    34         'tpu0033': ('Zone 5','Ajaokuta Township'),
    35         'tpu0034': ('Zone 6','Magongo'),
    36         'tpu0035': ('Zone 6','Ogori'),
    37         'tpu0036': ('Zone 6','Ibillo'),
    38         'tpu0037': ('Zone 6','Lampese'),
    39         'tpu0038': ('Zone 6','Ekpe'),
    40         'tpu0039': ('Zone 7','Kabba'),
    41         'tpu0040': ('Zone 7','Ayetoro Gbede'),
    42         'tpu0041': ('Zone 7','Okoro Gbede'),
    43         'tpu0042': ('Zone 7','Araromi Gbede'),
    44         'tpu0043': ('Zone 7','Aiyegunle Gbede'),
    45         'tpu0044': ('Zone 7','Odokoro Gbede'),
    46         'tpu0045': ('Zone 8','Oka-Akoko'),
    47         'tpu0046': ('Zone 8','Ifira-Akoko'),
    48         'tpu0047': ('Zone 8','Akungba-Akoko'),
    49         'tpu0048': ('Zone 8','Ikare-Akoko'),
    50         'tpu0049': ('Zone 8','Okeagbe-Akoko'),
    51         'tpu0050': ('Zone 8','Ogbagi-Akoko'),
    52         'tpu0051': ('Zone 8','Supare-Akoko'),
    53         'tpu0052': ('Zone 8','Oba-Akoko'),
    54         'tpu0053': ('Zone 8','Ese-Akoko'),
    55         'tpu0054': ('Zone 8','Ose'),
    56         'tpu0055': ('Zone 9','Isanlu'),
    57         'tpu0056': ('Zone 9','Takete Isao'),
    58         'tpu0057': ('Zone 10','Iyara'),
    59         'tpu0058': ('Zone 10','Egbede'),
    60         'tpu0059': ('Zone 10','Egga'),
    61         'tpu0060': ('Zone 10','Ekinrin Adde'),
    62         'tpu0061': ('Zone 10','Iyamoye'),
    63         'tpu0062': ('Zone 10','Omuo-Ekiti'),
    64         'tpu0063': ('Zone 11','Zariagi-Kabba Junction'),
    65         'tpu0064': ('Zone 11','Kaduna Junction'),
    66         'tpu0065': ('Zone 11','Zango-Lokoja'),
    67         'tpu0066': ('Zone 11','Lokoja'),
    68         'tpu0067': ('Zone 11','Ganaja Village'),
    69         'tpu0068': ('Zone 11','Koton-Karfe'),
    70         'tpu0069': ('Zone 11','Gegu-Beki'),
    71         'tpu0070': ('Zone 11','Orehi'),
    72         'tpu0071': ('Zone 11','Ahoko'),
    73         'tpu0072': ('Zone 11','Robomi'),
    74         'tpu0073': ('Zone 11','Obajana'),
    75         'tpu0074': ('Zone 12','Itobe'),
    76         'tpu0075': ('Zone 15','Okpella'),
    77         'tpu0076': ('Zone 15','Auchi'),
     1ZONES_TPU = {
     2        'z1_001': ('Zone 1','Otite'),
     3        'z1_002': ('Zone 1','Nagazi'),
     4        'z1_003': ('Zone 1','Nagazi-Eba'),
     5        'z1_004': ('Zone 1','Kabba Junction'),
     6        'z1_005': ('Zone 1','Oziokutu'),
     7        'z1_006': ('Zone 1','Ogaminana'),
     8        'z1_007': ('Zone 1','Ozuri'),
     9        'z1_008': ('Zone 1','Obangede'),
     10        'z1_009': ('Zone 1','Camp 2'),
     11        'z1_010': ('Zone 1','Itakpe'),
     12        'z1_011': ('Zone 1','Aku'),
     13        'z1_012': ('Zone 1','Osara'),
     14        'z2_001': ('Zone 2','Okunchi'),
     15        'z2_002': ('Zone 2','Ozuwaya'),
     16        'z2_003': ('Zone 2','Lafia'),
     17        'z2_004': ('Zone 2','Agassa'),
     18        'z2_005': ('Zone 2','Inike-Etahi'),
     19        'z2_006': ('Zone 2','Checkpoint'),
     20        'z2_007': ('Zone 2','Otutu'),
     21        'z3_001': ('Zone 3','Kuroko'),
     22        'z3_002': ('Zone 3','Inoziomi'),
     23        'z3_003': ('Zone 3','Karaworo'),
     24        'z3_004': ('Zone 3','Iresuha'),
     25        'z3_005': ('Zone 3','Ebogogo'),
     26        'z3_006': ('Zone 3','Eika-Ohizenyi'),
     27        'z3_007': ('Zone 3','GRA'),
     28        'z4_001': ('Zone 4','Okengwe'),
     29        'z4_002': ('Zone 4','Ihima'),
     30        'z4_003': ('Zone 4','Adavi-Eba'),
     31        'z4_004': ('Zone 4','Ege'),
     32        'z5_001': ('Zone 5','Adogo'),
     33        'z5_002': ('Zone 5','Eganyi'),
     34        'z5_003': ('Zone 5','Ajaokuta Township'),
     35        'z6_001': ('Zone 6','Magongo'),
     36        'z6_002': ('Zone 6','Ogori'),
     37        'z6_003': ('Zone 6','Ibillo'),
     38        'z6_004': ('Zone 6','Lampese'),
     39        'z6_005': ('Zone 6','Ekpe'),
     40        'z7_001': ('Zone 7','Kabba'),
     41        'z7_002': ('Zone 7','Ayetoro Gbede'),
     42        'z7_003': ('Zone 7','Okoro Gbede'),
     43        'z7_004': ('Zone 7','Araromi Gbede'),
     44        'z7_005': ('Zone 7','Aiyegunle Gbede'),
     45        'z7_006': ('Zone 7','Odokoro Gbede'),
     46        'z8_001': ('Zone 8','Oka-Akoko'),
     47        'z8_002': ('Zone 8','Ifira-Akoko'),
     48        'z8_003': ('Zone 8','Akungba-Akoko'),
     49        'z8_004': ('Zone 8','Ikare-Akoko'),
     50        'z8_005': ('Zone 8','Okeagbe-Akoko'),
     51        'z8_006': ('Zone 8','Ogbagi-Akoko'),
     52        'z8_007': ('Zone 8','Supare-Akoko'),
     53        'z8_008': ('Zone 8','Oba-Akoko'),
     54        'z8_009': ('Zone 8','Ese-Akoko'),
     55        'z8_010': ('Zone 8','Ose'),
     56        'z9_001': ('Zone 9','Isanlu'),
     57        'z9_002': ('Zone 9','Takete Isao'),
     58        'z10_001': ('Zone 10','Iyara'),
     59        'z10_002': ('Zone 10','Egbede'),
     60        'z10_003': ('Zone 10','Egga'),
     61        'z10_004': ('Zone 10','Ekinrin Adde'),
     62        'z10_005': ('Zone 10','Iyamoye'),
     63        'z10_006': ('Zone 10','Omuo-Ekiti'),
     64        'z11_001': ('Zone 11','Zariagi-Kabba Junction'),
     65        'z11_002': ('Zone 11','Kaduna Junction'),
     66        'z11_003': ('Zone 11','Zango-Lokoja'),
     67        'z11_004': ('Zone 11','Lokoja'),
     68        'z11_005': ('Zone 11','Ganaja Village'),
     69        'z11_006': ('Zone 11','Koton-Karfe'),
     70        'z11_007': ('Zone 11','Gegu-Beki'),
     71        'z11_008': ('Zone 11','Orehi'),
     72        'z11_009': ('Zone 11','Ahoko'),
     73        'z11_010': ('Zone 11','Robomi'),
     74        'z11_011': ('Zone 11','Obajana'),
     75        'z12_001': ('Zone 12','Itobe'),
     76        'z15_001': ('Zone 15','Okpella'),
     77        'z15_002': ('Zone 15','Auchi'),
    7878        }
Note: See TracChangeset for help on using the changeset viewer.