Changeset 5319 for main


Ignore:
Timestamp:
27 Jul 2010, 08:18:51 (14 years ago)
Author:
uli
Message:
  • Add a source for gender field.
  • Add applicant interfaces designed for use with special cases (importing PDE data, applicant editing, etc.).
  • Clean up some fields.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/jambtables/interfaces.py

    r5271 r5319  
    2323"""
    2424from waeup.sirp.interfaces import IWAeUPObject
     25from zc.sourcefactory.basic import BasicSourceFactory
    2526from zope.interface import Interface
    2627from zope import schema
    2728
     29class GenderSource(BasicSourceFactory):
     30    """A gender source delivers basically a mapping
     31       ``{'m': 'male', 'f': 'female'}``
     32
     33       Using a source, we make sure that the tokens (which are
     34       stored/expected for instance from CSV files) are something one
     35       can expect and not cryptic IntIDs.
     36    """
     37    def getValues(self):
     38        return ['m', 'f']
     39
     40    def getToken(self, value):
     41        return value[0].lower()
     42       
     43    def getTitle(self, value):
     44        if value == 'm':
     45            return 'male'
     46        if value == 'f':
     47            return 'female'
    2848
    2949class IJAMBDataTable(IWAeUPObject):
     
    7797        required=False,
    7898        )
    79        
    80 class IApplicant(IWAeUPObject):
    81     """An applicant.
    82 
    83 
     99
     100class IApplicantBaseData(IWAeUPObject):
     101    """The data for an applicant.
     102
     103    This is a base interface with no field (except ``reg_no``)
     104    required. For use with importers, forms, etc., please use one of
     105    the derived interfaces below, which set more fields to required
     106    state, depending on use-case.
    84107    """
    85108    reg_no = schema.TextLine(
     
    88111    access_code = schema.TextLine(
    89112        title = u'Access Code',
     113        required = False,
    90114        )
    91115    serial = schema.TextLine(
     
    95119    course1 = schema.TextLine(
    96120        title = u'1st Choice Course of Study',
     121        required = False,
    97122        )
    98123    course2 = schema.TextLine(
     
    106131    firstname = schema.TextLine(
    107132        title = u'First Name',
     133        required = False,
    108134        )
    109135    middlenames = schema.TextLine(
    110136        title = u'Middle Names',
     137        required = False,
    111138        )
    112139    lastname = schema.TextLine(
    113140        title = u'Surname/Full Name',
     141        required = False,
    114142        )
    115143    jamb_age = schema.Int(
     
    119147    date_of_birth = schema.Date(
    120148        title = u'Date of Birth',
     149        required = False,
    121150        )
    122151    jamb_state = schema.TextLine(
    123152        title = u'State (provided by JAMB)',
     153        required = False,
    124154        )
    125155    jamb_lga = schema.TextLine(
    126156        title = u'LGA (provided by JAMB)',
     157        required = False,
    127158        )
    128159    lga = schema.TextLine(
    129160        # XXX: should be choice
    130161        title = u'State/LGA (confirmed by applicant)',
     162        required = False,
    131163        )
    132164    sex = schema.Choice(
    133165        title = u'Sex',
    134         values = [u'female', u'male']
     166        source = GenderSource(),
     167        default = u'm',
     168        required = False,
    135169        )
    136170    email = schema.TextLine(
     
    145179        title = u'Passport Photograph',
    146180        default = True,
     181        required = False,
    147182        )
    148183    aos = schema.TextLine(
     
    198233    fst_sit_fname = schema.TextLine(
    199234        title = u'Full Name',
     235        required = False,
    200236        )
    201237    fst_sit_no = schema.TextLine(
     
    212248        required = False,
    213249        )
    214     #fst_sit_results = schema.TextLine(
    215     #    # XXX: Should be nested list of choices
    216     #    title = u'Results',
    217     #    required = False,
    218     #    )
    219    
    220250    fst_sit_results = schema.List(
    221251        title = u'Results',
     
    224254            title = u'Entries',
    225255            schema = IResultEntry,
     256            required = False,
    226257            )
    227258        )
    228    
    229     #fst_sit_results = schema.Object(
    230     #    title = u'Results',
    231     #    required = False,
    232     #    schema = IResultEntry,
    233     #    )
    234 
    235     #fst_sit_results = schema.Dict(
    236     #    title = u'Results',
    237     #    required = False,
    238     #    key_type = schema.TextLine(
    239     #        title = u'Subject',
    240     #        ),
    241     #    value_type = schema.TextLine(
    242     #        title = u'Score',
    243     #        ),
    244     #    )
    245 
    246     #
    247     # Second sitting data
    248     #
    249259    scd_sit_fname = schema.TextLine(
    250260        title = u'Full Name',
     261        required = False,
    251262        )
    252263    scd_sit_no = schema.TextLine(
     
    294305    application_date = schema.Date(
    295306        title = u'Application Date',
     307        required = False,
    296308        )
    297309    status = schema.TextLine(
    298310        # XXX: should be 'status' type
    299311        title = u'Application Status',
     312        required = False,
    300313        )
    301314    screening_date = schema.Date(
    302315        title = u'Screening Date',
     316        required = False,
    303317        )
    304318    screening_type = schema.TextLine(
    305319        # XXX: schould be choice
    306320        title = u'Screening Type',
     321        required = False,
    307322        )
    308323    screening_score = schema.TextLine(
    309324        title = u'Screening Score',
     325        required = False,
    310326        )
    311327    screening_venue = schema.TextLine(
     
    336352        # XXX: should have sensible default: upcoming session
    337353        title = u'Entry Session',
    338         required = True,
     354        required = False,
    339355        )
    340356    notice = schema.Text(
     
    348364    import_record_no = schema.TextLine(
    349365        title = u'Import Record No.',
     366        required = False,
    350367        )
    351368    imported_by = schema.TextLine(
    352369        title = u'Imported By',
     370        required = False,
    353371        )
    354372    import_date = schema.Datetime(
    355373        title = u'Import Date',
     374        required = False,
    356375        )
    357376    import_from = schema.TextLine(
    358377        title = u'Import Source',
    359         )
    360 
     378        required = False,
     379        )
     380
     381   
     382class IApplicant(IApplicantBaseData):
     383    """An applicant.
     384
     385    This is basically the applicant base data. Here we repeat the
     386    fields from base data only with the `required` attribute of
     387    required attributes set to True (which is the default).
     388    """
     389    access_code = schema.TextLine(
     390        title = u'Access Code',
     391        )
     392    course1 = schema.TextLine(
     393        title = u'1st Choice Course of Study',
     394        )
     395    firstname = schema.TextLine(
     396        title = u'First Name',
     397        )
     398    middlenames = schema.TextLine(
     399        title = u'Middle Names',
     400        )
     401    lastname = schema.TextLine(
     402        title = u'Surname/Full Name',
     403        )
     404    date_of_birth = schema.Date(
     405        title = u'Date of Birth',
     406        )
     407    jamb_state = schema.TextLine(
     408        title = u'State (provided by JAMB)',
     409        )
     410    jamb_lga = schema.TextLine(
     411        title = u'LGA (provided by JAMB)',
     412        )
     413    lga = schema.TextLine(
     414        # XXX: should be choice
     415        title = u'State/LGA (confirmed by applicant)',
     416        )
     417    sex = schema.Choice(
     418        title = u'Sex',
     419        source = GenderSource(),
     420        default = u'm',
     421        )
     422    passport = schema.Bool(
     423        title = u'Passport Photograph',
     424        default = True,
     425        )
     426    #
     427    # Higher Educational Data
     428    #
     429
     430    #
     431    # First sitting data
     432    #
     433    fst_sit_fname = schema.TextLine(
     434        title = u'Full Name',
     435        )
     436
     437    #
     438    # Second sitting data
     439    #
     440    scd_sit_fname = schema.TextLine(
     441        title = u'Full Name',
     442        )
     443    #
     444    # JAMB scores
     445    #
     446   
     447    #
     448    # Application Data
     449    #
     450    application_date = schema.Date(
     451        title = u'Application Date',
     452        )
     453    status = schema.TextLine(
     454        # XXX: should be 'status' type
     455        title = u'Application Status',
     456        )
     457    screening_date = schema.Date(
     458        title = u'Screening Date',
     459        )
     460    screening_type = schema.TextLine(
     461        # XXX: schould be choice
     462        title = u'Screening Type',
     463        )
     464    screening_score = schema.TextLine(
     465        title = u'Screening Score',
     466        )
     467    entry_session = schema.TextLine(
     468        # XXX: should be choice
     469        # XXX: should have sensible default: upcoming session
     470        title = u'Entry Session',
     471        )
     472    import_record_no = schema.TextLine(
     473        title = u'Import Record No.',
     474        )
     475    imported_by = schema.TextLine(
     476        title = u'Imported By',
     477        )
     478    import_date = schema.Datetime(
     479        title = u'Import Date',
     480        )
     481    import_from = schema.TextLine(
     482        title = u'Import Source',
     483        )
     484
     485class IApplicantPDEImportData(IApplicantBaseData):
     486    """Data for applicants, that passed PDE screening.
     487
     488    This data set should be suitable for imports from JAMB tables. It
     489    is also basicall the basic applicant data from
     490    :class:`IApplicantBaseData` only with the required fields set.
     491
     492    """
     493    firstname = schema.TextLine(
     494        title = u'First Name',
     495        required = True,
     496        )
     497    middlenames = schema.TextLine(
     498        title = u'Middle Names',
     499        required = True,
     500        )
     501    lastname = schema.TextLine(
     502        title = u'Surname/Full Name',
     503        required = True,
     504        )
     505    date_of_birth = schema.Date(
     506        title = u'Date of Birth',
     507        required = True,
     508        )
     509    jamb_state = schema.TextLine(
     510        title = u'State (provided by JAMB)',
     511        required = True,
     512        )
     513    jamb_lga = schema.TextLine(
     514        title = u'LGA (provided by JAMB)',
     515        required = True,
     516        )
     517    course1 = schema.TextLine(
     518        title = u'1st Choice Course of Study',
     519        required = True,
     520        )
     521    screening_date = schema.Date(
     522        title = u'Screening Date',
     523        required = True,
     524        )
     525    screening_type = schema.TextLine(
     526        # XXX: schould be choice
     527        title = u'Screening Type',
     528        required = True,
     529        )
     530    screening_venue = schema.TextLine(
     531        title = u'Screening Venue',
     532        required = True,
     533        )
     534    entry_session = schema.TextLine(
     535        # XXX: should be choice
     536        # XXX: should have sensible default: upcoming session
     537        title = u'Entry Session',
     538        required = True,
     539        )
     540   
    361541class IApplicantContainer(IWAeUPObject):
    362542    """A container for applicants.
Note: See TracChangeset for help on using the changeset viewer.