source: main/waeup.sirp/branches/ulif-images/src/waeup/sirp/jambtables/applicants.py @ 10690

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

Commit local changes (work inprogress)

File size: 5.3 KB
RevLine 
[5272]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
[5318]23from zope.component.interfaces import IFactory
[5479]24from zope.interface import implementedBy
[5272]25from zope.schema.fieldproperty import FieldProperty
26from waeup.sirp.interfaces import IWAeUPSIRPPluggable
27from waeup.sirp.jambtables.interfaces import (
[5483]28    IResultEntry, IApplicant, IApplicantContainer, IApplicantPDEEditData
[5272]29    )
[5530]30from waeup.sirp.widgets.passportwidget import PassportImage
[5272]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):
[5530]40    # class Applicant(grok.Model):
[5483]41    grok.implements(IApplicant, IApplicantPDEEditData)
42    grok.provides(IApplicant)
[5272]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
[5530]109class ApplicantTraverser(grok.Traverser):
110    grok.context(IApplicant)
111    def traverse(self, name):
112        passport_filename = self.context.passport.filename
113        print "FILENAME: ", passport_filename
114        if name == passport_filename:
115            print "USE FILE", self.context.passport
116            return self.context.passport
117        if name == 'passport.jpg':
118            if self.context.passport is not None:
119                print "PP: ", self.context.passport
120                return self.context.passport
121            return PassportImage(None)
122
[5318]123class ApplicantFactory(grok.GlobalUtility):
124    """A factory for faculty containers.
125    """
126    grok.implements(IFactory)
127    grok.name(u'waeup.Applicant')
128    title = u"Create a new applicant.",
129    description = u"This factory instantiates new applicant instances."
130
131    def __call__(self, *args, **kw):
132        return Applicant()
133
134    def getInterfaces(self):
[5479]135        return implementedBy(Applicant)
[5318]136
137       
[5272]138class ApplicantContainer(grok.Container):
139    grok.implements(IApplicantContainer)
140
[5420]141class ApplicantsPlugin(grok.GlobalUtility):
142    """A WAeUPSIRPPlugin that creates an applications folder in portal.
143    """
[5272]144    grok.name('applications')
145    grok.implements(IWAeUPSIRPPluggable)
146
147    def setup(self, site, name, logger):
148        site['applications'] = ApplicantContainer()
149        logger.info('Installed application container.')
150        return
151
152    def update(self, site, name, logger):
153        if not 'applications' in site.keys():
154            logger.info('Updating site at %s. Installing applications.' % (
155                    site,))
156            self.setup(site, name, logger)
157        else:
158            logger.info(
159                'ApplicantsPlugin: Updating site at %s: Nothing to do.' % (
160                    site, ))
161        return
Note: See TracBrowser for help on using the repository browser.