Ignore:
Timestamp:
27 May 2012, 16:46:26 (12 years ago)
Author:
Henrik Bettermann
Message:

Reorganise UG interfaces. The order attribute can't be used for inserting new fields.

Add IPUTMEApplicantEdit.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/applicants
Files:
5 edited

Legend:

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

    r8204 r8530  
    2222from waeup.kofa.utils.helpers import attrs_to_fields
    2323from waeup.uniben.applicants.interfaces import(
    24     ICustomApplicant, IUGApplicantEdit, IPGApplicantEdit)
     24    ICustomApplicant, IUGApplicantEdit, IPGApplicantEdit, IPUTMEApplicantEdit)
    2525
    2626class CustomApplicant(Applicant):
    2727
    28     grok.implements(ICustomApplicant, IUGApplicantEdit, IPGApplicantEdit)
     28    grok.implements(ICustomApplicant, IUGApplicantEdit,
     29        IPGApplicantEdit, IPUTMEApplicantEdit)
    2930    grok.provides(ICustomApplicant)
    3031
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py

    r8526 r8530  
    3737from waeup.uniben.applicants.interfaces import (
    3838    IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit,
    39     ICustomApplicantOnlinePayment,
     39    ICustomApplicantOnlinePayment, IPUTMEApplicantEdit,
    4040    UG_OMIT_DISPLAY_FIELDS, PG_OMIT_DISPLAY_FIELDS,
    4141    UG_OMIT_MANAGE_FIELDS, PG_OMIT_MANAGE_FIELDS,
    42     UG_OMIT_EDIT_FIELDS, PG_OMIT_EDIT_FIELDS)
     42    UG_OMIT_EDIT_FIELDS, PG_OMIT_EDIT_FIELDS, PUTME_OMIT_EDIT_FIELDS)
    4343from waeup.uniben.interfaces import MessageFactory as _
    4444
     
    124124            for field in PG_OMIT_EDIT_FIELDS:
    125125                form_fields = form_fields.omit(field)
     126        elif target is not None and target.startswith('putme'):
     127            form_fields = grok.AutoFields(IPUTMEApplicantEdit)
     128            for field in PUTME_OMIT_EDIT_FIELDS:
     129                form_fields = form_fields.omit(field)
    126130        else:
    127131            form_fields = grok.AutoFields(IUGApplicantEdit)
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py

    r8519 r8530  
    2424    AppCatCertificateSource, CertificateSource)
    2525from waeup.kofa.schoolgrades import ResultEntryField
    26 from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab
    27 from waeup.kofa.schema import FormattedDate
    28 from waeup.kofa.students.vocabularies import nats_vocab
     26from waeup.kofa.interfaces import (
     27    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
     28from waeup.kofa.schema import FormattedDate, TextLineChoice
     29from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
     30from waeup.kofa.applicants.interfaces import contextual_reg_num_source
    2931from waeup.uniben.interfaces import (
    3032    LGASource, high_qual, high_grade, exam_types)
     
    3638UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted',
    3739    'student_id', 'screening_score', 'screening_venue')
     40PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + (
     41    'firstname', 'middlename', 'lastname', 'sex',
     42    'course1', 'lga', 'jambscore')
    3843
    3944PG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password')
    4045PG_OMIT_MANAGE_FIELDS = ()
    41 PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted',
     46PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + (
     47    'locked', 'course_admitted',
    4248    'student_id', 'screening_score', 'screening_venue')
    4349
     
    6066        required = False,
    6167        )
    62 
    63 # This ordering doesn't work properly.
    64 IUGApplicant[
    65     'nationality'].order =  IApplicantBaseData['sex'].order
    66 IUGApplicant[
    67     'lga'].order =  IUGApplicant['nationality'].order
    68 
     68    perm_address = schema.Text(
     69        title = _(u'Permanent Address'),
     70        required = False,
     71        )
     72    course1 = schema.Choice(
     73        title = _(u'1st Choice Course of Study'),
     74        source = AppCatCertificateSource(),
     75        required = True,
     76        )
     77    course2 = schema.Choice(
     78        title = _(u'2nd Choice Course of Study'),
     79        source = AppCatCertificateSource(),
     80        required = False,
     81        )
     82    jambscore = schema.Int(
     83        title = _(u'JAMB Score'),
     84        required = False,
     85        )
     86
     87
     88# More fields
     89
     90
     91    notice = schema.Text(
     92        title = _(u'Notice'),
     93        required = False,
     94        )
     95    screening_venue = schema.TextLine(
     96        title = _(u'Screening Venue'),
     97        required = False,
     98        )
     99    screening_score = schema.Int(
     100        title = _(u'Screening Score'),
     101        required = False,
     102        )
     103    student_id = schema.TextLine(
     104        title = _(u'Student Id'),
     105        required = False,
     106        readonly = False,
     107        )
     108    course_admitted = schema.Choice(
     109        title = _(u'Admitted Course of Study'),
     110        source = CertificateSource(),
     111        required = False,
     112        )
     113    locked = schema.Bool(
     114        title = _(u'Form locked'),
     115        default = False,
     116        )
    69117
    70118class IPGApplicant(IApplicantBaseData):
     
    227275        readonly = False,
    228276        )
     277    student_id = schema.TextLine(
     278        title = _(u'Student Id'),
     279        required = False,
     280        readonly = False,
     281        )
    229282    course_admitted = schema.Choice(
    230283        title = _(u'Admitted Course of Study'),
     
    233286        readonly = False,
    234287        )
    235 
    236 
    237 # This ordering doesn't work properly.
    238 IPGApplicant[
    239     'nationality'].order =  IApplicantBaseData['sex'].order
    240 IPGApplicant[
    241     'lga'].order =  IPGApplicant['nationality'].order
    242 IPGApplicant[
    243     'student_id'].order =  IPGApplicant['notice'].order
    244 
     288    locked = schema.Bool(
     289        title = _(u'Form locked'),
     290        default = False,
     291        )
    245292
    246293class ICustomApplicant(IUGApplicant,IPGApplicant):
     
    286333
    287334    """
     335
     336class IPUTMEApplicantEdit(IUGApplicant):
     337    """An undergraduate applicant interface for editing.
     338
     339    Here we can repeat the fields from base data and set the
     340    `required` and `readonly` attributes to True to further restrict
     341    the data access. Or we can allow only certain certificates to be
     342    selected by choosing the appropriate source.
     343
     344    We cannot omit fields here. This has to be done in the
     345    respective form page.
     346    """
     347    email = schema.ASCIILine(
     348        title = _(u'Email Address'),
     349        required = True,
     350        constraint=validate_email,
     351        )
     352
     353IPUTMEApplicantEdit[
     354    'email'].order =  IUGApplicant['email'].order
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests.py

    r8526 r8530  
    254254            'emp_reason,emp_start,employer,employer2,firstname,history,'
    255255            'hq_degree,hq_disc,hq_matric_no,hq_school,hq_session,hq_type,'
    256             'lastname,lga,locked,middlename,nationality,notice,nysc_lga,'
     256            'jambscore,lastname,lga,locked,middlename,nationality,notice,nysc_lga,'
    257257            'nysc_year,password,perm_address,phone,pp_school,presently_inst,'
    258             'reg_number,screening_score,screening_venue,sex,state,student_id'
     258            'reg_number,screening_score,screening_venue,sex,state,student_id,'
     259            'container_code'
    259260            in result)
    260261        self.assertTrue(
    261             'Application initialized by system\'],,,,,,,Tester,,0,M.,,'
     262            'Application initialized by system\'],,,,,,,,Tester,,0,M.,,'
    262263            '"Some notice\nin lines.",,,any password,,+234-123-12345,,,'
    263             '123456,98,Exam Room,f,initialized,' in result)
    264         return
     264            '123456,98,Exam Room,f,initialized,,dp2011' in result)
     265        return
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py

    r8526 r8530  
    5353        'form.nysc_year': _(u'NYSC Information'),
    5454        'form.employer': _(u'Employment History'),
     55        'form.jambscore': _(u'JAMB Data'),
    5556        'form.notice': _(u'Application Process Information'),
    5657        'form.pp_school': _(u'Post Primary School Qualification'),
Note: See TracChangeset for help on using the changeset viewer.