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.

File:
1 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:
Note: See TracChangeset for help on using the changeset viewer.