Changeset 10794 for main


Ignore:
Timestamp:
23 Nov 2013, 08:24:15 (11 years ago)
Author:
Henrik Bettermann
Message:

Customize applicant interfaces and browser components.

Location:
main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants/applicant.py

    r10770 r10794  
    2121from waeup.kofa.applicants.applicant import ApplicantFactory
    2222from waeup.kofa.utils.helpers import attrs_to_fields
    23 from kofacustom.nigeria.applicants.applicant import NigeriaApplicant
     23from waeup.kofa.applicants.applicant import Applicant
    2424from kofacustom.ekodisco.applicants.interfaces import(
    25     ICustomApplicant, ICustomUGApplicantEdit, ICustomPGApplicantEdit, IPUTMEApplicantEdit)
     25    ICustomApplicant, ICustomApplicantEdit)
    2626
    27 class CustomApplicant(NigeriaApplicant):
     27class CustomApplicant(Applicant):
    2828
    29     grok.implements(ICustomApplicant, ICustomUGApplicantEdit,
    30         ICustomPGApplicantEdit, IPUTMEApplicantEdit)
     29    grok.implements(ICustomApplicant, ICustomApplicantEdit)
    3130    grok.provides(ICustomApplicant)
    3231
  • main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants/browser.py

    r10788 r10794  
    1919"""
    2020import grok
     21from zope.formlib.textwidgets import BytesDisplayWidget
    2122from waeup.kofa.applicants.browser import (
    2223    ApplicantRegistrationPage, ApplicantsContainerPage)
    23 from waeup.kofa.applicants.interfaces import IApplicant, IApplicantEdit
     24from kofacustom.ekodisco.applicants.interfaces import (
     25    ICustomApplicant, ICustomApplicantEdit)
    2426from kofacustom.nigeria.applicants.browser import (
    2527    NigeriaApplicantDisplayFormPage,
     
    3638    grok.template('applicantdisplaypage')
    3739
    38     form_fields = grok.AutoFields(IApplicant).omit(
     40    form_fields = grok.AutoFields(ICustomApplicant).omit(
    3941        'locked', 'course_admitted', 'password', 'suspended',
    40         'course2', 'notice', 'student_id')
     42        'course2', 'notice', 'student_id', 'sex')
     43
     44    form_fields['perm_address'].custom_widget = BytesDisplayWidget
     45    form_fields['service_address'].custom_widget = BytesDisplayWidget
    4146
    4247class CustomApplicantManageFormPage(ApplicantManageFormPage):
     
    4550    grok.template('applicanteditpage')
    4651
    47     form_fields = grok.AutoFields(IApplicant).omit('course2', 'notice', 'student_id')
     52    form_fields = grok.AutoFields(ICustomApplicant).omit(
     53        'course2', 'notice', 'student_id', 'sex')
    4854    form_fields['applicant_id'].for_display = True
    4955
     
    5359    grok.template('applicanteditpage')
    5460
    55     form_fields = grok.AutoFields(IApplicantEdit).omit(
     61    form_fields = grok.AutoFields(ICustomApplicantEdit).omit(
    5662        'locked', 'course_admitted', 'student_id',
    57         'suspended', 'course2', 'notice'
     63        'suspended', 'course2', 'notice', 'sex'
    5864        )
    5965    form_fields['applicant_id'].for_display = True
  • main/kofacustom.ekodisco/trunk/src/kofacustom/ekodisco/applicants/interfaces.py

    r10770 r10794  
    2828from waeup.kofa.schema import FormattedDate, TextLineChoice
    2929from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
    30 from waeup.kofa.applicants.interfaces import contextual_reg_num_source
     30from waeup.kofa.applicants.interfaces import (
     31    contextual_reg_num_source,
     32    IApplicant, IApplicantEdit, IApplicantUpdateByRegNo)
    3133from kofacustom.nigeria.applicants.interfaces import (
    3234    LGASource, high_qual, high_grade, exam_types,
    33     INigeriaUGApplicant, INigeriaPGApplicant,
    3435    INigeriaApplicantOnlinePayment,
    35     INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
    36     INigeriaApplicantUpdateByRegNo,
    37     IPUTMEApplicantEdit,
    3836    )
    3937from kofacustom.ekodisco.interfaces import MessageFactory as _
    4038from kofacustom.ekodisco.payments.interfaces import ICustomOnlinePayment
    4139
    42 class ICustomUGApplicant(INigeriaUGApplicant):
    43     """An undergraduate applicant.
     40class ICustomApplicant(IApplicant):
     41    """An applicant.
    4442
    45     This interface defines the least common multiple of all fields
    46     in ug application forms. In customized forms, fields can be excluded by
    47     adding them to the UG_OMIT* tuples.
    4843    """
    4944
    50 class ICustomPGApplicant(INigeriaPGApplicant):
    51     """A postgraduate applicant.
     45    course1 = schema.Choice(
     46        title = _(u'Desired Contract'),
     47        source = AppCatCertificateSource(),
     48        required = False,
     49        )
     50    course2 = schema.Choice(
     51        title = _(u'Not applicable'),
     52        source = AppCatCertificateSource(),
     53        required = False,
     54        )
     55    course_admitted = schema.Choice(
     56        title = _(u'Assigned Contract'),
     57        source = CertificateSource(),
     58        required = False,
     59        readonly = False,
     60        )
     61    perm_address = schema.Text(
     62        title = _(u'Customer Address'),
     63        required = False,
     64        )
     65    service_address = schema.Text(
     66        title = _(u'Service Address'),
     67        required = False,
     68        )
    5269
    53     This interface defines the least common multiple of all fields
    54     in pg application forms. In customized forms, fields can be excluded by
    55     adding them to the PG_OMIT* tuples.
    56     """
    57 
    58 
    59 class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
    60     """An interface for both types of applicants.
    61 
    62     Attention: The ICustomPGApplicant field seetings will be overwritten
    63     by ICustomPGApplicant field settings. If a field is defined
    64     in both interfaces zope.schema validates only against the
    65     constraints in ICustomUGApplicant. This does not affect the forms
    66     since they are build on either ICustomUGApplicant or ICustomPGApplicant.
    67     """
    68 
    69     def writeLogMessage(view, comment):
    70         """Adds an INFO message to the log file
    71         """
    72 
    73     def createStudent():
    74         """Create a student object from applicant data
    75         and copy applicant object.
    76         """
    77 
    78 class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
    79     """An undergraduate applicant interface for edit forms.
     70class ICustomApplicantEdit(IApplicantEdit):
     71    """An applicant interface for edit forms.
    8072
    8173    Here we can repeat the fields from base data and set the
     
    8880    """
    8981
    90 class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
    91     """A postgraduate applicant interface for editing.
    92 
    93     Here we can repeat the fields from base data and set the
    94     `required` and `readonly` attributes to True to further restrict
    95     the data access. Or we can allow only certain certificates to be
    96     selected by choosing the appropriate source.
    97 
    98     We cannot omit fields here. This has to be done in the
    99     respective form page.
    100     """
     82    course1 = schema.Choice(
     83        title = _(u'Desired Contract'),
     84        source = AppCatCertificateSource(),
     85        required = True,
     86        )
     87    course2 = schema.Choice(
     88        title = _(u'Not applicable'),
     89        source = AppCatCertificateSource(),
     90        required = False,
     91        )
     92    course_admitted = schema.Choice(
     93        title = _(u'Assigned Contract'),
     94        source = CertificateSource(),
     95        required = False,
     96        readonly = True,
     97        )
     98    perm_address = schema.Text(
     99        title = _(u'Customer Address'),
     100        required = True,
     101        )
     102    service_address = schema.Text(
     103        title = _(u'Service Address'),
     104        required = True,
     105        )
    101106
    102107class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
     
    105110    """
    106111
    107 class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
    108     """An undergraduate applicant interface for editing.
    109 
    110     Here we can repeat the fields from base data and set the
    111     `required` and `readonly` attributes to True to further restrict
    112     the data access. Or we can allow only certain certificates to be
    113     selected by choosing the appropriate source.
    114 
    115     We cannot omit fields here. This has to be done in the
    116     respective form page.
    117     """
    118 
    119 class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
     112class ICustomApplicantUpdateByRegNo(IApplicantUpdateByRegNo):
    120113    """Representation of an applicant.
    121114
Note: See TracChangeset for help on using the changeset viewer.