Changeset 16734


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

Adjust application form.

Location:
main/kofacustom.unidel/trunk/src/kofacustom/unidel/applicants
Files:
2 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
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/applicants/interfaces.py

    r16721 r16734  
    2626from waeup.kofa.interfaces import (
    2727    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
    28 from waeup.kofa.schema import FormattedDate, TextLineChoice
     28from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
    2929from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
    3030from waeup.kofa.applicants.interfaces import contextual_reg_num_source
    3131from kofacustom.nigeria.applicants.interfaces import (
    32     LGASource, high_qual, high_grade, exam_types,
     32    LGASource, high_qual, high_grade, exam_types, DisabilitiesSource,
     33    programme_types_vocab, jambsubjects, validate_jamb_reg_number,
    3334    INigeriaUGApplicant, INigeriaPGApplicant,
    3435    INigeriaApplicantOnlinePayment,
     
    4243class ICustomUGApplicant(INigeriaUGApplicant):
    4344    """An undergraduate applicant.
    44 
    45     This interface defines the least common multiple of all fields
    46     in ug application forms. In customized forms, fields can be excluded by
    47     adding them to the UG_OMIT* tuples.
    48     """
     45    """
     46
     47    disabilities = schema.Choice(
     48        title = _(u'Disability'),
     49        source = DisabilitiesSource(),
     50        required = False,
     51        )
     52    nationality = schema.Choice(
     53        source = nats_vocab,
     54        title = _(u'Nationality'),
     55        required = False,
     56        )
     57    lga = schema.Choice(
     58        source = LGASource(),
     59        title = _(u'State/LGA (Nigerians only)'),
     60        required = False,
     61        )
     62    perm_address = schema.Text(
     63        title = _(u'Permanent Address'),
     64        required = False,
     65        )
     66
     67    next_kin_name = schema.TextLine(
     68        title = _(u'Next of Kin Name'),
     69        required = False,
     70        readonly = False,
     71        )
     72
     73    next_kin_relation = schema.TextLine(
     74        title = _(u'Next of Kin Relationship'),
     75        required = False,
     76        readonly = False,
     77        )
     78
     79    next_kin_address = schema.Text(
     80        title = _(u'Next of Kin Address'),
     81        required = False,
     82        readonly = False,
     83        )
     84
     85    next_kin_phone = PhoneNumber(
     86        title = _(u'Next of Kin Phone'),
     87        description = u'',
     88        required = False,
     89        readonly = False,
     90        )
     91
     92    course1 = schema.Choice(
     93        title = _(u'1st Choice Course of Study'),
     94        source = AppCatCertificateSource(),
     95        required = True,
     96        )
     97    course2 = schema.Choice(
     98        title = _(u'2nd Choice Course of Study'),
     99        source = AppCatCertificateSource(),
     100        required = False,
     101        )
     102
     103    fst_sit_fname = schema.TextLine(
     104        title = _(u'Full Name'),
     105        required = False,
     106        readonly = False,
     107        )
     108
     109    fst_sit_no = schema.TextLine(
     110        title = _(u'Exam Number'),
     111        required = False,
     112        readonly = False,
     113        )
     114
     115    fst_sit_date = FormattedDate(
     116        title = _(u'Exam Date'),
     117        required = False,
     118        readonly = False,
     119        show_year = True,
     120        )
     121
     122    fst_sit_type = schema.Choice(
     123        title = _(u'Exam Type'),
     124        required = False,
     125        readonly = False,
     126        vocabulary = exam_types,
     127        )
     128
     129    fst_sit_results = schema.List(
     130        title = _(u'Exam Results'),
     131        value_type = ResultEntryField(),
     132        required = False,
     133        readonly = False,
     134        defaultFactory=list,
     135        )
     136
     137    scd_sit_fname = schema.TextLine(
     138        title = _(u'Full Name'),
     139        required = False,
     140        readonly = False,
     141        )
     142
     143    scd_sit_no = schema.TextLine(
     144        title = _(u'Exam Number'),
     145        required = False,
     146        readonly = False,
     147        )
     148
     149    scd_sit_date = FormattedDate(
     150        title = _(u'Exam Date'),
     151        required = False,
     152        readonly = False,
     153        show_year = True,
     154        )
     155
     156    scd_sit_type = schema.Choice(
     157        title = _(u'Exam Type'),
     158        required = False,
     159        readonly = False,
     160        vocabulary = exam_types,
     161        )
     162
     163    scd_sit_results = schema.List(
     164        title = _(u'Exam Results'),
     165        value_type = ResultEntryField(),
     166        required = False,
     167        readonly = False,
     168        defaultFactory=list,
     169        )
     170
     171    programme_type = schema.Choice(
     172        title = _(u'Programme Type'),
     173        vocabulary = programme_types_vocab,
     174        required = False,
     175        )
     176
     177    hq_type = schema.Choice(
     178        title = _(u'Qualification Obtained'),
     179        required = False,
     180        readonly = False,
     181        vocabulary = high_qual,
     182        )
     183    hq_matric_no = schema.TextLine(
     184        title = _(u'Former Matric Number'),
     185        required = False,
     186        readonly = False,
     187        )
     188    hq_degree = schema.Choice(
     189        title = _(u'Class of Degree'),
     190        required = False,
     191        readonly = False,
     192        vocabulary = high_grade,
     193        )
     194    hq_school = schema.TextLine(
     195        title = _(u'Institution Attended'),
     196        required = False,
     197        readonly = False,
     198        )
     199    hq_session = schema.TextLine(
     200        title = _(u'Years Attended'),
     201        required = False,
     202        readonly = False,
     203        )
     204    hq_disc = schema.TextLine(
     205        title = _(u'Discipline'),
     206        required = False,
     207        readonly = False,
     208        )
     209    jamb_subjects = schema.Text(
     210        title = _(u'Subjects and Scores'),
     211        required = False,
     212        )
     213    jamb_subjects_list = schema.List(
     214        title = _(u'JAMB Subjects'),
     215        required = False,
     216        defaultFactory=list,
     217        value_type = schema.Choice(
     218            vocabulary = jambsubjects
     219            #source = JAMBSubjectSource(),
     220            ),
     221        )
     222    jamb_score = schema.Int(
     223        title = _(u'Total JAMB Score'),
     224        required = False,
     225        )
     226    #jamb_age = schema.Int(
     227    #    title = _(u'Age (provided by JAMB)'),
     228    #    required = False,
     229    #    )
     230    jamb_reg_number = schema.TextLine(
     231        title = _(u'JAMB Registration Number'),
     232        required = False,
     233        constraint=validate_jamb_reg_number,
     234        )
     235    notice = schema.Text(
     236        title = _(u'Notice'),
     237        required = False,
     238        )
     239    screening_venue = schema.TextLine(
     240        title = _(u'Screening Venue'),
     241        required = False,
     242        )
     243    screening_date = schema.TextLine(
     244        title = _(u'Screening Date'),
     245        required = False,
     246        )
     247    screening_score = schema.Int(
     248        title = _(u'Screening Score (%)'),
     249        required = False,
     250        )
     251    aggregate = schema.Int(
     252        title = _(u'Aggregate Score (%)'),
     253        description = _(u'(average of relative JAMB and PUTME scores)'),
     254        required = False,
     255        )
     256    result_uploaded = schema.Bool(
     257        title = _(u'Result uploaded'),
     258        default = False,
     259        required = False,
     260        )
     261    student_id = schema.TextLine(
     262        title = _(u'Student Id'),
     263        required = False,
     264        readonly = False,
     265        )
     266    course_admitted = schema.Choice(
     267        title = _(u'Admitted Course of Study'),
     268        source = CertificateSource(),
     269        required = False,
     270        )
     271    locked = schema.Bool(
     272        title = _(u'Form locked'),
     273        default = False,
     274        required = False,
     275        )
    49276
    50277class ICustomPGApplicant(INigeriaPGApplicant):
    51278    """A postgraduate applicant.
    52 
    53     This interface defines the least common multiple of all fields
    54     in pg application forms. In customized forms, fields can be excluded by
    55     adding them to the PG_OMIT* tuples.
    56     """
    57 
     279    """
    58280
    59281class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
     
    76298        """
    77299
    78 class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
     300class ICustomUGApplicantEdit(ICustomUGApplicant):
    79301    """An undergraduate applicant interface for edit forms.
    80302
Note: See TracChangeset for help on using the changeset viewer.