Ignore:
Timestamp:
26 Jul 2012, 06:58:38 (12 years ago)
Author:
Henrik Bettermann
Message:

Adjust browser pages to changes made in kofacustom.nigeria.

Remove customization only for extended LGASource.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py

    r8960 r9056  
    2121from zope.component import getUtility
    2222from zope.i18n import translate
     23from zope.formlib.textwidgets import BytesDisplayWidget
    2324from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2425from waeup.kofa.students.interfaces import IStudentsUtils
     
    3839    ICustomPGApplicant, ICustomUGApplicant, ICustomPGApplicantEdit, ICustomUGApplicantEdit,
    3940    ICustomApplicantOnlinePayment, IPUTMEApplicantEdit,
    40     UG_OMIT_DISPLAY_FIELDS, PG_OMIT_DISPLAY_FIELDS,
    41     UG_OMIT_PDF_FIELDS, PG_OMIT_PDF_FIELDS,
    42     UG_OMIT_MANAGE_FIELDS, PG_OMIT_MANAGE_FIELDS,
    43     UG_OMIT_EDIT_FIELDS, PG_OMIT_EDIT_FIELDS, PUTME_OMIT_EDIT_FIELDS,
    44     UG_OMIT_RESULT_SLIP_FIELDS)
     41    UG_OMIT_DISPLAY_FIELDS,
     42    UG_OMIT_PDF_FIELDS,
     43    UG_OMIT_MANAGE_FIELDS,
     44    UG_OMIT_EDIT_FIELDS,
     45    PG_OMIT_DISPLAY_FIELDS,
     46    PG_OMIT_PDF_FIELDS,
     47    PG_OMIT_MANAGE_FIELDS,
     48    PG_OMIT_EDIT_FIELDS,
     49    PUTME_OMIT_DISPLAY_FIELDS,
     50    PUTME_OMIT_PDF_FIELDS,
     51    PUTME_OMIT_MANAGE_FIELDS,
     52    PUTME_OMIT_EDIT_FIELDS,
     53    PUTME_OMIT_RESULT_SLIP_FIELDS,
     54    PUDE_OMIT_DISPLAY_FIELDS,
     55    PUDE_OMIT_PDF_FIELDS,
     56    PUDE_OMIT_MANAGE_FIELDS,
     57    PUDE_OMIT_EDIT_FIELDS,
     58    PUDE_OMIT_RESULT_SLIP_FIELDS,
     59    )
    4560from waeup.uniben.interfaces import MessageFactory as _
    4661
     
    6277        return _('Download application slip')
    6378
     79
     80class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
     81    """A display view for applicant data.
     82    """
     83
     84    @property
     85    def form_fields(self):
     86        target = getattr(self.context.__parent__, 'prefix', None)
     87        if target is not None and target.startswith('pg'):
     88            form_fields = grok.AutoFields(ICustomPGApplicant)
     89            for field in PG_OMIT_DISPLAY_FIELDS:
     90                form_fields = form_fields.omit(field)
     91        elif target is not None and target.startswith('putme'):
     92            form_fields = grok.AutoFields(ICustomUGApplicant)
     93            for field in PUTME_OMIT_DISPLAY_FIELDS:
     94                form_fields = form_fields.omit(field)
     95        elif target is not None and target.startswith('pude'):
     96            form_fields = grok.AutoFields(ICustomUGApplicant)
     97            for field in PUDE_OMIT_DISPLAY_FIELDS:
     98                form_fields = form_fields.omit(field)
     99        else:
     100            form_fields = grok.AutoFields(ICustomUGApplicant)
     101            for field in UG_OMIT_DISPLAY_FIELDS:
     102                form_fields = form_fields.omit(field)
     103        form_fields['perm_address'].custom_widget = BytesDisplayWidget
     104        form_fields['notice'].custom_widget = BytesDisplayWidget
     105        return form_fields
    64106
    65107class CustomPDFApplicationSlip(PDFApplicationSlip):
     
    84126            for field in PG_OMIT_PDF_FIELDS:
    85127                form_fields = form_fields.omit(field)
    86         else:
     128        elif target is not None and target.startswith('putme'):
    87129            form_fields = grok.AutoFields(ICustomUGApplicant)
    88130            if self._reduced_slip():
    89                 for field in UG_OMIT_RESULT_SLIP_FIELDS:
     131                for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
    90132                    form_fields = form_fields.omit(field)
    91133            else:
    92                 for field in UG_OMIT_PDF_FIELDS:
    93                     form_fields = form_fields.omit(field)
     134                for field in PUTME_OMIT_PDF_FIELDS:
     135                    form_fields = form_fields.omit(field)
     136        elif target is not None and target.startswith('pude'):
     137            form_fields = grok.AutoFields(ICustomUGApplicant)
     138            if self._reduced_slip():
     139                for field in PUDE_OMIT_RESULT_SLIP_FIELDS:
     140                    form_fields = form_fields.omit(field)
     141            else:
     142                for field in PUDE_OMIT_PDF_FIELDS:
     143                    form_fields = form_fields.omit(field)
     144        else:
     145            form_fields = grok.AutoFields(ICustomUGApplicant)
     146            for field in UG_OMIT_PDF_FIELDS:
     147                form_fields = form_fields.omit(field)
    94148        if not getattr(self.context, 'student_id'):
    95149            form_fields = form_fields.omit('student_id')
    96150        return form_fields
    97151
    98 class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
    99     """A display view for applicant data.
    100     """
    101 
    102     @property
    103     def form_fields(self):
    104         target = getattr(self.context.__parent__, 'prefix', None)
    105         if target is not None and target.startswith('pg'):
    106             form_fields = grok.AutoFields(ICustomPGApplicant)
    107             for field in PG_OMIT_DISPLAY_FIELDS:
    108                 form_fields = form_fields.omit(field)
    109         else:
    110             form_fields = grok.AutoFields(ICustomUGApplicant)
    111             for field in UG_OMIT_DISPLAY_FIELDS:
    112                 form_fields = form_fields.omit(field)
    113         return form_fields
    114 
    115152class CustomApplicantManageFormPage(ApplicantManageFormPage):
    116153    """A full edit view for applicant data.
     
    124161            for field in PG_OMIT_MANAGE_FIELDS:
    125162                form_fields = form_fields.omit(field)
     163        elif target is not None and target.startswith('putme'):
     164            form_fields = grok.AutoFields(ICustomUGApplicant)
     165            for field in PUTME_OMIT_MANAGE_FIELDS:
     166                form_fields = form_fields.omit(field)
     167        elif target is not None and target.startswith('pude'):
     168            form_fields = grok.AutoFields(ICustomUGApplicant)
     169            for field in PUDE_OMIT_MANAGE_FIELDS:
     170                form_fields = form_fields.omit(field)
    126171        else:
    127172            form_fields = grok.AutoFields(ICustomUGApplicant)
     
    146191            form_fields = grok.AutoFields(IPUTMEApplicantEdit)
    147192            for field in PUTME_OMIT_EDIT_FIELDS:
     193                form_fields = form_fields.omit(field)
     194        elif target is not None and target.startswith('pude'):
     195            form_fields = grok.AutoFields(ICustomUGApplicant)
     196            for field in PUDE_OMIT_EDIT_FIELDS:
    148197                form_fields = form_fields.omit(field)
    149198        else:
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py

    r9006 r9056  
    4040    UG_OMIT_MANAGE_FIELDS,
    4141    UG_OMIT_EDIT_FIELDS,
    42     PUTME_OMIT_EDIT_FIELDS,
    43     UG_OMIT_RESULT_SLIP_FIELDS,
    4442    PG_OMIT_DISPLAY_FIELDS,
    4543    PG_OMIT_PDF_FIELDS,
    4644    PG_OMIT_MANAGE_FIELDS,
    4745    PG_OMIT_EDIT_FIELDS,
     46    PUTME_OMIT_DISPLAY_FIELDS,
     47    PUTME_OMIT_PDF_FIELDS,
     48    PUTME_OMIT_MANAGE_FIELDS,
     49    PUTME_OMIT_EDIT_FIELDS,
     50    PUTME_OMIT_RESULT_SLIP_FIELDS,
     51    PUDE_OMIT_DISPLAY_FIELDS,
     52    PUDE_OMIT_PDF_FIELDS,
     53    PUDE_OMIT_MANAGE_FIELDS,
     54    PUDE_OMIT_EDIT_FIELDS,
     55    PUDE_OMIT_RESULT_SLIP_FIELDS,
    4856    )
    4957from waeup.uniben.interfaces import MessageFactory as _
    5058from waeup.uniben.payments.interfaces import ICustomOnlinePayment
    51 
    52 ############################################################
    53 # Use former lgas for Uniben. Must be removed after application.
    54 from waeup.uniben.applicants.lgas import LGAS
    55 class LGASource(LGASource):
    56     """A source for school subjects used in exam documentation.
    57     """
    58     lga_dict = dict(LGAS)
    59 ############################################################
    6059
    6160class ICustomUGApplicant(INigeriaUGApplicant):
     
    6766    """
    6867
    69     nationality = schema.Choice(
    70         source = nats_vocab,
    71         title = _(u'Nationality'),
    72         required = False,
    73         )
    74     lga = schema.Choice(
    75         source = LGASource(),
    76         title = _(u'State/LGA (Nigerians only)'),
    77         required = False,
    78         )
    79     perm_address = schema.Text(
    80         title = _(u'Permanent Address'),
    81         required = False,
    82         )
    83     course1 = schema.Choice(
    84         title = _(u'1st Choice Course of Study'),
    85         source = AppCatCertificateSource(),
    86         required = True,
    87         )
    88     course2 = schema.Choice(
    89         title = _(u'2nd Choice Course of Study'),
    90         source = AppCatCertificateSource(),
    91         required = False,
    92         )
    93     jamb_subjects = schema.Text(
    94         title = _(u'Subjects and Scores'),
    95         required = False,
    96         )
    97     jamb_score = schema.Int(
    98         title = _(u'Total Score'),
    99         required = False,
    100         )
    101     notice = schema.Text(
    102         title = _(u'Notice'),
    103         required = False,
    104         )
    105     screening_venue = schema.TextLine(
    106         title = _(u'Screening Venue'),
    107         required = False,
    108         )
    109     screening_date = schema.TextLine(
    110         title = _(u'Screening Date'),
    111         required = False,
    112         )
    113     screening_score = schema.Int(
    114         title = _(u'Screening Score (%)'),
    115         required = False,
    116         )
    117     aggregate = schema.Int(
    118         title = _(u'Aggregate Score (%)'),
    119         description = _(u'(average of relative JAMB and PUTME scores)'),
    120         required = False,
    121         )
    122     result_uploaded = schema.Bool(
    123         title = _(u'Result uploaded'),
    124         default = False,
    125         )
    126     student_id = schema.TextLine(
    127         title = _(u'Student Id'),
    128         required = False,
    129         readonly = False,
    130         )
    131     course_admitted = schema.Choice(
    132         title = _(u'Admitted Course of Study'),
    133         source = CertificateSource(),
    134         required = False,
    135         )
    136     locked = schema.Bool(
    137         title = _(u'Form locked'),
    138         default = False,
    139         )
    140 
    14168class ICustomPGApplicant(INigeriaPGApplicant):
    14269    """A postgraduate applicant.
     
    14774    """
    14875
    149     nationality = schema.Choice(
    150         source = nats_vocab,
    151         title = _(u'Nationality'),
    152         required = False,
    153         )
    154     lga = schema.Choice(
    155         source = LGASource(),
    156         title = _(u'State/LGA (Nigerians only)'),
    157         required = False,
    158         )
    159     perm_address = schema.Text(
    160         title = _(u'Permanent Address'),
    161         required = False,
    162         )
    163     course1 = schema.Choice(
    164         title = _(u'1st Choice Course of Study'),
    165         source = AppCatCertificateSource(),
    166         required = True,
    167         )
    168     course2 = schema.Choice(
    169         title = _(u'2nd Choice Course of Study'),
    170         source = AppCatCertificateSource(),
    171         required = False,
    172         )
    173     hq_type = schema.Choice(
    174         title = _(u'Qualification Obtained'),
    175         required = False,
    176         readonly = False,
    177         vocabulary = high_qual,
    178         )
    179     hq_matric_no = schema.TextLine(
    180         title = _(u'Former Matric Number'),
    181         required = False,
    182         readonly = False,
    183         )
    184     hq_degree = schema.Choice(
    185         title = _(u'Class of Degree'),
    186         required = False,
    187         readonly = False,
    188         vocabulary = high_grade,
    189         )
    190     hq_school = schema.TextLine(
    191         title = _(u'Institution Attended'),
    192         required = False,
    193         readonly = False,
    194         )
    195     hq_session = schema.TextLine(
    196         title = _(u'Years Attended'),
    197         required = False,
    198         readonly = False,
    199         )
    200     hq_disc = schema.TextLine(
    201         title = _(u'Discipline'),
    202         required = False,
    203         readonly = False,
    204         )
    205     pp_school = schema.Choice(
    206         title = _(u'Qualification Obtained'),
    207         required = False,
    208         readonly = False,
    209         vocabulary = exam_types,
    210         )
    211     #presently = schema.Bool(
    212     #    title = _(u'Attending'),
    213     #    required = False,
    214     #    readonly = False,
    215     #    )
    216     presently_inst = schema.TextLine(
    217         title = _(u'If yes, name of institution'),
    218         required = False,
    219         readonly = False,
    220         )
    221     nysc_year = schema.Int(
    222         title = _(u'Nysc Year'),
    223         required = False,
    224         readonly = False,
    225         )
    226     nysc_lga = schema.Choice(
    227         source = LGASource(),
    228         title = _(u'Nysc Location'),
    229         required = False,
    230         )
    231     employer = schema.TextLine(
    232         title = _(u'Employer'),
    233         required = False,
    234         readonly = False,
    235         )
    236     emp_position = schema.TextLine(
    237         title = _(u'Employer Position'),
    238         required = False,
    239         readonly = False,
    240         )
    241     emp_start = FormattedDate(
    242         title = _(u'Start Date'),
    243         required = False,
    244         readonly = False,
    245         show_year = True,
    246         )
    247     emp_end = FormattedDate(
    248         title = _(u'End Date'),
    249         required = False,
    250         readonly = False,
    251         show_year = True,
    252         )
    253     emp_reason = schema.TextLine(
    254         title = _(u'Reason for Leaving'),
    255         required = False,
    256         readonly = False,
    257         )
    258     employer2 = schema.TextLine(
    259         title = _(u'2nd Employer'),
    260         required = False,
    261         readonly = False,
    262         )
    263     emp2_position = schema.TextLine(
    264         title = _(u'2nd Employer Position'),
    265         required = False,
    266         readonly = False,
    267         )
    268     emp2_start = FormattedDate(
    269         title = _(u'Start Date'),
    270         required = False,
    271         readonly = False,
    272         show_year = True,
    273         )
    274     emp2_end = FormattedDate(
    275         title = _(u'End Date'),
    276         required = False,
    277         readonly = False,
    278         show_year = True,
    279         )
    280     emp2_reason = schema.TextLine(
    281         title = _(u'Reason for Leaving'),
    282         required = False,
    283         readonly = False,
    284         )
    285     notice = schema.Text(
    286         title = _(u'Notice'),
    287         required = False,
    288         readonly = False,
    289         )
    290     student_id = schema.TextLine(
    291         title = _(u'Student Id'),
    292         required = False,
    293         readonly = False,
    294         )
    295     course_admitted = schema.Choice(
    296         title = _(u'Admitted Course of Study'),
    297         source = CertificateSource(),
    298         required = False,
    299         readonly = False,
    300         )
    301     locked = schema.Bool(
    302         title = _(u'Form locked'),
    303         default = False,
    304         )
    30576
    30677class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
     
    32394        """
    32495
    325 class ICustomUGApplicantEdit(ICustomUGApplicant):
     96class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
    32697    """An undergraduate applicant interface for edit forms.
    32798
     
    335106    """
    336107
    337     email = schema.ASCIILine(
    338         title = _(u'Email Address'),
    339         required = True,
    340         constraint=validate_email,
    341         )
    342     date_of_birth = FormattedDate(
    343         title = _(u'Date of Birth'),
    344         required = True,
    345         show_year = True,
    346         )
    347 
    348 ICustomUGApplicantEdit[
    349     'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
    350 ICustomUGApplicantEdit[
    351     'email'].order =  ICustomUGApplicant['email'].order
    352 
    353 class ICustomPGApplicantEdit(ICustomPGApplicant):
     108class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
    354109    """A postgraduate applicant interface for editing.
    355110
     
    363118    """
    364119
    365     email = schema.ASCIILine(
    366         title = _(u'Email Address'),
    367         required = True,
    368         constraint=validate_email,
    369         )
    370     date_of_birth = FormattedDate(
    371         title = _(u'Date of Birth'),
    372         required = True,
    373         show_year = True,
    374         )
    375 
    376 ICustomPGApplicantEdit[
    377     'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
    378 ICustomPGApplicantEdit[
    379     'email'].order =  ICustomPGApplicant['email'].order
    380 
    381120class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
    382121    """An applicant payment via payment gateways.
     
    384123    """
    385124
    386 class IPUTMEApplicantEdit(ICustomUGApplicant):
     125class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
    387126    """An undergraduate applicant interface for editing.
    388127
     
    395134    respective form page.
    396135    """
    397     email = schema.ASCIILine(
    398         title = _(u'Email Address'),
    399         required = True,
    400         constraint=validate_email,
    401         )
    402     date_of_birth = FormattedDate(
    403         title = _(u'Date of Birth'),
    404         required = True,
    405         show_year = True,
    406         )
    407136
    408 IPUTMEApplicantEdit[
    409     'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
    410 IPUTMEApplicantEdit[
    411     'email'].order =  ICustomUGApplicant['email'].order
    412 
    413 class ICustomApplicantUpdateByRegNo(ICustomApplicant):
     137class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
    414138    """Representation of an applicant.
    415139
     
    417141    the applicant object.
    418142    """
    419     reg_number = schema.TextLine(
    420         title = u'Registration Number',
    421         required = False,
    422         )
Note: See TracChangeset for help on using the changeset viewer.