Ignore:
Timestamp:
7 Jul 2012, 10:37:30 (12 years ago)
Author:
Henrik Bettermann
Message:

Use applicants components from kofacustom.nigeria. Since we do not customize interfaces again, there is no need to customize UI components, except CustomApplicantEditFormPage?.

Location:
main/waeup.aaue/trunk/src/waeup/aaue
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue

  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/browser.py

    r8840 r8931  
    1919"""
    2020import grok
    21 from zope.component import getUtility
    22 from zope.i18n import translate
    23 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    24 from waeup.kofa.students.interfaces import IStudentsUtils
    25 from waeup.kofa.applicants.interfaces import (
    26     IApplicantRegisterUpdate, IApplicant, IApplicantEdit)
    27 from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
    28     ExportPDFPage,
    29     ApplicantManageFormPage, ApplicantEditFormPage,
    30     ApplicantRegistrationPage, ApplicantAddFormPage,
    31     OnlinePaymentDisplayFormPage, ApplicationFeePaymentAddPage,
    32     OnlinePaymentBreadcrumb, ExportPDFPaymentSlipPage,
    33     ApplicantBaseDisplayFormPage)
    34 from waeup.kofa.applicants.viewlets import (
    35     PaymentReceiptActionButton, PDFActionButton)
    36 from waeup.kofa.applicants.pdf import PDFApplicationSlip
     21from kofacustom.nigeria.applicants.browser import  NigeriaApplicantEditFormPage
    3722from waeup.aaue.applicants.interfaces import (
    38     IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit,
    39     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,
     23    ICustomPGApplicantEdit, ICustomUGApplicantEdit,
     24    IPUTMEApplicantEdit,
    4325    UG_OMIT_EDIT_FIELDS, PG_OMIT_EDIT_FIELDS, PUTME_OMIT_EDIT_FIELDS,
    44     UG_OMIT_RESULT_SLIP_FIELDS)
    45 from waeup.aaue.interfaces import MessageFactory as _
    46 
    47 class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb):
    48     """A breadcrumb for payments.
    49     """
    50     grok.context(ICustomApplicantOnlinePayment)
    51 
    52 class PaymentReceiptActionButton(PaymentReceiptActionButton):
    53     grok.order(4)
    54     grok.context(ICustomApplicantOnlinePayment)
    55 
    56 class PDFActionButton(PDFActionButton):
    57 
    58     @property
    59     def text(self):
    60         if getattr(self.context, 'result_uploaded', False):
    61             return _('Download result slip')
    62         return _('Download application slip')
     26    )
    6327
    6428
    65 class CustomPDFApplicationSlip(PDFApplicationSlip):
    66 
    67     def _reduced_slip(self):
    68         return getattr(self.context, 'result_uploaded', False)
    69 
    70     @property
    71     def note(self):
    72         target = getattr(self.context.__parent__, 'prefix', None)
    73         if target is not None and not target.startswith('pg') \
    74             and not self._reduced_slip():
    75             return _(u'<br /><br /><br />'
    76                       'Comfirm your exam venue 72 hours to the exam.')
    77         return
    78 
    79     @property
    80     def form_fields(self):
    81         target = getattr(self.context.__parent__, 'prefix', None)
    82         if target is not None and target.startswith('pg'):
    83             form_fields = grok.AutoFields(IPGApplicant)
    84             for field in PG_OMIT_PDF_FIELDS:
    85                 form_fields = form_fields.omit(field)
    86         else:
    87             form_fields = grok.AutoFields(IUGApplicant)
    88             if self._reduced_slip():
    89                 for field in UG_OMIT_RESULT_SLIP_FIELDS:
    90                     form_fields = form_fields.omit(field)
    91             else:
    92                 for field in UG_OMIT_PDF_FIELDS:
    93                     form_fields = form_fields.omit(field)
    94         if not getattr(self.context, 'student_id'):
    95             form_fields = form_fields.omit('student_id')
    96         return form_fields
    97 
    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(IPGApplicant)
    107             for field in PG_OMIT_DISPLAY_FIELDS:
    108                 form_fields = form_fields.omit(field)
    109         else:
    110             form_fields = grok.AutoFields(IUGApplicant)
    111             for field in UG_OMIT_DISPLAY_FIELDS:
    112                 form_fields = form_fields.omit(field)
    113         return form_fields
    114 
    115 class CustomApplicantManageFormPage(ApplicantManageFormPage):
    116     """A full edit view for applicant data.
    117     """
    118    
    119     @property
    120     def form_fields(self):
    121         target = getattr(self.context.__parent__, 'prefix', None)
    122         if target is not None and target.startswith('pg'):
    123             form_fields = grok.AutoFields(IPGApplicant)
    124             for field in PG_OMIT_MANAGE_FIELDS:
    125                 form_fields = form_fields.omit(field)
    126         else:
    127             form_fields = grok.AutoFields(IUGApplicant)
    128             for field in UG_OMIT_MANAGE_FIELDS:
    129                 form_fields = form_fields.omit(field)
    130         form_fields['student_id'].for_display = True
    131         form_fields['applicant_id'].for_display = True
    132         return form_fields
    133 
    134 class CustomApplicantEditFormPage(ApplicantEditFormPage):
     29class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
    13530    """An applicant-centered edit view for applicant data.
    13631    """
     
    14035        target = getattr(self.context.__parent__, 'prefix', None)
    14136        if target is not None and target.startswith('pg'):
    142             form_fields = grok.AutoFields(IPGApplicantEdit)
     37            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
    14338            for field in PG_OMIT_EDIT_FIELDS:
    14439                form_fields = form_fields.omit(field)
     
    14843                form_fields = form_fields.omit(field)
    14944        else:
    150             form_fields = grok.AutoFields(IUGApplicantEdit)
     45            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
    15146            for field in UG_OMIT_EDIT_FIELDS:
    15247                form_fields = form_fields.omit(field)
     
    15449        form_fields['reg_number'].for_display = True
    15550        return form_fields
    156 
    157 class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage):
    158     """ Page to view an online payment ticket
    159     """
    160     grok.context(ICustomApplicantOnlinePayment)
    161     form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
    162     form_fields[
    163         'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    164     form_fields[
    165         'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    166 
    167 class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
    168     """ Page to add an online payment ticket
    169     """
    170     factory = u'waeup.CustomApplicantOnlinePayment'
    171 
    172 class CustomExportPDFPaymentSlipPage(ExportPDFPaymentSlipPage):
    173     """Deliver a PDF slip of the context.
    174     """
    175     grok.context(ICustomApplicantOnlinePayment)
    176     form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit('ac')
    177     form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    178     form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    179 
    180 class CustomApplicantRegistrationPage(ApplicantRegistrationPage):
    181     """Captcha'd registration page for applicants.
    182     """
    183 
    184     #def _redirect(self, email, password, applicant_id):
    185     #    # Forward email and credentials to landing page.
    186     #    self.redirect(self.url(self.context, 'registration_complete',
    187     #        data = dict(email=email, password=password,
    188     #        applicant_id=applicant_id)))
    189     #    return
Note: See TracChangeset for help on using the changeset viewer.