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

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

Add a confirm_passport attribute to applicants and reflect that change in form.

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    confirm_passport = False
47   
48    def __init__(self):
49        self.reg_no = None
50        self.access_code = None
51        self.serial = None
52        self.course1 = None
53        self.course2 = None
54        self.course3 = None
55        self.firstname = None
56        self.middlenames = None
57        self.lastname = None
58        self.jamb_age = None
59        self.date_of_birth = None
60        self.jamb_state = None
61        self.jamb_lga = None
62        self.lga = None
63        self.sex = None
64        self.email = None
65        self.phone = None
66        self.passport = None
67        self.aos = None
68        self.subj1 = None
69        self.subj2 = None
70        self.subj3 = None
71        self.hq_matric_no = None
72        self.hq_type = None
73        self.hq_grade = None
74        self.hq_school = None
75        self.hq_session = None
76        self.hq_disc = None
77        self.fst_sit_fname = None
78        self.fst_sit_no = None
79        self.fst_sit_date = None
80        self.fst_sit_type = None
81        #self.fst_sit_results = []
82        self.fst_sit_results = None
83        #self.fst_sit_results = ResultEntry()
84        self.scd_sit_fname = None
85        self.scd_sit_no = None
86        self.scd_sit_date = None
87        self.scd_sit_type = None
88        self.scd_sit_results = None
89        self.eng_score = None
90        self.subj1score = None
91        self.subj2score = None
92        self.subj3score = None
93        self.application_date = None
94        self.status = None
95        self.screening_date = None
96        self.screening_type = None
97        self.screening_score = None
98        self.screening_venue = None
99        self.total_score = None
100        self.course_admitted = None
101        self.department = None
102        self.faculty = None
103        self.entry_session = None
104        self.notice = None
105        self.student_id = None
106        self.import_record_no = None
107        self.imported_by = None
108        self.import_date = None
109        self.import_from = None
110
111class ApplicantTraverser(grok.Traverser):
112    """Get image of the context applicant.
113
114    Each applicant can provide a passport photograph which will be
115    returned by this traverser if:
116
117    - we request the exact filename of the picture or
118
119    - ask for a picture named 'passport.jpg'.
120
121    If no picture was stored yet, we get a placeholder image when
122    asking for `passport.jpg`.
123
124    If none of the above applies, we return ``None``, most probably
125    resulting a :exc:`NotFound` exception.
126   
127    """
128    grok.context(IApplicant)
129    def traverse(self, name):
130        passport_filename = getattr(self.context.passport, 'filename', None)
131        if name == passport_filename:
132            return self.context.passport
133        if name == 'passport.jpg':
134            if self.context.passport is not None:
135                return self.context.passport
136            return ImageFile()
137        return
138
139class ApplicantFactory(grok.GlobalUtility):
140    """A factory for faculty containers.
141    """
142    grok.implements(IFactory)
143    grok.name(u'waeup.Applicant')
144    title = u"Create a new applicant.",
145    description = u"This factory instantiates new applicant instances."
146
147    def __call__(self, *args, **kw):
148        return Applicant()
149
150    def getInterfaces(self):
151        return implementedBy(Applicant)
Note: See TracBrowser for help on using the repository browser.