source: main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants/browser.py @ 16982

Last change on this file since 16982 was 10823, checked in by Henrik Bettermann, 11 years ago

Customize application slip.

  • Property svn:keywords set to Id
File size: 3.3 KB
RevLine 
[10770]1## $Id: browser.py 10823 2013-12-02 16:30:42Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""UI components for basic applicants and related components.
19"""
20import grok
[10800]21from hurry.workflow.interfaces import IWorkflowState
[10794]22from zope.formlib.textwidgets import BytesDisplayWidget
[10823]23from waeup.kofa.widgets.datewidget import (
24    FriendlyDateDisplayWidget, FriendlyDateDisplayWidget,)
[10770]25from waeup.kofa.applicants.browser import (
26    ApplicantRegistrationPage, ApplicantsContainerPage)
[10800]27from waeup.kofa.applicants.pdf import PDFApplicationSlip
[10794]28from kofacustom.ekodisco.applicants.interfaces import (
29    ICustomApplicant, ICustomApplicantEdit)
[10770]30from kofacustom.nigeria.applicants.browser import (
31    NigeriaApplicantDisplayFormPage,
[10788]32    ApplicantDisplayFormPage,
33    ApplicantManageFormPage,
34    ApplicantEditFormPage)
[10770]35
[10800]36
37from kofacustom.ekodisco.applicants.workflow import STARTED
38
[10770]39from kofacustom.ekodisco.interfaces import MessageFactory as _
40
[10788]41class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
42    """A display view for applicant data.
43    """
44    grok.template('applicantdisplaypage')
45
[10794]46    form_fields = grok.AutoFields(ICustomApplicant).omit(
[10788]47        'locked', 'course_admitted', 'password', 'suspended',
[10794]48        'course2', 'notice', 'student_id', 'sex')
[10788]49
[10794]50    form_fields['perm_address'].custom_widget = BytesDisplayWidget
51    form_fields['service_address'].custom_widget = BytesDisplayWidget
52
[10788]53class CustomApplicantManageFormPage(ApplicantManageFormPage):
54    """A full edit view for applicant data.
55    """
56    grok.template('applicanteditpage')
57
[10794]58    form_fields = grok.AutoFields(ICustomApplicant).omit(
59        'course2', 'notice', 'student_id', 'sex')
[10788]60    form_fields['applicant_id'].for_display = True
61
62class CustomApplicantEditFormPage(ApplicantEditFormPage):
63    """An applicant-centered edit view for applicant data.
64    """
65    grok.template('applicanteditpage')
66
[10794]67    form_fields = grok.AutoFields(ICustomApplicantEdit).omit(
[10788]68        'locked', 'course_admitted', 'student_id',
[10794]69        'suspended', 'course2', 'notice', 'sex'
[10788]70        )
71    form_fields['applicant_id'].for_display = True
72    form_fields['reg_number'].for_display = True
[10800]73
74    submit_state = STARTED
75
76    @property
77    def display_actions(self):
78        state = IWorkflowState(self.context).getState()
79        actions = [[],[]]
80        if state == STARTED:
81            actions = [[_('Save'), _('Final Submit')], []]
82        return actions
83
84class CustomPDFApplicationSlip(PDFApplicationSlip):
85    """Bypass NigeriaPDFApplicationSlip
[10823]86    """
87
88    form_fields =  grok.AutoFields(ICustomApplicant).omit(
89        'locked', 'course_admitted', 'suspended', 'sex', 'course2'
90        )
91    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
Note: See TracBrowser for help on using the repository browser.