Ignore:
Timestamp:
14 Jul 2020, 14:19:29 (4 years ago)
Author:
Henrik Bettermann
Message:

Configure transcript applications.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser.py

    r16142 r16165  
    124124
    125125TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS + (
    126     'date_of_birth',
     126    #'date_of_birth',
    127127    'sex',
    128128    'nationality',
    129     'entry_mode',
    130     'entry_session',
     129    #'entry_mode',
     130    #'entry_session',
    131131    'end_session',
    132     'course_studied',
    133     'course_changed',
    134     'change_level',
     132    #'course_studied',
     133    #'course_changed',
     134    #'change_level',
    135135    )
    136136
     
    158158    @property
    159159    def form_fields(self):
    160         if self.target is not None and self.target == 'transfull':
     160        if self.target is not None and self.target == 'tscf':
    161161            form_fields = grok.AutoFields(ITranscriptApplicant)
    162162            for field in TRANS_OMIT_FIELDS:
    163163                form_fields = form_fields.omit(field)
    164164            form_fields['dispatch_address'].custom_widget = BytesDisplayWidget
    165             form_fields['perm_address'].custom_widget = BytesDisplayWidget
    166             return form_fields
    167         if self.target is not None and self.target == 'transshort':
     165            #form_fields['perm_address'].custom_widget = BytesDisplayWidget
     166            return form_fields
     167        if self.target is not None and self.target == 'tscs':
    168168            form_fields = grok.AutoFields(ITranscriptApplicant)
    169169            for field in TRANS_SHORT_OMIT_FIELDS:
    170170                form_fields = form_fields.omit(field)
    171171            form_fields['dispatch_address'].custom_widget = BytesDisplayWidget
    172             form_fields['perm_address'].custom_widget = BytesDisplayWidget
     172            #form_fields['perm_address'].custom_widget = BytesDisplayWidget
    173173            return form_fields
    174174        if self.target is not None and self.target.startswith('pg'):
     
    192192        return form_fields
    193193
     194def getCerts(view, coursex):
     195    yield(dict(code='', title='--', selected=''))
     196    appcatcertificatesource = AppCatCertificateSource().factory
     197    for cert in appcatcertificatesource.getValues(view.context):
     198        selected = ''
     199        course = getattr(view.context, coursex)
     200        if course is not None and course.code == cert.code:
     201            selected = 'selected'
     202        title = appcatcertificatesource.getTitle(view.context, cert)
     203        yield(dict(code=cert.code, title=title, selected=selected))
     204
     205def saveCourses(view, changed_fields=[]):
     206    """In custom packages we needed to customize the certificate
     207    select widget. We just save course1 and course2 if these customized
     208    fields appear in the form.
     209    """
     210    form = view.request.form
     211    course1 = form.get('custom.course1', None)
     212    course2 = form.get('custom.course2', None)
     213    cat = queryUtility(ICatalog, name='certificates_catalog')
     214    if course1:
     215        results = list(
     216            cat.searchResults(code=(course1, course1)))
     217        view.context.course1 = results[0]
     218        changed_fields.append('course1')
     219    if course2:
     220        results = list(
     221            cat.searchResults(code=(course2, course2)))
     222        view.context.course2 = results[0]
     223        changed_fields.append('course2')
     224    return changed_fields
     225
     226def display_fileupload(view, filename):
     227    if view.target.startswith('tsc'):
     228        return False
     229    if filename[1] == 'res_stat.pdf':
     230        if view.context.subtype != 'transfer':
     231            return False
     232    if filename[1] == 'jamb.pdf' \
     233        and view.target is not None \
     234        and view.target.startswith('pg'):
     235        return False
     236    if filename[1] == 'nysc.pdf' \
     237        and view.target is not None \
     238        and not view.target.startswith('pg'):
     239        return False
     240    return True
     241
    194242class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
    195243    """A full edit view for applicant data.
     
    197245
    198246    def getCerts(self, coursex):
    199         yield(dict(code='', title='--', selected=''))
    200         appcatcertificatesource = AppCatCertificateSource().factory
    201         for cert in appcatcertificatesource.getValues(self.context):
    202             selected = ''
    203             course = getattr(self.context, coursex)
    204             if course is not None and course.code == cert.code:
    205                 selected = 'selected'
    206             title = appcatcertificatesource.getTitle(self.context, cert)
    207             yield(dict(code=cert.code, title=title, selected=selected))
     247        return getCerts(self, coursex)
    208248
    209249    def saveCourses(self, changed_fields):
    210         """In custom packages we needed to customize the certificate
    211         select widget. We just save course1 and course2 if these customized
    212         fields appear in the form.
    213         """
    214         form = self.request.form
    215         course1 = form.get('custom.course1', None)
    216         course2 = form.get('custom.course2', None)
    217         cat = queryUtility(ICatalog, name='certificates_catalog')
    218         if course1:
    219             results = list(
    220                 cat.searchResults(code=(course1, course1)))
    221             self.context.course1 = results[0]
    222             changed_fields.append('course1')
    223         if course2:
    224             results = list(
    225                 cat.searchResults(code=(course2, course2)))
    226             self.context.course2 = results[0]
    227             changed_fields.append('course2')
    228         return changed_fields
     250        return saveCourses(self, changed_fields)
     251
     252    def display_fileupload(self, filename):
     253        return display_fileupload(self, filename)
    229254
    230255    @property
     
    236261    @property
    237262    def form_fields(self):
    238         if self.target is not None and self.target == 'transfull':
     263        self.course_selector = False
     264        if self.target is not None and self.target == 'tscf':
    239265            form_fields = grok.AutoFields(ITranscriptApplicant)
    240266            for field in TRANS_OMIT_FIELDS:
    241267                form_fields = form_fields.omit(field)
    242268            return form_fields
    243         if self.target is not None and self.target == 'transshort':
     269        if self.target is not None and self.target == 'tscs':
    244270            form_fields = grok.AutoFields(ITranscriptApplicant)
    245271            for field in TRANS_SHORT_OMIT_FIELDS:
    246272                form_fields = form_fields.omit(field)
    247273            return form_fields
     274        self.course_selector = True
    248275        if self.target is not None and self.target.startswith('pg'):
    249276            form_fields = grok.AutoFields(ICustomPGApplicant)
     
    263290
    264291    def getCerts(self, coursex):
    265         yield(dict(code='', title='--', selected=''))
    266         appcatcertificatesource = AppCatCertificateSource().factory
    267         for cert in appcatcertificatesource.getValues(self.context):
    268             selected = ''
    269             course = getattr(self.context, coursex)
    270             if course is not None and course.code == cert.code:
    271                 selected = 'selected'
    272             title = appcatcertificatesource.getTitle(self.context, cert)
    273             yield(dict(code=cert.code, title=title, selected=selected))
     292        return getCerts(self, coursex)
    274293
    275294    def saveCourses(self):
    276         """In custom packages we needed to customize the certificate
    277         select widget. We just save course1 and course2 if these customized
    278         fields appear in the form.
    279         """
    280         form = self.request.form
    281         course1 = form.get('custom.course1', None)
    282         course2 = form.get('custom.course2', None)
    283         cat = queryUtility(ICatalog, name='certificates_catalog')
    284         if course1:
    285             results = list(
    286                 cat.searchResults(code=(course1, course1)))
    287             self.context.course1 = results[0]
    288         if course2:
    289             results = list(
    290                 cat.searchResults(code=(course2, course2)))
    291             self.context.course2 = results[0]
    292         return
     295        return saveCourses(self)
    293296
    294297    def display_fileupload(self, filename):
    295         if filename[1] == 'res_stat.pdf':
    296             if self.context.subtype != 'transfer':
    297                 return False
    298         if filename[1] == 'jamb.pdf' \
    299             and self.target is not None \
    300             and self.target.startswith('pg'):
    301             return False
    302         if filename[1] == 'nysc.pdf' \
    303             and self.target is not None \
    304             and not self.target.startswith('pg'):
    305             return False
    306         return True
     298        return display_fileupload(self, filename)
    307299
    308300    def dataNotComplete(self, data):
     
    320312    @property
    321313    def form_fields(self):
    322         if self.target is not None and self.target == 'transfull':
     314        self.course_selector = False
     315        if self.target is not None and self.target == 'tscf':
    323316            form_fields = grok.AutoFields(ITranscriptApplicant)
    324317            for field in TRANS_OMIT_FIELDS:
    325318                form_fields = form_fields.omit(field)
    326319            return form_fields
    327         if self.target is not None and self.target == 'transshort':
     320        if self.target is not None and self.target == 'tscs':
    328321            form_fields = grok.AutoFields(ITranscriptApplicant)
    329322            for field in TRANS_SHORT_OMIT_FIELDS:
    330323                form_fields = form_fields.omit(field)
    331324            return form_fields
     325        self.course_selector = True
    332326        if self.target is not None and self.target.startswith('pg'):
    333327            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/browser_templates/applicanteditpage.pt

    r16076 r16165  
    2222    <tbody>
    2323      <tal:widgets content="structure provider:widgets" />
    24 
     24      <tal:course_selector condition="view/course_selector">
    2525      <tr>
    2626        <td class="separator" colspan="2">
     
    7373      </tr>
    7474      <tr>
    75 
    76       <tr>
    77         <td class="separator" colspan="2">
     75      </tal:course_selector>
     76
     77      <tr>
     78        <td class="separator" colspan="2"
     79          tal:condition="python: not view.target.startswith('tsc')">
    7880          File Uploads
    7981        </td>
    8082      </tr>
    81 
    8283      <tr tal:condition="python: context.__parent__.with_picture">
    8384        <td class="fieldname" i18n:translate="">
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/interfaces.py

    r16147 r16165  
    2121
    2222from zope import schema
     23from zope.component import getUtility
     24from zope.catalog.interfaces import ICatalog
    2325from zc.sourcefactory.basic import BasicSourceFactory
    2426from waeup.kofa.applicants.interfaces import (
     
    111113            DESTINATION_COST[value][1])
    112114
     115class TranscriptCertificateSource(CertificateSource):
     116    """Include Department and Faculty in Title.
     117    """
     118    def getValues(self, context):
     119        catalog = getUtility(ICatalog, name='certificates_catalog')
     120        resultset = catalog.searchResults(code=(None, None))
     121        resultlist = sorted(resultset, key=lambda
     122            value: value.__parent__.__parent__.__parent__.code +
     123            value.__parent__.__parent__.code +
     124            value.code)
     125        return resultlist
     126
     127    def getTitle(self, context, value):
     128        """
     129        """
     130        try: title = "%s / %s / %s (%s)" % (
     131            value.__parent__.__parent__.__parent__.title,
     132            value.__parent__.__parent__.title,
     133            value.title, value.code)
     134        except AttributeError:
     135            title = "NA / %s (%s)" % (value.title, value.code)
     136        return title
     137
    113138class ICustomUGApplicant(IApplicantBaseData):
    114139    """An undergraduate applicant.
     
    415440        )
    416441
    417     #student_id = schema.TextLine(
    418     #    title = _(u'Kofa Student Id'),
    419     #    required = False,
    420     #    readonly = False,
    421     #    )
    422 
    423     #reg_number = schema.TextLine(
    424     #    title = _(u'Registration Number'),
    425     #    readonly = False,
    426     #    required = False,
    427     #    )
    428 
    429442    matric_number = schema.TextLine(
    430443        title = _(u'Matriculation Number'),
     
    448461        )
    449462
    450     date_of_birth = FormattedDate(
    451         title = _(u'Date of Birth'),
    452         required = False,
    453         #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
    454         show_year = True,
    455         )
     463    #date_of_birth = FormattedDate(
     464    #    title = _(u'Date of Birth'),
     465    #    required = False,
     466    #    #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
     467    #    show_year = True,
     468    #    )
    456469
    457470    sex = schema.Choice(
     
    461474        )
    462475
    463     nationality = schema.Choice(
    464         vocabulary = nats_vocab,
    465         title = _(u'Nationality'),
    466         required = False,
    467         )
     476    #nationality = schema.Choice(
     477    #    vocabulary = nats_vocab,
     478    #    title = _(u'Nationality'),
     479    #    required = False,
     480    #    )
    468481
    469482    email = schema.ASCIILine(
     
    473486        )
    474487
    475     phone = PhoneNumber(
    476         title = _(u'Phone'),
    477         description = u'',
    478         required = False,
    479         )
    480 
    481     perm_address = schema.Text(
    482         title = _(u'Current Local Address'),
    483         required = False,
    484         readonly = False,
    485         )
     488    #phone = PhoneNumber(
     489    #    title = _(u'Phone'),
     490    #    description = u'',
     491    #    required = False,
     492    #    )
     493
     494    #perm_address = schema.Text(
     495    #    title = _(u'Current Local Address'),
     496    #    required = False,
     497    #    readonly = False,
     498    #    )
    486499
    487500    dispatch_address = schema.Text(
     
    499512        )
    500513
    501     entry_mode = schema.Choice(
    502         title = _(u'Entry Mode'),
    503         source = StudyModeSource(),
    504         required = False,
    505         readonly = False,
    506         )
    507 
    508     entry_session = schema.Choice(
    509         title = _(u'Entry Session'),
     514    #entry_mode = schema.Choice(
     515    #    title = _(u'Entry Mode'),
     516    #    source = StudyModeSource(),
     517    #    required = False,
     518    #    readonly = False,
     519    #    )
     520
     521    #entry_session = schema.Choice(
     522    #    title = _(u'Entry Session'),
     523    #    source = academic_sessions_vocab,
     524    #    required = False,
     525    #    readonly = False,
     526    #    )
     527
     528    end_session = schema.Choice(
     529        title = _(u'Academic Session of Graduation'),
    510530        source = academic_sessions_vocab,
    511531        required = False,
     
    513533        )
    514534
    515     end_session = schema.Choice(
    516         title = _(u'End Session'),
    517         source = academic_sessions_vocab,
    518         required = False,
    519         readonly = False,
    520         )
    521 
    522535    course_studied = schema.Choice(
    523         title = _(u'Course of Study / Degree'),
    524         source = CertificateSource(),
    525         required = False,
    526         readonly = False,
    527         )
    528 
    529     course_changed = schema.Choice(
    530         title = _(u'Change of Study Course'),
    531         description = u'If yes, select previous course of study.',
    532         source = CertificateSource(),
    533         readonly = False,
    534         required = False,
    535         )
    536 
    537     change_level = schema.Choice(
    538         title = _(u'Change Level'),
    539         description = u'If yes, select level at which you changed course of study.',
    540         source = StudyLevelSource(),
    541         required = False,
    542         readonly = False,
    543         )
     536        title = _(u'Course of Study'),
     537        source = TranscriptCertificateSource(),
     538        description = u'Faculty / Department / Course',
     539        required = False,
     540        readonly = False,
     541        )
     542
     543    #course_changed = schema.Choice(
     544    #    title = _(u'Change of Study Course'),
     545    #    description = u'If yes, select previous course of study.',
     546    #    source = CertificateSource(),
     547    #    readonly = False,
     548    #    required = False,
     549    #    )
     550
     551    #change_level = schema.Choice(
     552    #    title = _(u'Change Level'),
     553    #    description = u'If yes, select level at which you changed course of study.',
     554    #    source = StudyLevelSource(),
     555    #    required = False,
     556    #    readonly = False,
     557    #    )
    544558
    545559    no_copies = schema.Choice(
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/utils.py

    r16142 r16165  
    5858        'pg': ['Postgraduate Programmes', 'PG'],
    5959        'ug': ['Undergraduate Programmes', 'UG'],
    60         'transfull': ['Transcript Application (without student record)', 'TRF'],
    61         'transshort': ['Transcript Application (with student record)', 'TRS'],
     60        'tscf': ['Transcript Application (without student record)', 'TRF'],
     61        'tscs': ['Transcript Application (with student record)', 'TRS'],
    6262        }
    6363
Note: See TracChangeset for help on using the changeset viewer.