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

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

Clean up.

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