Ignore:
Timestamp:
26 Apr 2015, 08:59:40 (10 years ago)
Author:
Henrik Bettermann
Message:

Initialize customization of forms.

Location:
main/kofacustom.wdu/trunk/src/kofacustom/wdu/applicants
Files:
2 edited

Legend:

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

    r11940 r12885  
    1919"""
    2020import grok
    21 from waeup.kofa.applicants.browser import (
    22     ApplicantRegistrationPage, ApplicantsContainerPage)
     21from zope.component import getUtility
     22from zope.i18n import translate
     23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     24from zope.formlib.textwidgets import BytesDisplayWidget
     25from waeup.kofa.students.interfaces import IStudentsUtils
    2326from kofacustom.nigeria.applicants.browser import (
    2427    NigeriaApplicantDisplayFormPage,
     28    NigeriaApplicantManageFormPage,
     29    NigeriaApplicantEditFormPage,
    2530    NigeriaPDFApplicationSlip)
     31
     32from kofacustom.nigeria.applicants.interfaces import (
     33    UG_OMIT_DISPLAY_FIELDS,
     34    UG_OMIT_PDF_FIELDS,
     35    UG_OMIT_MANAGE_FIELDS,
     36    UG_OMIT_EDIT_FIELDS,
     37    PUTME_OMIT_DISPLAY_FIELDS,
     38    PUTME_OMIT_PDF_FIELDS,
     39    PUTME_OMIT_MANAGE_FIELDS,
     40    PUTME_OMIT_EDIT_FIELDS,
     41    PUTME_OMIT_RESULT_SLIP_FIELDS,
     42    PUDE_OMIT_DISPLAY_FIELDS,
     43    PUDE_OMIT_PDF_FIELDS,
     44    PUDE_OMIT_MANAGE_FIELDS,
     45    PUDE_OMIT_EDIT_FIELDS,
     46    PUDE_OMIT_RESULT_SLIP_FIELDS,
     47    )
     48
     49from kofacustom.wdu.applicants.interfaces import (
     50    ICustomUGApplicant,
     51    ICustomUGApplicantEdit,
     52    ICustomPUTMEApplicantEdit,
     53    )
    2654
    2755from kofacustom.wdu.interfaces import MessageFactory as _
    2856
     57
     58class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
     59    """A display view for applicant data.
     60    """
     61
     62    @property
     63    def form_fields(self):
     64        if self.target is not None and self.target.startswith('putme'):
     65            form_fields = grok.AutoFields(ICustomUGApplicant)
     66            for field in PUTME_OMIT_DISPLAY_FIELDS:
     67                form_fields = form_fields.omit(field)
     68        elif self.target is not None and self.target.startswith('pude'):
     69            form_fields = grok.AutoFields(ICustomUGApplicant)
     70            for field in PUDE_OMIT_DISPLAY_FIELDS:
     71                form_fields = form_fields.omit(field)
     72        else:
     73            form_fields = grok.AutoFields(ICustomUGApplicant)
     74            for field in UG_OMIT_DISPLAY_FIELDS:
     75                form_fields = form_fields.omit(field)
     76        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
     77        form_fields['notice'].custom_widget = BytesDisplayWidget
     78        if not getattr(self.context, 'student_id'):
     79            form_fields = form_fields.omit('student_id')
     80        if not getattr(self.context, 'screening_score'):
     81            form_fields = form_fields.omit('screening_score')
     82        if not getattr(self.context, 'screening_venue') or self._not_paid():
     83            form_fields = form_fields.omit('screening_venue')
     84        if not getattr(self.context, 'screening_date') or self._not_paid():
     85            form_fields = form_fields.omit('screening_date')
     86        return form_fields
     87
     88class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
     89
     90    @property
     91    def form_fields(self):
     92        if self.target is not None and self.target.startswith('putme'):
     93            form_fields = grok.AutoFields(ICustomUGApplicant)
     94            if self._reduced_slip():
     95                for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
     96                    form_fields = form_fields.omit(field)
     97            else:
     98                for field in PUTME_OMIT_PDF_FIELDS:
     99                    form_fields = form_fields.omit(field)
     100        elif self.target is not None and self.target.startswith('pude'):
     101            form_fields = grok.AutoFields(ICustomUGApplicant)
     102            if self._reduced_slip():
     103                for field in PUDE_OMIT_RESULT_SLIP_FIELDS:
     104                    form_fields = form_fields.omit(field)
     105            else:
     106                for field in PUDE_OMIT_PDF_FIELDS:
     107                    form_fields = form_fields.omit(field)
     108        else:
     109            form_fields = grok.AutoFields(ICustomUGApplicant)
     110            for field in UG_OMIT_PDF_FIELDS:
     111                form_fields = form_fields.omit(field)
     112        if not getattr(self.context, 'student_id'):
     113            form_fields = form_fields.omit('student_id')
     114        if not getattr(self.context, 'screening_score'):
     115            form_fields = form_fields.omit('screening_score')
     116        if not getattr(self.context, 'screening_venue'):
     117            form_fields = form_fields.omit('screening_venue')
     118        if not getattr(self.context, 'screening_date'):
     119            form_fields = form_fields.omit('screening_date')
     120        return form_fields
     121
     122class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
     123    """A full edit view for applicant data.
     124    """
     125
     126    @property
     127    def form_fields(self):
     128        if self.target is not None and self.target.startswith('putme'):
     129            form_fields = grok.AutoFields(ICustomUGApplicant)
     130            for field in PUTME_OMIT_MANAGE_FIELDS:
     131                form_fields = form_fields.omit(field)
     132        elif self.target is not None and self.target.startswith('pude'):
     133            form_fields = grok.AutoFields(ICustomUGApplicant)
     134            for field in PUDE_OMIT_MANAGE_FIELDS:
     135                form_fields = form_fields.omit(field)
     136        else:
     137            form_fields = grok.AutoFields(ICustomUGApplicant)
     138            for field in UG_OMIT_MANAGE_FIELDS:
     139                form_fields = form_fields.omit(field)
     140        form_fields['student_id'].for_display = True
     141        form_fields['applicant_id'].for_display = True
     142        return form_fields
     143
     144class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
     145    """An applicant-centered edit view for applicant data.
     146    """
     147
     148    @property
     149    def form_fields(self):
     150        if self.target is not None and self.target.startswith('putme'):
     151            form_fields = grok.AutoFields(ICustomPUTMEApplicantEdit)
     152            for field in PUTME_OMIT_EDIT_FIELDS:
     153                form_fields = form_fields.omit(field)
     154        elif self.target is not None and self.target.startswith('pude'):
     155            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     156            for field in PUDE_OMIT_EDIT_FIELDS:
     157                form_fields = form_fields.omit(field)
     158        else:
     159            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     160            for field in UG_OMIT_EDIT_FIELDS:
     161                form_fields = form_fields.omit(field)
     162        form_fields['applicant_id'].for_display = True
     163        form_fields['reg_number'].for_display = True
     164        return form_fields
  • main/kofacustom.wdu/trunk/src/kofacustom/wdu/applicants/interfaces.py

    r11940 r12885  
    105105    """
    106106
    107 class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
     107class ICustomPUTMEApplicantEdit(IPUTMEApplicantEdit):
    108108    """An undergraduate applicant interface for editing.
    109109
Note: See TracChangeset for help on using the changeset viewer.