Ignore:
Timestamp:
3 Dec 2021, 08:10:26 (3 years ago)
Author:
Henrik Bettermann
Message:

Adjust application form.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/applicants/browser.py

    r16721 r16734  
    1919"""
    2020import grok
     21from zope.formlib.textwidgets import BytesDisplayWidget
    2122from waeup.kofa.applicants.browser import (
    2223    ApplicantRegistrationPage, ApplicantsContainerPage)
     
    3132    INigeriaPGApplicantEdit, INigeriaUGApplicantEdit,
    3233    INigeriaApplicantOnlinePayment,
    33     UG_OMIT_DISPLAY_FIELDS,
    34     UG_OMIT_PDF_FIELDS,
    35     UG_OMIT_MANAGE_FIELDS,
    36     UG_OMIT_EDIT_FIELDS,
     34    #UG_OMIT_DISPLAY_FIELDS,
     35    #UG_OMIT_PDF_FIELDS,
     36    #UG_OMIT_MANAGE_FIELDS,
     37    #UG_OMIT_EDIT_FIELDS,
    3738    PG_OMIT_DISPLAY_FIELDS,
    3839    PG_OMIT_PDF_FIELDS,
     
    4849from kofacustom.unidel.interfaces import MessageFactory as _
    4950
     51OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted',
     52    'result_uploaded', 'suspended', 'special_application',
     53    'bank_account_number',
     54    'bank_account_name',
     55    'bank_name')
     56
     57# UG students are all undergraduate students.
     58UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
     59    'jamb_subjects_list',
     60    'programme_type',)
     61UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',)
     62UG_OMIT_MANAGE_FIELDS = (
     63    'special_application',
     64    'jamb_subjects_list',
     65    'programme_type',)
     66UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
     67    'student_id',
     68    'notice',
     69    'screening_score',
     70    'screening_venue',
     71    'screening_date',
     72    'jamb_age',
     73    #'jamb_subjects',
     74    #'jamb_score',
     75    #'jamb_reg_number',
     76    'aggregate',)
     77
     78
     79class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
     80    """A display view for applicant data.
     81    """
     82
     83    @property
     84    def form_fields(self):
     85        if self.target is not None and self.target.startswith('pg'):
     86            form_fields = grok.AutoFields(ICustomPGApplicant)
     87            for field in PG_OMIT_DISPLAY_FIELDS:
     88                form_fields = form_fields.omit(field)
     89        else:
     90            form_fields = grok.AutoFields(ICustomUGApplicant)
     91            for field in UG_OMIT_DISPLAY_FIELDS:
     92                form_fields = form_fields.omit(field)
     93        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
     94        form_fields['notice'].custom_widget = BytesDisplayWidget
     95        if not getattr(self.context, 'student_id'):
     96            form_fields = form_fields.omit('student_id')
     97        if not getattr(self.context, 'screening_score'):
     98            form_fields = form_fields.omit('screening_score')
     99        if not getattr(self.context, 'screening_venue') or self._not_paid():
     100            form_fields = form_fields.omit('screening_venue')
     101        if not getattr(self.context, 'screening_date') or self._not_paid():
     102            form_fields = form_fields.omit('screening_date')
     103        return form_fields
     104
     105class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
     106
     107    @property
     108    def form_fields(self):
     109        if self.target is not None and self.target.startswith('pg'):
     110            form_fields = grok.AutoFields(ICustomPGApplicant)
     111            for field in PG_OMIT_PDF_FIELDS:
     112                form_fields = form_fields.omit(field)
     113        else:
     114            form_fields = grok.AutoFields(ICustomUGApplicant)
     115            for field in UG_OMIT_PDF_FIELDS:
     116                form_fields = form_fields.omit(field)
     117        if not getattr(self.context, 'student_id'):
     118            form_fields = form_fields.omit('student_id')
     119        if not getattr(self.context, 'screening_score'):
     120            form_fields = form_fields.omit('screening_score')
     121        if not getattr(self.context, 'screening_venue'):
     122            form_fields = form_fields.omit('screening_venue')
     123        if not getattr(self.context, 'screening_date'):
     124            form_fields = form_fields.omit('screening_date')
     125        return form_fields
     126
     127class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
     128    """A full edit view for applicant data.
     129    """
     130
     131    @property
     132    def form_fields(self):
     133        if self.target is not None and self.target.startswith('pg'):
     134            form_fields = grok.AutoFields(ICustomPGApplicant)
     135            for field in PG_OMIT_MANAGE_FIELDS:
     136                form_fields = form_fields.omit(field)
     137        else:
     138            form_fields = grok.AutoFields(ICustomUGApplicant)
     139            for field in UG_OMIT_MANAGE_FIELDS:
     140                form_fields = form_fields.omit(field)
     141        form_fields['student_id'].for_display = True
     142        form_fields['applicant_id'].for_display = True
     143        return form_fields
     144
    50145class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
    51146    """An applicant-centered edit view for applicant data.
     
    55150        return True
    56151
     152    @property
     153    def form_fields(self):
     154        if self.target is not None and self.target.startswith('pg'):
     155            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
     156            for field in PG_OMIT_EDIT_FIELDS:
     157                form_fields = form_fields.omit(field)
     158        else:
     159            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     160            for field in UG_OMIT_EDIT_FIELDS:
     161                form_fields = form_fields.omit(field)
     162        form_fields['applicant_id'].for_display = True
     163        form_fields['reg_number'].for_display = True
     164        return form_fields
Note: See TracChangeset for help on using the changeset viewer.