Changeset 14128


Ignore:
Timestamp:
24 Aug 2016, 12:30:11 (8 years ago)
Author:
Henrik Bettermann
Message:

Customize ICustomUGApplicant and browser views which are using this interface.

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

Legend:

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

    r14035 r14128  
    1919"""
    2020import grok
     21from zope.formlib.textwidgets import BytesDisplayWidget
    2122from waeup.kofa.applicants.browser import (
    2223    ApplicantRegistrationPage, ApplicantsContainerPage)
    2324from kofacustom.nigeria.applicants.browser import (
    2425    NigeriaApplicantDisplayFormPage,
     26    NigeriaApplicantManageFormPage,
     27    NigeriaApplicantEditFormPage,
    2528    NigeriaPDFApplicationSlip)
    26 
     29from kofacustom.nigeria.applicants.interfaces import (
     30    UG_OMIT_DISPLAY_FIELDS,
     31    UG_OMIT_PDF_FIELDS,
     32    UG_OMIT_MANAGE_FIELDS,
     33    UG_OMIT_EDIT_FIELDS,
     34    )
     35from kofacustom.coewarri.applicants.interfaces import (
     36    ICustomUGApplicantEdit, ICustomUGApplicant)
    2737from kofacustom.coewarri.interfaces import MessageFactory as _
    2838
     39class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
     40    """A display view for applicant data.
     41    """
     42
     43    @property
     44    def form_fields(self):
     45        target = getattr(self.context.__parent__, 'prefix', None)
     46        form_fields = grok.AutoFields(ICustomUGApplicant)
     47        form_fields['notice'].custom_widget = BytesDisplayWidget
     48        form_fields['jamb_subjects'].custom_widget = BytesDisplayWidget
     49        if not getattr(self.context, 'student_id'):
     50            form_fields = form_fields.omit('student_id')
     51        if not getattr(self.context, 'screening_score'):
     52            form_fields = form_fields.omit('screening_score')
     53        if not getattr(self.context, 'screening_venue'):
     54            form_fields = form_fields.omit('screening_venue')
     55        if not getattr(self.context, 'screening_date'):
     56            form_fields = form_fields.omit('screening_date')
     57        return form_fields
     58
     59class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
     60
     61    @property
     62    def form_fields(self):
     63        target = getattr(self.context.__parent__, 'prefix', None)
     64        form_fields = grok.AutoFields(ICustomUGApplicant)
     65        for field in UG_OMIT_PDF_FIELDS:
     66            form_fields = form_fields.omit(field)
     67        if not getattr(self.context, 'student_id'):
     68            form_fields = form_fields.omit('student_id')
     69        if not getattr(self.context, 'screening_score'):
     70            form_fields = form_fields.omit('screening_score')
     71        if not getattr(self.context, 'screening_venue'):
     72            form_fields = form_fields.omit('screening_venue')
     73        if not getattr(self.context, 'screening_date'):
     74            form_fields = form_fields.omit('screening_date')
     75        return form_fields
     76
     77class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
     78    """A full edit view for applicant data.
     79    """
     80
     81    @property
     82    def form_fields(self):
     83        target = getattr(self.context.__parent__, 'prefix', None)
     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        target = getattr(self.context.__parent__, 'prefix', None)
     98        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     99        for field in UG_OMIT_EDIT_FIELDS:
     100            form_fields = form_fields.omit(field)
     101        form_fields['applicant_id'].for_display = True
     102        form_fields['reg_number'].for_display = True
     103        return form_fields
     104
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/applicants/interfaces.py

    r14035 r14128  
    4545    This interface defines the least common multiple of all fields
    4646    in ug application forms. In customized forms, fields can be excluded by
    47     adding them to the UG_OMIT* tuples.
    48     """
     47    adding them to the OMIT* tuples.
     48    """
     49
     50    nationality = schema.Choice(
     51        source = nats_vocab,
     52        title = _(u'Nationality'),
     53        required = True,
     54        )
     55    lga = schema.Choice(
     56        source = LGASource(),
     57        title = _(u'State/LGA (Nigerians only)'),
     58        required = False,
     59        )
     60    #perm_address = schema.Text(
     61    #    title = _(u'Permanent Address'),
     62    #    required = False,
     63    #    )
     64    course1 = schema.Choice(
     65        title = _(u'1st Choice Course of Study'),
     66        source = AppCatCertificateSource(),
     67        required = False,
     68        )
     69    course2 = schema.Choice(
     70        title = _(u'2nd Choice Course of Study'),
     71        source = AppCatCertificateSource(),
     72        required = False,
     73        )
     74    olevel_type = schema.Choice(
     75        title = _(u'1st Qualification Obtained'),
     76        required = False,
     77        readonly = False,
     78        vocabulary = exam_types,
     79        )
     80    olevel_school = schema.TextLine(
     81        title = _(u'1st Institution Attended'),
     82        required = False,
     83        readonly = False,
     84        )
     85    olevel_exam_number = schema.TextLine(
     86        title = _(u'1st Exam Number'),
     87        required = False,
     88        readonly = False,
     89        )
     90    olevel_exam_date = FormattedDate(
     91        title = _(u'1st Exam Date'),
     92        required = False,
     93        readonly = False,
     94        show_year = True,
     95        )
     96    olevel_results = schema.List(
     97        title = _(u'1st Exam Results'),
     98        value_type = ResultEntryField(),
     99        required = False,
     100        readonly = False,
     101        defaultFactory=list,
     102        )
     103    olevel_type2 = schema.Choice(
     104        title = _(u'2nd Qualification Obtained'),
     105        required = False,
     106        readonly = False,
     107        vocabulary = exam_types,
     108        )
     109    olevel_school2 = schema.TextLine(
     110        title = _(u'2nd Institution Attended'),
     111        required = False,
     112        readonly = False,
     113        )
     114    olevel_exam_number2 = schema.TextLine(
     115        title = _(u'2nd Exam Number'),
     116        required = False,
     117        readonly = False,
     118        )
     119    olevel_exam_date2 = FormattedDate(
     120        title = _(u'2nd Exam Date'),
     121        required = False,
     122        readonly = False,
     123        show_year = True,
     124        )
     125    olevel_results2 = schema.List(
     126        title = _(u'2nd Exam Results'),
     127        value_type = ResultEntryField(),
     128        required = False,
     129        readonly = False,
     130        defaultFactory=list,
     131        )
     132    hq_type = schema.Choice(
     133        title = _(u'Qualification Obtained'),
     134        required = False,
     135        readonly = False,
     136        vocabulary = high_qual,
     137        )
     138    hq_matric_no = schema.TextLine(
     139        title = _(u'Former Matric Number'),
     140        required = False,
     141        readonly = False,
     142        )
     143    hq_degree = schema.Choice(
     144        title = _(u'Class of Degree'),
     145        required = False,
     146        readonly = False,
     147        vocabulary = high_grade,
     148        )
     149    hq_school = schema.TextLine(
     150        title = _(u'Institution Attended'),
     151        required = False,
     152        readonly = False,
     153        )
     154    hq_session = schema.TextLine(
     155        title = _(u'Years Attended'),
     156        required = False,
     157        readonly = False,
     158        )
     159    hq_disc = schema.TextLine(
     160        title = _(u'Discipline'),
     161        required = False,
     162        readonly = False,
     163        )
     164    jamb_subjects = schema.Text(
     165        title = _(u'Subjects and Scores'),
     166        description = _(u'(one subject with score per line)'),
     167        required = False,
     168        )
     169    jamb_score = schema.Int(
     170        title = _(u'Total JAMB Score'),
     171        required = False,
     172        )
     173    jamb_reg_number = schema.TextLine(
     174        title = _(u'JAMB Registration Number'),
     175        required = False,
     176        )
     177    notice = schema.Text(
     178        title = _(u'Notice'),
     179        required = False,
     180        )
     181    screening_venue = schema.TextLine(
     182        title = _(u'Screening Venue'),
     183        required = False,
     184        )
     185    screening_date = schema.TextLine(
     186        title = _(u'Screening Date'),
     187        required = False,
     188        )
     189    screening_score = schema.Int(
     190        title = _(u'Screening Score (%)'),
     191        required = False,
     192        )
     193    aggregate = schema.Int(
     194        title = _(u'Aggregate Score (%)'),
     195        description = _(u'(average of relative JAMB and PUTME scores)'),
     196        required = False,
     197        )
     198    result_uploaded = schema.Bool(
     199        title = _(u'Result uploaded'),
     200        default = False,
     201        )
     202    student_id = schema.TextLine(
     203        title = _(u'Student Id'),
     204        required = False,
     205        readonly = False,
     206        )
     207    course_admitted = schema.Choice(
     208        title = _(u'Admitted Course of Study'),
     209        source = CertificateSource(),
     210        required = False,
     211        )
     212    locked = schema.Bool(
     213        title = _(u'Form locked'),
     214        default = False,
     215        )
    49216
    50217class ICustomPGApplicant(INigeriaPGApplicant):
     
    76243        """
    77244
    78 class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
     245class ICustomUGApplicantEdit(ICustomUGApplicant):
    79246    """An undergraduate applicant interface for edit forms.
    80247
     
    88255    """
    89256
     257
     258    email = schema.ASCIILine(
     259        title = _(u'Email Address'),
     260        required = True,
     261        constraint=validate_email,
     262        )
     263    date_of_birth = FormattedDate(
     264        title = _(u'Date of Birth'),
     265        required = True,
     266        show_year = True,
     267        )
     268    jamb_reg_number = schema.TextLine(
     269        title = _(u'JAMB Registration Number'),
     270        required = True,
     271        )
     272    course1 = schema.Choice(
     273        title = _(u'1st Choice Course of Study'),
     274        source = AppCatCertificateSource(),
     275        required = True,
     276        )
     277
     278ICustomUGApplicantEdit[
     279    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
     280ICustomUGApplicantEdit[
     281    'email'].order =  ICustomUGApplicant['email'].order
     282ICustomUGApplicantEdit[
     283    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
     284ICustomUGApplicantEdit[
     285    'course1'].order =  ICustomUGApplicant['course1'].order
     286
    90287class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
    91288    """A postgraduate applicant interface for editing.
Note: See TracChangeset for help on using the changeset viewer.