Ignore:
Timestamp:
14 Nov 2019, 14:45:16 (5 years ago)
Author:
Henrik Bettermann
Message:

Add sponsor field.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants
Files:
2 edited

Legend:

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

    r15793 r15807  
    1919"""
    2020import grok
     21from zope.formlib.textwidgets import BytesDisplayWidget
    2122from waeup.kofa.applicants.browser import (
    2223    ApplicantRegistrationPage, ApplicantsContainerPage)
     24from waeup.kofa.applicants.interfaces import ISpecialApplicant
    2325from kofacustom.nigeria.applicants.browser import (
    2426    NigeriaApplicantDisplayFormPage,
     27    NigeriaApplicantManageFormPage,
     28    NigeriaApplicantEditFormPage,
    2529    NigeriaPDFApplicationSlip)
    26 from kofacustom.iuokada.applicants.interfaces import ICustomApplicant
    27 
     30from kofacustom.nigeria.applicants.interfaces import (
     31    UG_OMIT_DISPLAY_FIELDS,
     32    UG_OMIT_PDF_FIELDS,
     33    UG_OMIT_MANAGE_FIELDS,
     34    UG_OMIT_EDIT_FIELDS,
     35    PG_OMIT_DISPLAY_FIELDS,
     36    PG_OMIT_PDF_FIELDS,
     37    PG_OMIT_MANAGE_FIELDS,
     38    PG_OMIT_EDIT_FIELDS,
     39    )
     40from kofacustom.iuokada.applicants.interfaces import (
     41    ICustomPGApplicant, ICustomUGApplicant,
     42    ICustomPGApplicantEdit, ICustomUGApplicantEdit,
     43    ICustomApplicantOnlinePayment
     44    )
    2845from kofacustom.iuokada.interfaces import MessageFactory as _
    2946
     
    3148    """A display view for applicant data.
    3249    """
     50
    3351    @property
    3452    def form_fields(self):
    35         if self.context.special:
    36             form_fields = grok.AutoFields(ISpecialApplicant).omit('locked')
     53        if self.target is not None and self.target.startswith('pg'):
     54            form_fields = grok.AutoFields(ICustomPGApplicant)
     55            for field in PG_OMIT_DISPLAY_FIELDS:
     56                form_fields = form_fields.omit(field)
    3757        else:
    38             form_fields = grok.AutoFields(ICustomApplicant).omit(
    39                 'locked', 'course_admitted', 'password', 'suspended')
     58            form_fields = grok.AutoFields(ICustomUGApplicant)
     59            for field in UG_OMIT_DISPLAY_FIELDS:
     60                form_fields = form_fields.omit(field)
     61        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
     62        form_fields['notice'].custom_widget = BytesDisplayWidget
     63        if not getattr(self.context, 'student_id'):
     64            form_fields = form_fields.omit('student_id')
     65        if not getattr(self.context, 'screening_score'):
     66            form_fields = form_fields.omit('screening_score')
     67        if not getattr(self.context, 'screening_venue') or self._not_paid():
     68            form_fields = form_fields.omit('screening_venue')
     69        if not getattr(self.context, 'screening_date') or self._not_paid():
     70            form_fields = form_fields.omit('screening_date')
    4071        return form_fields
    4172
     73class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
     74    """A full edit view for applicant data.
     75    """
     76
     77    @property
     78    def form_fields(self):
     79        if self.target is not None and self.target.startswith('pg'):
     80            form_fields = grok.AutoFields(ICustomPGApplicant)
     81            for field in PG_OMIT_MANAGE_FIELDS:
     82                form_fields = form_fields.omit(field)
     83        else:
     84            form_fields = grok.AutoFields(ICustomUGApplicant)
     85            for field in UG_OMIT_MANAGE_FIELDS:
     86                form_fields = form_fields.omit(field)
     87        form_fields['student_id'].for_display = True
     88        form_fields['applicant_id'].for_display = True
     89        return form_fields
     90
     91class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
     92    """An applicant-centered edit view for applicant data.
     93    """
     94
     95    @property
     96    def form_fields(self):
     97        if self.target is not None and self.target.startswith('pg'):
     98            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
     99            for field in PG_OMIT_EDIT_FIELDS:
     100                form_fields = form_fields.omit(field)
     101        else:
     102            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     103            for field in UG_OMIT_EDIT_FIELDS:
     104                form_fields = form_fields.omit(field)
     105        form_fields['applicant_id'].for_display = True
     106        form_fields['reg_number'].for_display = True
     107        return form_fields
     108
     109class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
     110
     111    @property
     112    def form_fields(self):
     113        if self.target is not None and self.target.startswith('pg'):
     114            form_fields = grok.AutoFields(ICustomPGApplicant)
     115            for field in PG_OMIT_PDF_FIELDS:
     116                form_fields = form_fields.omit(field)
     117        else:
     118            form_fields = grok.AutoFields(ICustomUGApplicant)
     119            for field in UG_OMIT_PDF_FIELDS:
     120                form_fields = form_fields.omit(field)
     121        if not getattr(self.context, 'student_id'):
     122            form_fields = form_fields.omit('student_id')
     123        if not getattr(self.context, 'screening_score'):
     124            form_fields = form_fields.omit('screening_score')
     125        if not getattr(self.context, 'screening_venue'):
     126            form_fields = form_fields.omit('screening_venue')
     127        if not getattr(self.context, 'screening_date'):
     128            form_fields = form_fields.omit('screening_date')
     129        return form_fields
     130
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/interfaces.py

    r15793 r15807  
    2828from waeup.kofa.schema import FormattedDate, TextLineChoice
    2929from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
    30 from waeup.kofa.applicants.interfaces import contextual_reg_num_source
     30from waeup.kofa.applicants.interfaces import (
     31    contextual_reg_num_source, IApplicantBaseData)
    3132from kofacustom.nigeria.applicants.interfaces import (
    3233    LGASource, high_qual, high_grade, exam_types,
     
    7980        required = False,
    8081        )
     82
     83ICustomUGApplicant[
     84    'sponsor'].order =  ICustomUGApplicant['lga'].order
     85ICustomUGApplicant[
     86    'heard_about'].order =  ICustomUGApplicant['lga'].order
     87ICustomUGApplicant[
     88    'sponsor'].order =  ICustomUGApplicant['lga'].order
     89ICustomUGApplicant[
     90    'lga'].order =  ICustomUGApplicant['nationality'].order
    8191
    8292class ICustomPGApplicant(INigeriaPGApplicant):
Note: See TracChangeset for help on using the changeset viewer.