Changeset 16618 for main


Ignore:
Timestamp:
15 Sep 2021, 20:06:27 (3 years ago)
Author:
Henrik Bettermann
Message:

Start customization of application forms.

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

Legend:

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

    r16615 r16618  
    1919"""
    2020import grok
    21 from waeup.kofa.applicants.browser import (
    22     ApplicantRegistrationPage, ApplicantsContainerPage)
     21from zope.component import getUtility
     22from zope.i18n import translate
     23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     24from zope.formlib.textwidgets import BytesDisplayWidget
     25from waeup.kofa.students.interfaces import IStudentsUtils
     26from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
     27    ApplicantManageFormPage, ApplicantEditFormPage,
     28    ApplicantRegistrationPage,
     29    OnlinePaymentDisplayFormPage,
     30    OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
     31    )
     32from waeup.kofa.applicants.viewlets import (
     33    PDFActionButton, PaymentReceiptActionButton)
     34from waeup.kofa.applicants.pdf import PDFApplicationSlip
    2335from kofacustom.nigeria.applicants.browser import (
    2436    NigeriaApplicantDisplayFormPage,
     37    NigeriaApplicantManageFormPage,
     38    NigeriaApplicantEditFormPage,
    2539    NigeriaPDFApplicationSlip)
     40from kofacustom.nigeria.applicants.interfaces import (
     41    INigeriaPGApplicant, INigeriaUGApplicant,
     42    INigeriaPGApplicantEdit, INigeriaUGApplicantEdit,
     43    INigeriaApplicantOnlinePayment,
     44    UG_OMIT_DISPLAY_FIELDS,
     45    UG_OMIT_PDF_FIELDS,
     46    UG_OMIT_MANAGE_FIELDS,
     47    UG_OMIT_EDIT_FIELDS,
     48    PG_OMIT_DISPLAY_FIELDS,
     49    PG_OMIT_PDF_FIELDS,
     50    PG_OMIT_MANAGE_FIELDS,
     51    PG_OMIT_EDIT_FIELDS,
     52    )
     53from kofacustom.edocons.applicants.interfaces import (
     54    ICustomPGApplicant, ICustomUGApplicant, ICustomApplicant,
     55    ICustomPGApplicantEdit, ICustomUGApplicantEdit,
     56    ICustomApplicantOnlinePayment,
     57    )
     58from kofacustom.nigeria.interfaces import MessageFactory as _
    2659
    27 from kofacustom.edocons.interfaces import MessageFactory as _
     60class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
     61    """A display view for applicant data.
     62    """
    2863
     64    @property
     65    def form_fields(self):
     66        if self.target is not None and self.target.startswith('pg'):
     67            form_fields = grok.AutoFields(ICustomPGApplicant)
     68            for field in PG_OMIT_DISPLAY_FIELDS:
     69                form_fields = form_fields.omit(field)
     70        else:
     71            form_fields = grok.AutoFields(ICustomUGApplicant)
     72            for field in UG_OMIT_DISPLAY_FIELDS:
     73                form_fields = form_fields.omit(field)
     74        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
     75        form_fields['notice'].custom_widget = BytesDisplayWidget
     76        if not getattr(self.context, 'student_id'):
     77            form_fields = form_fields.omit('student_id')
     78        if not getattr(self.context, 'screening_score'):
     79            form_fields = form_fields.omit('screening_score')
     80        if not getattr(self.context, 'screening_venue') or self._not_paid():
     81            form_fields = form_fields.omit('screening_venue')
     82        if not getattr(self.context, 'screening_date') or self._not_paid():
     83            form_fields = form_fields.omit('screening_date')
     84        return form_fields
     85
     86class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
     87
     88    @property
     89    def form_fields(self):
     90        if self.target is not None and self.target.startswith('pg'):
     91            form_fields = grok.AutoFields(ICustomPGApplicant)
     92            for field in PG_OMIT_PDF_FIELDS:
     93                form_fields = form_fields.omit(field)
     94        else:
     95            form_fields = grok.AutoFields(ICustomUGApplicant)
     96            for field in UG_OMIT_PDF_FIELDS:
     97                form_fields = form_fields.omit(field)
     98        if not getattr(self.context, 'student_id'):
     99            form_fields = form_fields.omit('student_id')
     100        if not getattr(self.context, 'screening_score'):
     101            form_fields = form_fields.omit('screening_score')
     102        if not getattr(self.context, 'screening_venue'):
     103            form_fields = form_fields.omit('screening_venue')
     104        if not getattr(self.context, 'screening_date'):
     105            form_fields = form_fields.omit('screening_date')
     106        return form_fields
     107
     108class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
     109    """A full edit view for applicant data.
     110    """
     111
     112    @property
     113    def form_fields(self):
     114        if self.target is not None and self.target.startswith('pg'):
     115            form_fields = grok.AutoFields(ICustomPGApplicant)
     116            for field in PG_OMIT_MANAGE_FIELDS:
     117                form_fields = form_fields.omit(field)
     118        else:
     119            form_fields = grok.AutoFields(ICustomUGApplicant)
     120            for field in UG_OMIT_MANAGE_FIELDS:
     121                form_fields = form_fields.omit(field)
     122        form_fields['student_id'].for_display = True
     123        form_fields['applicant_id'].for_display = True
     124        return form_fields
     125
     126class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
     127    """An applicant-centered edit view for applicant data.
     128    """
     129
     130    @property
     131    def form_fields(self):
     132        if self.target is not None and self.target.startswith('pg'):
     133            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
     134            for field in PG_OMIT_EDIT_FIELDS:
     135                form_fields = form_fields.omit(field)
     136        else:
     137            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     138            for field in UG_OMIT_EDIT_FIELDS:
     139                form_fields = form_fields.omit(field)
     140        form_fields['applicant_id'].for_display = True
     141        form_fields['reg_number'].for_display = True
     142        return form_fields
  • main/kofacustom.edocons/trunk/src/kofacustom/edocons/applicants/interfaces.py

    r16615 r16618  
    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,
     32    IApplicantBaseData)
    3133from kofacustom.nigeria.applicants.interfaces import (
    3234    LGASource, high_qual, high_grade, exam_types,
     35    jambsubjects,
    3336    INigeriaUGApplicant, INigeriaPGApplicant,
    3437    INigeriaApplicantOnlinePayment,
     
    3740    IPUTMEApplicantEdit,
    3841    )
     42from kofacustom.nigeria.interfaces import (
     43    LGASource, DisabilitiesSource,
     44    high_qual, high_grade, exam_types, validate_jamb_reg_number)
     45
    3946from kofacustom.edocons.interfaces import MessageFactory as _
    4047from kofacustom.edocons.payments.interfaces import ICustomOnlinePayment
    4148
     49programme_types_vocab = SimpleKofaVocabulary(
     50    (_('Post UTME'), 'putme'),
     51    (_('Post DE'), 'pude'),
     52    (_('Admission Screening Exercise'), 'ase'),
     53    (_('not applicable'), 'na'),
     54    )
     55
    4256class ICustomUGApplicant(INigeriaUGApplicant):
    4357    """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     """
     58    """
     59
     60    disabilities = schema.Choice(
     61        title = _(u'Disability'),
     62        source = DisabilitiesSource(),
     63        required = False,
     64        )
     65    nationality = schema.Choice(
     66        source = nats_vocab,
     67        title = _(u'Nationality'),
     68        required = False,
     69        )
     70    lga = schema.Choice(
     71        source = LGASource(),
     72        title = _(u'State/LGA (Nigerians only)'),
     73        required = False,
     74        )
     75    perm_address = schema.Text(
     76        title = _(u'Permanent Address'),
     77        required = False,
     78        )
     79    course1 = schema.Choice(
     80        title = _(u'1st Choice Course of Study'),
     81        source = AppCatCertificateSource(),
     82        required = True,
     83        )
     84    course2 = schema.Choice(
     85        title = _(u'2nd Choice Course of Study'),
     86        source = AppCatCertificateSource(),
     87        required = False,
     88        )
     89
     90    fst_sit_fname = schema.TextLine(
     91        title = _(u'Full Name'),
     92        required = False,
     93        readonly = False,
     94        )
     95
     96    fst_sit_no = schema.TextLine(
     97        title = _(u'Exam Number'),
     98        required = False,
     99        readonly = False,
     100        )
     101
     102    fst_sit_sc_pin = schema.TextLine(
     103        title = _(u'Scratch Card Pin'),
     104        required = False,
     105        readonly = False,
     106        )
     107
     108    fst_sit_sc_serial_number = schema.TextLine(
     109        title = _(u'Scratch Card Serial Number'),
     110        required = False,
     111        readonly = False,
     112        )
     113
     114    fst_sit_date = FormattedDate(
     115        title = _(u'Exam Date'),
     116        required = False,
     117        readonly = False,
     118        show_year = True,
     119        )
     120
     121    fst_sit_type = schema.Choice(
     122        title = _(u'Exam Type'),
     123        required = False,
     124        readonly = False,
     125        vocabulary = exam_types,
     126        )
     127
     128    fst_sit_results = schema.List(
     129        title = _(u'Exam Results'),
     130        value_type = ResultEntryField(),
     131        required = False,
     132        readonly = False,
     133        defaultFactory=list,
     134        )
     135
     136    scd_sit_fname = schema.TextLine(
     137        title = _(u'Full Name'),
     138        required = False,
     139        readonly = False,
     140        )
     141
     142    scd_sit_no = schema.TextLine(
     143        title = _(u'Exam Number'),
     144        required = False,
     145        readonly = False,
     146        )
     147
     148    scd_sit_sc_pin = schema.TextLine(
     149        title = _(u'Scratch Card Pin'),
     150        required = False,
     151        readonly = False,
     152        )
     153
     154    scd_sit_sc_serial_number = schema.TextLine(
     155        title = _(u'Scratch Card Serial Number'),
     156        required = False,
     157        readonly = False,
     158        )
     159
     160    scd_sit_date = FormattedDate(
     161        title = _(u'Exam Date'),
     162        required = False,
     163        readonly = False,
     164        show_year = True,
     165        )
     166
     167    scd_sit_type = schema.Choice(
     168        title = _(u'Exam Type'),
     169        required = False,
     170        readonly = False,
     171        vocabulary = exam_types,
     172        )
     173
     174    scd_sit_results = schema.List(
     175        title = _(u'Exam Results'),
     176        value_type = ResultEntryField(),
     177        required = False,
     178        readonly = False,
     179        defaultFactory=list,
     180        )
     181
     182    programme_type = schema.Choice(
     183        title = _(u'Programme Type'),
     184        vocabulary = programme_types_vocab,
     185        required = False,
     186        )
     187
     188    hq_type = schema.Choice(
     189        title = _(u'Qualification Obtained'),
     190        required = False,
     191        readonly = False,
     192        vocabulary = high_qual,
     193        )
     194    hq_matric_no = schema.TextLine(
     195        title = _(u'Former Matric Number'),
     196        required = False,
     197        readonly = False,
     198        )
     199    hq_degree = schema.Choice(
     200        title = _(u'Class of Degree'),
     201        required = False,
     202        readonly = False,
     203        vocabulary = high_grade,
     204        )
     205    hq_school = schema.TextLine(
     206        title = _(u'Institution Attended'),
     207        required = False,
     208        readonly = False,
     209        )
     210    hq_session = schema.TextLine(
     211        title = _(u'Years Attended'),
     212        required = False,
     213        readonly = False,
     214        )
     215    hq_disc = schema.TextLine(
     216        title = _(u'Discipline'),
     217        required = False,
     218        readonly = False,
     219        )
     220    jamb_subjects = schema.Text(
     221        title = _(u'Subjects and Scores'),
     222        required = False,
     223        )
     224    jamb_subjects_list = schema.List(
     225        title = _(u'JAMB Subjects'),
     226        required = False,
     227        defaultFactory=list,
     228        value_type = schema.Choice(
     229            vocabulary = jambsubjects
     230            #source = JAMBSubjectSource(),
     231            ),
     232        )
     233    jamb_score = schema.Int(
     234        title = _(u'Total JAMB Score'),
     235        required = False,
     236        )
     237    #jamb_age = schema.Int(
     238    #    title = _(u'Age (provided by JAMB)'),
     239    #    required = False,
     240    #    )
     241    jamb_reg_number = schema.TextLine(
     242        title = _(u'JAMB Registration Number'),
     243        required = False,
     244        constraint=validate_jamb_reg_number,
     245        )
     246    notice = schema.Text(
     247        title = _(u'Notice'),
     248        required = False,
     249        )
     250    screening_venue = schema.TextLine(
     251        title = _(u'Screening Venue'),
     252        required = False,
     253        )
     254    screening_date = schema.TextLine(
     255        title = _(u'Screening Date'),
     256        required = False,
     257        )
     258    screening_score = schema.Int(
     259        title = _(u'Screening Score (%)'),
     260        required = False,
     261        )
     262    aggregate = schema.Int(
     263        title = _(u'Aggregate Score (%)'),
     264        description = _(u'(average of relative JAMB and PUTME scores)'),
     265        required = False,
     266        )
     267    result_uploaded = schema.Bool(
     268        title = _(u'Result uploaded'),
     269        default = False,
     270        required = False,
     271        )
     272    student_id = schema.TextLine(
     273        title = _(u'Student Id'),
     274        required = False,
     275        readonly = False,
     276        )
     277    course_admitted = schema.Choice(
     278        title = _(u'Admitted Course of Study'),
     279        source = CertificateSource(),
     280        required = False,
     281        )
     282    locked = schema.Bool(
     283        title = _(u'Form locked'),
     284        default = False,
     285        required = False,
     286        )
    49287
    50288class ICustomPGApplicant(INigeriaPGApplicant):
     
    76314        """
    77315
    78 class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
     316class ICustomUGApplicantEdit(ICustomUGApplicant):
    79317    """An undergraduate applicant interface for edit forms.
    80318
Note: See TracChangeset for help on using the changeset viewer.