Ignore:
Timestamp:
7 Mar 2024, 12:57:10 (7 months ago)
Author:
Henrik Bettermann
Message:

Simplify application

File:
1 edited

Legend:

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

    r17689 r17711  
    1919"""
    2020import grok
     21from zope.formlib.textwidgets import BytesDisplayWidget
     22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2123from waeup.kofa.applicants.browser import (
    2224    ApplicantRegistrationPage, ApplicantsContainerPage)
    23 from kofacustom.nigeria.applicants.browser import (
    24     NigeriaApplicantDisplayFormPage,
    25     NigeriaApplicantManageFormPage,
    26     NigeriaApplicantEditFormPage,
    27     NigeriaPDFApplicationSlip)
     25from waeup.kofa.applicants.browser import (
     26    ApplicantDisplayFormPage,
     27    ApplicantManageFormPage,
     28    ApplicantEditFormPage,
     29    ApplicantRegistrationPage,
     30    OnlinePaymentDisplayFormPage,
     31    OnlinePaymentBreadcrumb,
     32    ExportPDFPaymentSlipPage,
     33    )
     34from waeup.kofa.applicants.pdf import PDFApplicationSlip
    2835
    29 from kofacustom.nigeria.applicants.interfaces import (
    30     INigeriaPGApplicant, INigeriaUGApplicant,
    31     INigeriaPGApplicantEdit, INigeriaUGApplicantEdit,
    32     INigeriaApplicantOnlinePayment,
    33     UG_OMIT_DISPLAY_FIELDS,
    34     UG_OMIT_PDF_FIELDS,
    35     UG_OMIT_MANAGE_FIELDS,
    36     UG_OMIT_EDIT_FIELDS,
    37     PG_OMIT_DISPLAY_FIELDS,
    38     PG_OMIT_PDF_FIELDS,
    39     PG_OMIT_MANAGE_FIELDS,
    40     PG_OMIT_EDIT_FIELDS,
    41     )
    4236from kofacustom.udss.applicants.interfaces import (
    43     ICustomPGApplicant, ICustomUGApplicant, ICustomApplicant,
    44     ICustomPGApplicantEdit, ICustomUGApplicantEdit,
     37    ICustomUGApplicant,
     38    ICustomApplicant,
     39    ICustomUGApplicantEdit,
    4540    ICustomApplicantOnlinePayment,
    4641    )
     
    4843from kofacustom.udss.interfaces import MessageFactory as _
    4944
    50 class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
     45OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted',
     46    'result_uploaded', 'suspended', 'special_application',)
     47
     48UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
     49    'programme_type', 'course1', 'course2', 'course_admitted')
     50UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',)
     51UG_OMIT_MANAGE_FIELDS = (
     52    'special_application',
     53    'programme_type', 'course1', 'course2', 'course_admitted')
     54UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
     55    'student_id',
     56    'notice',
     57    'jamb_age',
     58    'jamb_subjects',
     59    'jamb_score',
     60    'jamb_reg_number',
     61    'aggregate')
     62
     63class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
     64    """A display view for applicant data.
     65    """
     66
     67    def _not_paid(self):
     68        return self.context.state in ('initialized', 'started',)
     69
     70    @property
     71    def form_fields(self):
     72        form_fields = grok.AutoFields(ICustomUGApplicant)
     73        for field in UG_OMIT_PDF_FIELDS:
     74            form_fields = form_fields.omit(field)
     75        form_fields['notice'].custom_widget = BytesDisplayWidget
     76        if not getattr(self.context, 'student_id'):
     77            form_fields = form_fields.omit('student_id')
     78        return form_fields
     79
     80class CustomPDFApplicationSlip(PDFApplicationSlip):
     81
     82    def _addLoginInformation(self):
     83        """ We do no longer render login information on
     84        pdf application slips.
     85        """
     86        return
     87
     88    def _reduced_slip(self):
     89        return getattr(self.context, 'result_uploaded', False)
     90
     91    @property
     92    def form_fields(self):
     93        form_fields = grok.AutoFields(ICustomUGApplicant)
     94        for field in UG_OMIT_PDF_FIELDS:
     95            form_fields = form_fields.omit(field)
     96        if not getattr(self.context, 'student_id'):
     97            form_fields = form_fields.omit('student_id')
     98        return form_fields
     99
     100class CustomApplicantManageFormPage(ApplicantManageFormPage):
     101    """A full edit view for applicant data.
     102    """
     103
     104    @property
     105    def form_fields(self):
     106        form_fields = grok.AutoFields(ICustomUGApplicant)
     107        for field in UG_OMIT_MANAGE_FIELDS:
     108            form_fields = form_fields.omit(field)
     109        form_fields['student_id'].for_display = True
     110        form_fields['applicant_id'].for_display = True
     111        return form_fields
     112
     113class CustomApplicantEditFormPage(ApplicantEditFormPage):
    51114    """An applicant-centered edit view for applicant data.
    52115    """
     116
     117    @property
     118    def form_fields(self):
     119        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     120        for field in UG_OMIT_EDIT_FIELDS:
     121            form_fields = form_fields.omit(field)
     122        form_fields['applicant_id'].for_display = True
     123        form_fields['reg_number'].for_display = True
     124        return form_fields
    53125
    54126    def unremovable(self, ticket):
Note: See TracChangeset for help on using the changeset viewer.