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

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

Customize application slip.

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
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
21from hurry.workflow.interfaces import IWorkflowState
22from zope.formlib.textwidgets import BytesDisplayWidget
23from waeup.kofa.widgets.datewidget import (
24    FriendlyDateDisplayWidget, FriendlyDateDisplayWidget,)
25from waeup.kofa.applicants.browser import (
26    ApplicantRegistrationPage, ApplicantsContainerPage)
27from waeup.kofa.applicants.pdf import PDFApplicationSlip
28from kofacustom.ekodisco.applicants.interfaces import (
29    ICustomApplicant, ICustomApplicantEdit)
30from kofacustom.nigeria.applicants.browser import (
31    NigeriaApplicantDisplayFormPage,
32    ApplicantDisplayFormPage,
33    ApplicantManageFormPage,
34    ApplicantEditFormPage)
35
36
37from kofacustom.ekodisco.applicants.workflow import STARTED
38
39from kofacustom.ekodisco.interfaces import MessageFactory as _
40
41class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
42    """A display view for applicant data.
43    """
44    grok.template('applicantdisplaypage')
45
46    form_fields = grok.AutoFields(ICustomApplicant).omit(
47        'locked', 'course_admitted', 'password', 'suspended',
48        'course2', 'notice', 'student_id', 'sex')
49
50    form_fields['perm_address'].custom_widget = BytesDisplayWidget
51    form_fields['service_address'].custom_widget = BytesDisplayWidget
52
53class CustomApplicantManageFormPage(ApplicantManageFormPage):
54    """A full edit view for applicant data.
55    """
56    grok.template('applicanteditpage')
57
58    form_fields = grok.AutoFields(ICustomApplicant).omit(
59        'course2', 'notice', 'student_id', 'sex')
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
67    form_fields = grok.AutoFields(ICustomApplicantEdit).omit(
68        'locked', 'course_admitted', 'student_id',
69        'suspended', 'course2', 'notice', 'sex'
70        )
71    form_fields['applicant_id'].for_display = True
72    form_fields['reg_number'].for_display = True
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
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.