source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicants.py @ 5941

Last change on this file since 5941 was 5941, checked in by uli, 14 years ago

Introduce locked-attribute for applicants to control workflow a bit.

File size: 4.8 KB
Line 
1##
2## applicants.py
3## Login : <uli@pu.smp.net>
4## Started on  Fri Jul 16 11:46:55 2010 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2010 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22import grok
23from zope.component.interfaces import IFactory
24from zope.interface import implementedBy
25from zope.schema.fieldproperty import FieldProperty
26from waeup.sirp.image.schema import ImageFile
27from waeup.sirp.interfaces import IWAeUPSIRPPluggable
28from waeup.sirp.applicants.interfaces import (
29    IResultEntry, IApplicant, IApplicantPDEEditData
30    )
31
32class ResultEntry(grok.Context):
33    grok.implements(IResultEntry)
34
35    def __init__(self, subject=None, score=None):
36        self.subject = subject
37        self.score = score
38   
39class Applicant(grok.Context):
40    # class Applicant(grok.Model):
41    grok.implements(IApplicant, IApplicantPDEEditData)
42    grok.provides(IApplicant)
43
44    fst_sit_results = FieldProperty(IApplicant['fst_sit_results'])
45    locked = False
46   
47    def __init__(self):
48        self.reg_no = None
49        self.access_code = None
50        self.serial = None
51        self.course1 = None
52        self.course2 = None
53        self.course3 = None
54        self.firstname = None
55        self.middlenames = None
56        self.lastname = None
57        self.jamb_age = None
58        self.date_of_birth = None
59        self.jamb_state = None
60        self.jamb_lga = None
61        self.lga = None
62        self.sex = None
63        self.email = None
64        self.phone = None
65        self.passport = None
66        self.aos = None
67        self.subj1 = None
68        self.subj2 = None
69        self.subj3 = None
70        self.hq_matric_no = None
71        self.hq_type = None
72        self.hq_grade = None
73        self.hq_school = None
74        self.hq_session = None
75        self.hq_disc = None
76        self.fst_sit_fname = None
77        self.fst_sit_no = None
78        self.fst_sit_date = None
79        self.fst_sit_type = None
80        #self.fst_sit_results = []
81        self.fst_sit_results = None
82        #self.fst_sit_results = ResultEntry()
83        self.scd_sit_fname = None
84        self.scd_sit_no = None
85        self.scd_sit_date = None
86        self.scd_sit_type = None
87        self.scd_sit_results = None
88        self.eng_score = None
89        self.subj1score = None
90        self.subj2score = None
91        self.subj3score = None
92        self.application_date = None
93        self.status = None
94        self.screening_date = None
95        self.screening_type = None
96        self.screening_score = None
97        self.screening_venue = None
98        self.total_score = None
99        self.course_admitted = None
100        self.department = None
101        self.faculty = None
102        self.entry_session = None
103        self.notice = None
104        self.student_id = None
105        self.import_record_no = None
106        self.imported_by = None
107        self.import_date = None
108        self.import_from = None
109
110class ApplicantTraverser(grok.Traverser):
111    """Get image of the context applicant.
112
113    Each applicant can provide a passport photograph which will be
114    returned by this traverser if:
115
116    - we request the exact filename of the picture or
117
118    - ask for a picture named 'passport.jpg'.
119
120    If no picture was stored yet, we get a placeholder image when
121    asking for `passport.jpg`.
122
123    If none of the above applies, we return ``None``, most probably
124    resulting a :exc:`NotFound` exception.
125   
126    """
127    grok.context(IApplicant)
128    def traverse(self, name):
129        passport_filename = getattr(self.context.passport, 'filename', None)
130        if name == passport_filename:
131            return self.context.passport
132        if name == 'passport.jpg':
133            if self.context.passport is not None:
134                return self.context.passport
135            return ImageFile()
136        return
137
138class ApplicantFactory(grok.GlobalUtility):
139    """A factory for faculty containers.
140    """
141    grok.implements(IFactory)
142    grok.name(u'waeup.Applicant')
143    title = u"Create a new applicant.",
144    description = u"This factory instantiates new applicant instances."
145
146    def __call__(self, *args, **kw):
147        return Applicant()
148
149    def getInterfaces(self):
150        return implementedBy(Applicant)
Note: See TracBrowser for help on using the repository browser.