Changeset 16078 for main


Ignore:
Timestamp:
2 May 2020, 20:07:43 (5 years ago)
Author:
Henrik Bettermann
Message:

Implement transcript applications.

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

Legend:

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

    r11785 r16078  
    2424from waeup.uniben.applicants.interfaces import(
    2525    ICustomApplicant, ICustomUGApplicantEdit, ICustomPGApplicantEdit,
    26     IPUTMEApplicantEdit)
     26    IPUTMEApplicantEdit, ITranscriptApplicant)
    2727
    2828class CustomApplicant(NigeriaApplicant):
    2929
    3030    grok.implements(ICustomApplicant, ICustomUGApplicantEdit,
    31         ICustomPGApplicantEdit, IPUTMEApplicantEdit)
     31        ICustomPGApplicantEdit, IPUTMEApplicantEdit, ITranscriptApplicant)
    3232    grok.provides(ICustomApplicant)
    3333
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py

    r15506 r16078  
    4949    ICustomPGApplicantEdit,
    5050    ICustomUGApplicantEdit,
    51     IPUTMEApplicantEdit)
     51    IPUTMEApplicantEdit,
     52    ITranscriptApplicant)
    5253from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED
    5354from kofacustom.nigeria.applicants.interfaces import (
     
    207208    @property
    208209    def form_fields(self):
     210        if self.target is not None and self.target == 'trans':
     211            form_fields = grok.AutoFields(ITranscriptApplicant).omit(
     212                'locked', 'suspended')
     213            form_fields['dispatch_address'].custom_widget = BytesDisplayWidget
     214            form_fields['perm_address'].custom_widget = BytesDisplayWidget
     215            return form_fields
    209216        if self.target == 'ictwk':
    210217            form_fields = grok.AutoFields(IUnibenRegistration)
     
    372379    @property
    373380    def form_fields(self):
     381        if self.target is not None and self.target == 'trans':
     382            form_fields = grok.AutoFields(ITranscriptApplicant)
     383            form_fields['applicant_id'].for_display = True
     384            return form_fields
    374385        if self.target == 'ictwk':
    375386            form_fields = grok.AutoFields(IUnibenRegistration)
     
    432443    @property
    433444    def form_fields(self):
     445        if self.target is not None and self.target == 'trans':
     446            form_fields = grok.AutoFields(ITranscriptApplicant).omit(
     447                'locked', 'suspended')
     448            form_fields['applicant_id'].for_display = True
     449            form_fields['reg_number'].for_display = True
     450            form_fields['place_of_birth'].field.required = True
     451            form_fields['date_of_birth'].field.required = True
     452            form_fields['nationality'].field.required = True
     453            form_fields['email'].field.required = True
     454            form_fields['phone'].field.required = True
     455            form_fields['perm_address'].field.required = True
     456            form_fields['dispatch_address'].field.required = True
     457            form_fields['entry_mode'].field.required = True
     458            form_fields['entry_session'].field.required = True
     459            form_fields['end_session'].field.required = True
     460            form_fields['course_studied'].field.required = True
     461            return form_fields
    434462        if self.target == 'ictwk':
    435463            form_fields = grok.AutoFields(IUnibenRegistration)
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/export.py

    r14851 r16078  
    2525from kofacustom.nigeria.applicants.interfaces import (
    2626    INigeriaUGApplicant, INigeriaPGApplicant, IBankAccount)
    27 from waeup.uniben.applicants.interfaces import IUnibenRegistration
     27from waeup.uniben.applicants.interfaces import (
     28    IUnibenRegistration, ITranscriptApplicant)
    2829
    2930class CustomApplicantExporter(NigeriaApplicantExporter):
     
    3637        iface_names(IApplicantBaseData) +
    3738        iface_names(IUnibenRegistration) +
     39        iface_names(ITranscriptApplicant) +
    3840        iface_names(IBankAccount)
    3941        ))) + (
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py

    r15490 r16078  
    2929    IApplicantBaseData,
    3030    AppCatCertificateSource, CertificateSource)
     31from waeup.kofa.university.vocabularies import StudyModeSource
     32from waeup.kofa.students.vocabularies import (
     33    nats_vocab, GenderSource, StudyLevelSource)
    3134from waeup.kofa.schoolgrades import ResultEntryField
    3235from waeup.kofa.interfaces import (
     
    184187#                raise Invalid(_("Matriculation number not found."))
    185188
     189class ITranscriptApplicant(IKofaObject):
     190    """A transcript applicant.
     191    """
     192
     193    suspended = schema.Bool(
     194        title = _(u'Account suspended'),
     195        default = False,
     196        required = False,
     197        )
     198
     199    locked = schema.Bool(
     200        title = _(u'Form locked'),
     201        default = False,
     202        required = False,
     203        )
     204
     205    applicant_id = schema.TextLine(
     206        title = _(u'Application Id'),
     207        required = False,
     208        readonly = False,
     209        )
     210
     211    reg_number = TextLineChoice(
     212        title = _(u'Kofa Registration Number'),
     213        readonly = False,
     214        required = True,
     215        source = contextual_reg_num_source,
     216        )
     217
     218    firstname = schema.TextLine(
     219        title = _(u'First Name'),
     220        required = True,
     221        )
     222
     223    middlename = schema.TextLine(
     224        title = _(u'Middle Name'),
     225        required = False,
     226        )
     227
     228    lastname = schema.TextLine(
     229        title = _(u'Last Name (Surname)'),
     230        required = True,
     231        )
     232
     233    matric_number = schema.TextLine(
     234        title = _(u'Matriculation Number'),
     235        readonly = False,
     236        required = True,
     237        )
     238
     239    date_of_birth = FormattedDate(
     240        title = _(u'Date of Birth'),
     241        required = False,
     242        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
     243        show_year = True,
     244        )
     245
     246    sex = schema.Choice(
     247        title = _(u'Gender'),
     248        source = GenderSource(),
     249        required = True,
     250        )
     251
     252    place_of_birth = schema.TextLine(
     253        title = _(u'Place of Birth'),
     254        readonly = False,
     255        required = False,
     256        )
     257
     258    nationality = schema.Choice(
     259        vocabulary = nats_vocab,
     260        title = _(u'Nationality'),
     261        required = False,
     262        )
     263
     264    email = schema.ASCIILine(
     265        title = _(u'Email Address'),
     266        required = True,
     267        constraint=validate_email,
     268        )
     269
     270    phone = PhoneNumber(
     271        title = _(u'Phone'),
     272        description = u'',
     273        required = False,
     274        )
     275
     276    perm_address = schema.Text(
     277        title = _(u'Current Local Address'),
     278        required = False,
     279        readonly = False,
     280        )
     281
     282    dispatch_address = schema.Text(
     283        title = _(u'Dispatch Addresses'),
     284        description = u'Addresses to which transcript should be posted.',
     285        required = False,
     286        readonly = False,
     287        )
     288
     289    entry_mode = schema.Choice(
     290        title = _(u'Entry Mode'),
     291        source = StudyModeSource(),
     292        required = False,
     293        readonly = False,
     294        )
     295
     296    entry_session = schema.Choice(
     297        title = _(u'Entry Session'),
     298        source = academic_sessions_vocab,
     299        required = False,
     300        readonly = False,
     301        )
     302
     303    end_session = schema.Choice(
     304        title = _(u'End Session'),
     305        source = academic_sessions_vocab,
     306        required = False,
     307        readonly = False,
     308        )
     309
     310    course_studied = schema.Choice(
     311        title = _(u'Course of Study / Degree'),
     312        source = CertificateSource(),
     313        required = False,
     314        readonly = False,
     315        )
     316
     317    purpose = schema.TextLine(
     318        title = _(u'Purpose of this Application'),
     319        readonly = False,
     320        required = False,
     321        )
     322
     323    course_changed = schema.Choice(
     324        title = _(u'Change of Study Course'),
     325        description = u'If yes, select previous course of study.',
     326        source = CertificateSource(),
     327        readonly = False,
     328        required = False,
     329        )
     330
     331    change_level = schema.Choice(
     332        title = _(u'Change Level'),
     333        description = u'If yes, select level at which you changed course of study.',
     334        source = StudyLevelSource(),
     335        required = False,
     336        readonly = False,
     337        )
     338
     339    no_copies = schema.Choice(
     340        title = _(u'Number of Copies'),
     341        description = u'Must correspond with the number of dispatch addresses above.',
     342        values=[1, 2, 3, 4],
     343        required = False,
     344        readonly = False,
     345        default = 1,
     346        )
     347
    186348class ICustomUGApplicant(IApplicantBaseData, IBankAccount):
    187349    """An undergraduate applicant.
     
    409571
    410572class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
    411     IUnibenRegistration):
     573    IUnibenRegistration, ITranscriptApplicant):
    412574    """An interface for both types of applicants.
    413575
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r15313 r16078  
    2121"""
    2222import os
     23import datetime
     24import pytz
    2325from StringIO import StringIO
    24 from datetime import datetime
    2526from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2627from zope.securitypolicy.interfaces import IPrincipalRoleManager
     28from zope.component import createObject, getUtility
     29from waeup.kofa.configuration import SessionConfiguration
     30from waeup.kofa.interfaces import IUserAccount
    2731from waeup.kofa.browser.tests.test_pdf import samples_dir
    2832from waeup.kofa.applicants.container import ApplicantsContainer
     
    3135from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup, PH_LEN
    3236
    33 session_1 = datetime.now().year - 2
     37session_1 = datetime.datetime.now().year - 2
    3438SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    3539
     
    127131        self.assertTrue('<span>55</span>' in self.browser.contents)
    128132        configuration = CustomSessionConfiguration()
    129         configuration.academic_session = datetime.now().year - 2
     133        configuration.academic_session = datetime.datetime.now().year - 2
    130134        self.app['configuration'].addSessionConfiguration(configuration)
    131135        # Admission checking fee is 0, thus admission checking payment
     
    290294        open(path, 'wb').write(self.browser.contents)
    291295        print "Sample ictwk_application_slip.pdf written to %s" % path
     296
     297    def test_transcript_payment(self):
     298        configuration = SessionConfiguration()
     299        configuration.academic_session = session_1
     300        self.app['configuration'].addSessionConfiguration(configuration)
     301        # Add special application container
     302        applicantscontainer = ApplicantsContainer()
     303        applicantscontainer.year = session_1
     304        applicantscontainer.application_fee = 200.0
     305        applicantscontainer.code = u'trans1234'
     306        applicantscontainer.prefix = 'trans'
     307        applicantscontainer.title = u'This is a trans container'
     308        applicantscontainer.application_category = 'no'
     309        applicantscontainer.mode = 'create'
     310        applicantscontainer.strict_deadline = True
     311        applicantscontainer.with_picture = False
     312        delta = datetime.timedelta(days=10)
     313        applicantscontainer.startdate = datetime.datetime.now(pytz.utc) - delta
     314        applicantscontainer.enddate = datetime.datetime.now(pytz.utc) + delta
     315        self.app['applicants']['trans1234'] = applicantscontainer
     316        # Add an applicant
     317        applicant = createObject('waeup.Applicant')
     318        # reg_number is the only field which has to be preset here
     319        # because managers are allowed to edit this required field
     320        applicant.reg_number = u'12345'
     321        self.app['applicants']['trans1234'].addApplicant(applicant)
     322        IUserAccount(
     323            self.app['applicants']['trans1234'][
     324            applicant.application_number]).setPassword('apwd')
     325        # Login
     326        self.browser.open(self.login_path)
     327        self.browser.getControl(
     328            name="form.login").value = applicant.applicant_id
     329        self.browser.getControl(name="form.password").value = 'apwd'
     330        self.browser.getControl("Login").click()
     331        self.browser.getLink("Application record").click()
     332        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
     333        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     334        self.browser.getControl(name="form.nationality").value = ['NG']
     335        self.browser.getControl(name="form.firstname").value = 'Angela'
     336        self.browser.getControl(name="form.lastname").value = 'Merkel'
     337        self.browser.getControl(name="form.sex").value = ['f']
     338        self.browser.getControl(name="form.no_copies").value = ['3']
     339        self.browser.getControl(name="form.course_studied").value = ['CERT1']
     340        self.browser.getControl(name="form.matric_number").value = '234'
     341        self.browser.getControl(name="form.place_of_birth").value = 'Bochum'
     342        self.browser.getControl(name="form.dispatch_address").value = 'Kuensche'
     343        self.browser.getControl(name="form.perm_address").value = 'Kuensche'
     344        self.browser.getControl(name="form.entry_mode").value = ['ug_ft']
     345        self.browser.getControl(name="form.entry_session").value = ['2014']
     346        self.browser.getControl(name="form.end_session").value = ['2015']
     347        self.browser.getControl(name="form.phone.country").value = ['+234']
     348        self.browser.getControl(name="form.phone.ext").value = '5678'
     349        self.browser.getControl("Save").click()
     350        self.browser.getControl("Add online payment ticket").click()
     351        self.assertTrue('Payment ticket created' in self.browser.contents)
     352        self.assertTrue('<span>200.0</span>' in self.browser.contents)
     353        self.assertEqual(applicant.values()[0].amount_auth, 200.0)
     354        return
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py

    r14867 r16078  
    6060                 '(2nd supplementary advert)', 'ASE'],
    6161        'spft': ['Special Full-Time Programmes', 'SP'],
     62        'trans': ['Transcript Application', 'TR'],
    6263        }
    6364
Note: See TracChangeset for help on using the changeset viewer.