source: main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants/applicant.py @ 10821

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

Show proper workflow states.

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1## $Id: applicant.py 10815 2013-11-29 10:17:00Z 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
19import grok
20from zope.interface import implementedBy
21from waeup.kofa.applicants.applicant import ApplicantFactory
22from waeup.kofa.utils.helpers import attrs_to_fields
23from waeup.kofa.applicants.applicant import Applicant
24from kofacustom.ekodisco.applicants.interfaces import(
25    ICustomApplicant, ICustomApplicantEdit)
26from kofacustom.ekodisco.applicants.workflow import application_states_dict
27
28class CustomApplicant(Applicant):
29
30    grok.implements(ICustomApplicant, ICustomApplicantEdit)
31    grok.provides(ICustomApplicant)
32
33    create_names = [
34        'firstname', 'middlename', 'lastname',
35        'date_of_birth',
36        'email', 'phone', 'perm_address'
37        ]
38
39    @property
40    def translated_state(self):
41        return application_states_dict[self.state]
42
43    def _setStudyCourseAttributes(self, studycourse):
44        #studycourse.entry_mode = self.course_admitted.study_mode
45        #studycourse.current_level = self.course_admitted.start_level
46        studycourse.service_address = self.service_address
47        studycourse.certificate = self.course_admitted
48        studycourse.entry_session = self.__parent__.year
49        studycourse.current_session = self.__parent__.year
50        return
51
52# Set all attributes of CustomApplicant required in ICustomApplicant as field
53# properties. Doing this, we do not have to set initial attributes
54# ourselves and as a bonus we get free validation when an attribute is
55# set.
56CustomApplicant = attrs_to_fields(CustomApplicant)
57
58class CustomApplicantFactory(ApplicantFactory):
59    """A factory for customized applicants.
60    """
61
62    def __call__(self, *args, **kw):
63        return CustomApplicant()
64
65    def getInterfaces(self):
66        return implementedBy(CustomApplicant)
Note: See TracBrowser for help on using the repository browser.