Ignore:
Timestamp:
26 Jul 2012, 15:14:45 (12 years ago)
Author:
Henrik Bettermann
Message:

Since no interface has been further customized we do not need customized pages.

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

    r9056 r9057  
    1818"""UI components for basic applicants and related components.
    1919"""
    20 import grok
    21 from zope.component import getUtility
    22 from zope.i18n import translate
    23 from zope.formlib.textwidgets import BytesDisplayWidget
    24 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    25 from waeup.kofa.students.interfaces import IStudentsUtils
    26 from waeup.kofa.applicants.interfaces import (
    27     IApplicantRegisterUpdate, IApplicant, IApplicantEdit)
    28 from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
    29     ExportPDFPage,
    30     ApplicantManageFormPage, ApplicantEditFormPage,
    31     ApplicantRegistrationPage, ApplicantAddFormPage,
    32     OnlinePaymentDisplayFormPage, ApplicationFeePaymentAddPage,
    33     OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
    34     ApplicantBaseDisplayFormPage)
    35 from waeup.kofa.applicants.viewlets import (
    36     PaymentReceiptActionButton, PDFActionButton)
    37 from waeup.kofa.applicants.pdf import PDFApplicationSlip
    38 from waeup.uniben.applicants.interfaces import (
    39     ICustomPGApplicant, ICustomUGApplicant, ICustomPGApplicantEdit, ICustomUGApplicantEdit,
    40     ICustomApplicantOnlinePayment, IPUTMEApplicantEdit,
    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     )
    60 from waeup.uniben.interfaces import MessageFactory as _
     20from waeup.kofa.applicants.browser import ApplicantRegistrationPage
    6121
    62 class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
    63     """A breadcrumb for payments.
    64     """
    65     grok.context(ICustomApplicantOnlinePayment)
    66 
    67 class PaymentReceiptActionButton(PaymentReceiptActionButton):
    68     grok.order(4)
    69     grok.context(ICustomApplicantOnlinePayment)
    70 
    71 class PDFActionButton(PDFActionButton):
    72 
    73     @property
    74     def text(self):
    75         if getattr(self.context, 'result_uploaded', False):
    76             return _('Download result slip')
    77         return _('Download application slip')
    78 
    79 
    80 class 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
    106 
    107 class CustomPDFApplicationSlip(PDFApplicationSlip):
    108 
    109     def _reduced_slip(self):
    110         return getattr(self.context, 'result_uploaded', False)
    111 
    112     @property
    113     def note(self):
    114         target = getattr(self.context.__parent__, 'prefix', None)
    115         if target is not None and not target.startswith('pg') \
    116             and not self._reduced_slip():
    117             return _(u'<br /><br /><br />'
    118                       'Comfirm your exam venue 72 hours to the exam.')
    119         return
    120 
    121     @property
    122     def form_fields(self):
    123         target = getattr(self.context.__parent__, 'prefix', None)
    124         if target is not None and target.startswith('pg'):
    125             form_fields = grok.AutoFields(ICustomPGApplicant)
    126             for field in PG_OMIT_PDF_FIELDS:
    127                 form_fields = form_fields.omit(field)
    128         elif target is not None and target.startswith('putme'):
    129             form_fields = grok.AutoFields(ICustomUGApplicant)
    130             if self._reduced_slip():
    131                 for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
    132                     form_fields = form_fields.omit(field)
    133             else:
    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)
    148         if not getattr(self.context, 'student_id'):
    149             form_fields = form_fields.omit('student_id')
    150         return form_fields
    151 
    152 class CustomApplicantManageFormPage(ApplicantManageFormPage):
    153     """A full edit view for applicant data.
    154     """
    155    
    156     @property
    157     def form_fields(self):
    158         target = getattr(self.context.__parent__, 'prefix', None)
    159         if target is not None and target.startswith('pg'):
    160             form_fields = grok.AutoFields(ICustomPGApplicant)
    161             for field in PG_OMIT_MANAGE_FIELDS:
    162                 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)
    171         else:
    172             form_fields = grok.AutoFields(ICustomUGApplicant)
    173             for field in UG_OMIT_MANAGE_FIELDS:
    174                 form_fields = form_fields.omit(field)
    175         form_fields['student_id'].for_display = True
    176         form_fields['applicant_id'].for_display = True
    177         return form_fields
    178 
    179 class CustomApplicantEditFormPage(ApplicantEditFormPage):
    180     """An applicant-centered edit view for applicant data.
    181     """
    182 
    183     @property
    184     def form_fields(self):
    185         target = getattr(self.context.__parent__, 'prefix', None)
    186         if target is not None and target.startswith('pg'):
    187             form_fields = grok.AutoFields(ICustomPGApplicantEdit)
    188             for field in PG_OMIT_EDIT_FIELDS:
    189                 form_fields = form_fields.omit(field)
    190         elif target is not None and target.startswith('putme'):
    191             form_fields = grok.AutoFields(IPUTMEApplicantEdit)
    192             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:
    197                 form_fields = form_fields.omit(field)
    198         else:
    199             form_fields = grok.AutoFields(ICustomUGApplicantEdit)
    200             for field in UG_OMIT_EDIT_FIELDS:
    201                 form_fields = form_fields.omit(field)
    202         form_fields['applicant_id'].for_display = True
    203         form_fields['reg_number'].for_display = True
    204         return form_fields
    205 
    206 class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
    207     """ Page to view an online payment ticket
    208     """
    209     grok.context(ICustomApplicantOnlinePayment)
    210     # We temporarily omit r_company since this attribute was not set in 2012
    211     form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit(
    212         'ac', 'r_company')
    213     form_fields[
    214         'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    215     form_fields[
    216         'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    217 
    218 class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
    219     """Deliver a PDF slip of the context.
    220     """
    221     grok.context(ICustomApplicantOnlinePayment)
    222     # We temporarily omit r_company since this attribute was not set in 2012
    223     form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit(
    224         'ac', 'r_company')
    225     form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    226     form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    22722
    22823class CustomApplicantRegistrationPage(ApplicantRegistrationPage):
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py

    r9056 r9057  
    3636    INigeriaApplicantUpdateByRegNo,
    3737    IPUTMEApplicantEdit,
    38     UG_OMIT_DISPLAY_FIELDS,
    39     UG_OMIT_PDF_FIELDS,
    40     UG_OMIT_MANAGE_FIELDS,
    41     UG_OMIT_EDIT_FIELDS,
    42     PG_OMIT_DISPLAY_FIELDS,
    43     PG_OMIT_PDF_FIELDS,
    44     PG_OMIT_MANAGE_FIELDS,
    45     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,
    5638    )
    5739from waeup.uniben.interfaces import MessageFactory as _
Note: See TracChangeset for help on using the changeset viewer.