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

Implement tpu zone application.

File:
1 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)
Note: See TracChangeset for help on using the changeset viewer.