Ignore:
Timestamp:
26 Apr 2011, 11:17:38 (14 years ago)
Author:
uli
Message:
  • Fix applicant/passport-image traverser to return a placeholder image if in doubt.
  • Set Applicant attributes via FieldProperties?. No need to set initial values manually any more.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicants.py

    r5952 r5983  
    2424from zope.interface import implementedBy
    2525from zope.schema.fieldproperty import FieldProperty
    26 from waeup.sirp.image.schema import ImageFile
    2726from waeup.sirp.interfaces import IWAeUPSIRPPluggable
    2827from waeup.sirp.applicants.interfaces import (
    29     IResultEntry, IApplicant, IApplicantPDEEditData
     28    IResultEntry, IApplicant, IApplicantPDEEditData,
     29    DEFAULT_PASSPORT_IMAGE_MALE,
    3030    )
    3131
     
    3636        self.subject = subject
    3737        self.score = score
    38    
     38
    3939class Applicant(grok.Context):
    40     # class Applicant(grok.Model):
    4140    grok.implements(IApplicant, IApplicantPDEEditData)
    4241    grok.provides(IApplicant)
    4342
    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
     43# Set all attributes of Applicant required in IApplicant as field
     44# properties. Doing this, we do not have to set initial attributes
     45# ourselves and as a bonus we get free validation when an attribute is
     46# set.
     47for field_name in list(IApplicant):
     48    setattr(Applicant, field_name, FieldProperty(IApplicant[field_name]))
    11049
    11150class ApplicantTraverser(grok.Traverser):
     
    13473            if self.context.passport is not None:
    13574                return self.context.passport
    136             return ImageFile()
     75            return DEFAULT_PASSPORT_IMAGE_MALE
    13776        return
    13877
Note: See TracChangeset for help on using the changeset viewer.