source: main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/applicant.py @ 17747

Last change on this file since 17747 was 17370, checked in by Henrik Bettermann, 21 months ago

Implement transcript application.

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1## $Id: applicant.py 17370 2023-03-29 13:15:45Z 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.interfaces import IObjectHistory
24from waeup.kofa.applicants.workflow import (
25    application_states_dict, ADMITTED, NOT_ADMITTED, CREATED)
26from kofacustom.nigeria.applicants.applicant import NigeriaApplicant
27from kofacustom.edopoly.applicants.interfaces import(
28    ICustomApplicant, ICustomUGApplicantEdit, ICustomPGApplicantEdit,
29    IPUTMEApplicantEdit, ICustomSpecialApplicant, ITranscriptApplicant)
30
31class CustomApplicant(NigeriaApplicant):
32
33    grok.implements(ICustomApplicant, ICustomUGApplicantEdit,
34        ICustomPGApplicantEdit, IPUTMEApplicantEdit, ICustomSpecialApplicant,
35        ITranscriptApplicant)
36    grok.provides(ICustomApplicant)
37
38    def admchecking_fee_paid(self):
39        # We don't charge if admission checking fee is not set.
40        session = str(self.__parent__.year)
41        try:
42            session_config = grok.getSite()['configuration'][session]
43        except KeyError:
44            return True
45        if session_config.admchecking_fee == 0:
46            return True
47        for key in self.keys():
48            ticket = self[key]
49            if ticket.p_state == 'paid' and \
50                ticket.p_category == 'admission_checking':
51                return True
52        return False
53
54    @property
55    def history(self):
56        # We do not provide a history
57        if self.state in (ADMITTED, NOT_ADMITTED, CREATED) \
58            and not self.admchecking_fee_paid():
59            return
60        history = IObjectHistory(self)
61        return history
62
63    @property
64    def translated_state(self):
65        if self.state in (ADMITTED, NOT_ADMITTED, CREATED) \
66            and not self.admchecking_fee_paid():
67            return
68        try:
69            state = application_states_dict[self.state]
70        except LookupError:  # in unit tests
71            return
72        return state
73
74# Set all attributes of CustomApplicant required in ICustomApplicant as field
75# properties. Doing this, we do not have to set initial attributes
76# ourselves and as a bonus we get free validation when an attribute is
77# set.
78CustomApplicant = attrs_to_fields(CustomApplicant)
79
80class CustomApplicantFactory(ApplicantFactory):
81    """A factory for customized applicants.
82    """
83
84    def __call__(self, *args, **kw):
85        return CustomApplicant()
86
87    def getInterfaces(self):
88        return implementedBy(CustomApplicant)
Note: See TracBrowser for help on using the repository browser.