Ignore:
Timestamp:
19 Jul 2017, 19:16:36 (7 years ago)
Author:
Henrik Bettermann
Message:

Use same application module setup as for kwarapoly.

Location:
main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants
Files:
5 edited

Legend:

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

    r14716 r14721  
    3131    grok.provides(ICustomApplicant)
    3232
     33    @property
     34    def is_nd(self):
     35        if self.applicant_id.startswith('nd') \
     36            or self.applicant_id.startswith('rmd') \
     37            or self.applicant_id.startswith('prend') \
     38            or self.applicant_id.startswith('prermd'):
     39            return True
     40        return False
     41
    3342# Set all attributes of CustomApplicant required in ICustomApplicant as field
    3443# properties. Doing this, we do not have to set initial attributes
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/browser.py

    r14716 r14721  
    1919"""
    2020import grok
    21 from waeup.kofa.applicants.browser import (
    22     ApplicantRegistrationPage, ApplicantsContainerPage)
    23 from kofacustom.nigeria.applicants.browser import (
    24     NigeriaApplicantDisplayFormPage,
    25     NigeriaPDFApplicationSlip)
     21from zope.component import getUtility
     22from zope.i18n import translate
     23from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     24from zope.formlib.textwidgets import BytesDisplayWidget
     25from waeup.kofa.applicants.interfaces import (
     26    IApplicant, IApplicantEdit, ISpecialApplicant)
     27from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
     28    ApplicantManageFormPage, ApplicantEditFormPage,
     29    ApplicantsContainerPage)
     30from waeup.kofa.applicants.viewlets import (
     31    PaymentReceiptActionButton, PDFActionButton)
     32from waeup.kofa.applicants.pdf import PDFApplicationSlip
     33from kofacustom.nigeria.applicants.interfaces import (
     34    UG_OMIT_DISPLAY_FIELDS,
     35    UG_OMIT_PDF_FIELDS,
     36    UG_OMIT_MANAGE_FIELDS,
     37    UG_OMIT_EDIT_FIELDS
     38    )
     39from kofacustom.dspg.applicants.interfaces import (
     40    ICustomUGApplicant, ICustomUGApplicantEdit,
     41    ND_OMIT_DISPLAY_FIELDS,
     42    ND_OMIT_PDF_FIELDS,
     43    ND_OMIT_MANAGE_FIELDS,
     44    ND_OMIT_EDIT_FIELDS
     45    )
    2646
    27 from kofacustom.dspg.interfaces import MessageFactory as _
     47UG_OMIT_EDIT_FIELDS = [
     48    value for value in UG_OMIT_EDIT_FIELDS
     49        if not value in ('jamb_subjects', 'jamb_score', 'jamb_reg_number')]
    2850
     51PRE_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + [
     52    'firstname',
     53    'middlename',
     54    'lastname',
     55    #'sex',
     56    'jamb_score'
     57    ]
     58
     59class CustomApplicantsContainerPage(ApplicantsContainerPage):
     60    """The standard view for regular applicant containers.
     61    """
     62
     63    @property
     64    def form_fields(self):
     65        form_fields = super(CustomApplicantsContainerPage, self).form_fields
     66        if self.request.principal.id == 'zope.anybody':
     67            return form_fields.omit('application_fee')
     68        return form_fields
     69
     70class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
     71    """A display view for applicant data.
     72    """
     73
     74    @property
     75    def form_fields(self):
     76        if self.context.special:
     77            return grok.AutoFields(ISpecialApplicant)
     78        form_fields = grok.AutoFields(ICustomUGApplicant)
     79        if self.context.is_nd:
     80            for field in ND_OMIT_DISPLAY_FIELDS:
     81                form_fields = form_fields.omit(field)
     82        else:
     83            form_fields = grok.AutoFields(ICustomUGApplicant)
     84            for field in UG_OMIT_DISPLAY_FIELDS:
     85                form_fields = form_fields.omit(field)
     86        form_fields['notice'].custom_widget = BytesDisplayWidget
     87        form_fields['jamb_subjects'].custom_widget = BytesDisplayWidget
     88        if not getattr(self.context, 'student_id'):
     89            form_fields = form_fields.omit('student_id')
     90        if not getattr(self.context, 'screening_score'):
     91            form_fields = form_fields.omit('screening_score')
     92        if not getattr(self.context, 'screening_venue'):
     93            form_fields = form_fields.omit('screening_venue')
     94        if not getattr(self.context, 'screening_date'):
     95            form_fields = form_fields.omit('screening_date')
     96        return form_fields
     97
     98class CustomPDFApplicationSlip(PDFApplicationSlip):
     99
     100    def _reduced_slip(self):
     101        return getattr(self.context, 'result_uploaded', False)
     102
     103    @property
     104    def note(self):
     105        note = getattr(self.context.__parent__, 'application_slip_notice', None)
     106        if note:
     107            return '<br /><br />' + note
     108        pronoun = 'S/he'
     109        if self.context.sex == 'm':
     110            pronoun = 'He'
     111        else:
     112            pronoun = 'She'
     113        return '''<br /><br />
     114The applicant has declared that:
     115
     116a) %s is not a member of any secret cult and will not join any.
     117b) %s will not engage in any cult activities.
     118c) %s will not be involved in any acts of terrorism, rape, robbery, fighting, illegal gathering and
     119any activities that could disrupt peace on campus.
     120d) %s does not have and will not acquire any form of weapon, fire arms, gun knife or any weapon
     121that can cause damage to life and property.
     122e) %s will strive to be worthy in character and learning at all times.
     123
     124The applicant has acknowledged that offences will automatically lead to the expulsion from the
     125Polytechnic and also be dealt with in accordance with the law of the land.
     126
     127The applicant promises to abide by all the Rules and Regulations of the Polytechnic if offered
     128admission.
     129''' % (
     130    pronoun, pronoun, pronoun, pronoun, pronoun)
     131
     132    @property
     133    def form_fields(self):
     134        form_fields = grok.AutoFields(ICustomUGApplicant)
     135        if self.context.is_nd:
     136            for field in ND_OMIT_PDF_FIELDS:
     137                form_fields = form_fields.omit(field)
     138        else:
     139            form_fields = grok.AutoFields(ICustomUGApplicant)
     140            for field in UG_OMIT_PDF_FIELDS:
     141                form_fields = form_fields.omit(field)
     142        if not getattr(self.context, 'student_id'):
     143            form_fields = form_fields.omit('student_id')
     144        if not getattr(self.context, 'screening_score'):
     145            form_fields = form_fields.omit('screening_score')
     146        if not getattr(self.context, 'screening_venue'):
     147            form_fields = form_fields.omit('screening_venue')
     148        if not getattr(self.context, 'screening_date'):
     149            form_fields = form_fields.omit('screening_date')
     150        return form_fields
     151
     152class CustomApplicantManageFormPage(ApplicantManageFormPage):
     153    """A full edit view for applicant data.
     154    """
     155
     156    @property
     157    def form_fields(self):
     158        if self.context.special:
     159            form_fields = grok.AutoFields(ISpecialApplicant)
     160            form_fields['applicant_id'].for_display = True
     161            return form_fields
     162        form_fields = grok.AutoFields(ICustomUGApplicant)
     163        if self.context.is_nd:
     164            for field in ND_OMIT_MANAGE_FIELDS:
     165                form_fields = form_fields.omit(field)
     166        else:
     167            for field in UG_OMIT_MANAGE_FIELDS:
     168                form_fields = form_fields.omit(field)
     169        form_fields['student_id'].for_display = True
     170        form_fields['applicant_id'].for_display = True
     171        return form_fields
     172
     173class CustomApplicantEditFormPage(ApplicantEditFormPage):
     174    """An applicant-centered edit view for applicant data.
     175    """
     176
     177    @property
     178    def form_fields(self):
     179
     180        if self.context.special:
     181            form_fields = grok.AutoFields(ISpecialApplicant).omit(
     182                'locked', 'suspended')
     183            form_fields['applicant_id'].for_display = True
     184            return form_fields
     185        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
     186        if self.context.is_nd:
     187            for field in ND_OMIT_EDIT_FIELDS:
     188                form_fields = form_fields.omit(field)
     189        elif self.target is not None and self.target.startswith('pre'):
     190            for field in PRE_OMIT_EDIT_FIELDS:
     191                form_fields = form_fields.omit(field)
     192        else:
     193            for field in UG_OMIT_EDIT_FIELDS:
     194                form_fields = form_fields.omit(field)
     195        form_fields['applicant_id'].for_display = True
     196        form_fields['reg_number'].for_display = True
     197        return form_fields
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/interfaces.py

    r14716 r14721  
    2626from waeup.kofa.interfaces import (
    2727    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
    28 from waeup.kofa.schema import FormattedDate, TextLineChoice
     28from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
    2929from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
    3030from waeup.kofa.applicants.interfaces import contextual_reg_num_source
    3131from kofacustom.nigeria.applicants.interfaces import (
    3232    LGASource, high_qual, high_grade, exam_types,
     33    OMIT_DISPLAY_FIELDS,
    3334    INigeriaUGApplicant, INigeriaPGApplicant,
    3435    INigeriaApplicantOnlinePayment,
     
    4041from kofacustom.dspg.payments.interfaces import ICustomOnlinePayment
    4142
    42 class ICustomUGApplicant(INigeriaUGApplicant):
     43ND_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
     44    'hq_type',
     45    'hq_matric_no',
     46    'hq_degree',
     47    'hq_school',
     48    'hq_session',
     49    'hq_disc',
     50    'hq_type')
     51ND_OMIT_PDF_FIELDS = ND_OMIT_DISPLAY_FIELDS + ('phone',)
     52ND_OMIT_MANAGE_FIELDS = ('special_application',)
     53ND_OMIT_EDIT_FIELDS = ND_OMIT_MANAGE_FIELDS + ND_OMIT_DISPLAY_FIELDS + (
     54    'student_id', 'notice',
     55    'screening_score',
     56    'screening_venue',
     57    'screening_date',
     58    'jamb_age',
     59    'jamb_subjects',
     60    'jamb_score',
     61    'aggregate')
     62
     63class ICustomUGApplicant(IApplicantBaseData):
    4364    """An undergraduate applicant.
    4465
     
    4768    adding them to the UG_OMIT* tuples.
    4869    """
     70    sex = schema.Choice(
     71        title = _(u'Sex'),
     72        source = GenderSource(),
     73        required = False,
     74        )
     75    nationality = schema.Choice(
     76        source = nats_vocab,
     77        title = _(u'Nationality'),
     78        required = False,
     79        )
     80    lga = schema.Choice(
     81        source = LGASource(),
     82        title = _(u'State/LGA (Nigerians only)'),
     83        required = False,
     84        )
     85    #perm_address = schema.Text(
     86    #    title = _(u'Permanent Address'),
     87    #    required = False,
     88    #    )
     89    next_kin_address = schema.Text(
     90        title = _(u'Next of Kin Address'),
     91        required = False,
     92        )
     93    jamb_reg_number = schema.TextLine(
     94        title = _(u'JAMB Registration Number'),
     95        required = False,
     96        )
     97    course1 = schema.Choice(
     98        title = _(u'1st Choice Course of Study'),
     99        source = AppCatCertificateSource(),
     100        required = False,
     101        )
     102    course2 = schema.Choice(
     103        title = _(u'2nd Choice Course of Study'),
     104        source = AppCatCertificateSource(),
     105        required = False,
     106        )
     107    olevel_type = schema.Choice(
     108        title = _(u'Qualification Obtained'),
     109        required = False,
     110        readonly = False,
     111        vocabulary = exam_types,
     112        )
     113    olevel_school = schema.TextLine(
     114        title = _(u'Institution Attended'),
     115        required = False,
     116        readonly = False,
     117        )
     118    olevel_exam_number = schema.TextLine(
     119        title = _(u'Exam Number'),
     120        required = False,
     121        readonly = False,
     122        )
     123    olevel_exam_date = FormattedDate(
     124        title = _(u'Exam Date'),
     125        required = False,
     126        readonly = False,
     127        show_year = True,
     128        )
     129    olevel_results = schema.List(
     130        title = _(u'Exam Results'),
     131        value_type = ResultEntryField(),
     132        required = False,
     133        readonly = False,
     134        defaultFactory=list,
     135        )
     136    olevel_pin = schema.TextLine(
     137        title = _(u'Result Checking PIN'),
     138        required = False,
     139        readonly = False,
     140        )
     141    olevel_pin_serial = schema.TextLine(
     142        title = _(u'PIN Serial Number'),
     143        required = False,
     144        readonly = False,
     145        )
     146    olevel_type2 = schema.Choice(
     147        title = _(u'2nd Qualification Obtained'),
     148        required = False,
     149        readonly = False,
     150        vocabulary = exam_types,
     151        )
     152    olevel_school2 = schema.TextLine(
     153        title = _(u'2nd Institution Attended'),
     154        required = False,
     155        readonly = False,
     156        )
     157    olevel_exam_number2 = schema.TextLine(
     158        title = _(u'2nd Exam Number'),
     159        required = False,
     160        readonly = False,
     161        )
     162    olevel_exam_date2 = FormattedDate(
     163        title = _(u'2nd Exam Date'),
     164        required = False,
     165        readonly = False,
     166        show_year = True,
     167        )
     168    olevel_results2 = schema.List(
     169        title = _(u'2nd Exam Results'),
     170        value_type = ResultEntryField(),
     171        required = False,
     172        readonly = False,
     173        defaultFactory=list,
     174        )
     175    olevel_pin2 = schema.TextLine(
     176        title = _(u'2nd Result Checking PIN'),
     177        required = False,
     178        readonly = False,
     179        )
     180    olevel_pin_serial2 = schema.TextLine(
     181        title = _(u'2nd PIN Serial Number'),
     182        required = False,
     183        readonly = False,
     184        )
     185    hq_type = schema.Choice(
     186        title = _(u'Qualification Obtained'),
     187        required = False,
     188        readonly = False,
     189        vocabulary = high_qual,
     190        )
     191    hq_matric_no = schema.TextLine(
     192        title = _(u'Former Matric Number'),
     193        required = False,
     194        readonly = False,
     195        )
     196    hq_degree = schema.Choice(
     197        title = _(u'Class of Degree'),
     198        required = False,
     199        readonly = False,
     200        vocabulary = high_grade,
     201        )
     202    hq_school = schema.TextLine(
     203        title = _(u'Institution Attended'),
     204        required = False,
     205        readonly = False,
     206        )
     207    hq_session = schema.TextLine(
     208        title = _(u'Years Attended'),
     209        required = False,
     210        readonly = False,
     211        )
     212    hq_disc = schema.TextLine(
     213        title = _(u'Discipline'),
     214        required = False,
     215        readonly = False,
     216        )
     217    jamb_subjects = schema.Text(
     218        title = _(u'Subjects and Scores'),
     219        description = _(u'(one subject with score per line)'),
     220        required = False,
     221        )
     222    jamb_score = schema.Int(
     223        title = _(u'Total JAMB Score'),
     224        required = False,
     225        )
     226    jamb_age = schema.Int(
     227        title = _(u'Age (provided by JAMB)'),
     228        required = False,
     229        )
     230    notice = schema.Text(
     231        title = _(u'Notice'),
     232        required = False,
     233        )
     234    screening_venue = schema.TextLine(
     235        title = _(u'Screening Venue'),
     236        required = False,
     237        )
     238    screening_date = schema.TextLine(
     239        title = _(u'Screening Date'),
     240        required = False,
     241        )
     242    screening_score = schema.Int(
     243        title = _(u'Screening Score (%)'),
     244        required = False,
     245        )
     246    aggregate = schema.Int(
     247        title = _(u'Aggregate Score (%)'),
     248        description = _(u'(average of relative JAMB and PUTME scores)'),
     249        required = False,
     250        )
     251    result_uploaded = schema.Bool(
     252        title = _(u'Result uploaded'),
     253        default = False,
     254        required = False,
     255        )
     256    student_id = schema.TextLine(
     257        title = _(u'Student Id'),
     258        required = False,
     259        readonly = False,
     260        )
     261    course_admitted = schema.Choice(
     262        title = _(u'Admitted Course of Study'),
     263        source = CertificateSource(),
     264        required = False,
     265        )
     266    locked = schema.Bool(
     267        title = _(u'Form locked'),
     268        default = False,
     269        required = False,
     270        )
     271
     272ICustomUGApplicant[
     273    'sex'].order =  IApplicantBaseData['sex'].order
    49274
    50275class ICustomPGApplicant(INigeriaPGApplicant):
     
    55280    adding them to the PG_OMIT* tuples.
    56281    """
    57 
    58282
    59283class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
     
    76300        """
    77301
    78 class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
     302class ICustomUGApplicantEdit(ICustomUGApplicant):
    79303    """An undergraduate applicant interface for edit forms.
    80304
     
    87311    respective form page.
    88312    """
     313    email = schema.ASCIILine(
     314        title = _(u'Email Address'),
     315        required = True,
     316        constraint=validate_email,
     317        )
     318    phone = PhoneNumber(
     319        title = _(u'Phone'),
     320        description = u'',
     321        required = True,
     322        )
     323    date_of_birth = FormattedDate(
     324        title = _(u'Date of Birth'),
     325        required = True,
     326        show_year = True,
     327        )
     328    sex = schema.Choice(
     329        title = _(u'Sex'),
     330        source = GenderSource(),
     331        required = True,
     332        )
     333    nationality = schema.Choice(
     334        source = nats_vocab,
     335        title = _(u'Nationality'),
     336        required = True,
     337        )
     338    course1 = schema.Choice(
     339        title = _(u'1st Choice Course of Study'),
     340        source = AppCatCertificateSource(),
     341        required = True,
     342        )
     343    olevel_type = schema.Choice(
     344        title = _(u'Qualification Obtained'),
     345        required = True,
     346        readonly = False,
     347        vocabulary = exam_types,
     348        )
     349    jamb_subjects = schema.Text(
     350        title = _(u'Subjects and Scores'),
     351        description = _(u'(one subject with score per line)'),
     352        required = True,
     353        )
     354    jamb_reg_number = schema.TextLine(
     355        title = _(u'JAMB Registration Number'),
     356        required = True,
     357        )
     358
     359ICustomUGApplicantEdit[
     360    'nationality'].order =  ICustomUGApplicant['nationality'].order
     361ICustomUGApplicantEdit[
     362    'email'].order =  ICustomUGApplicant['email'].order
     363ICustomUGApplicantEdit[
     364    'phone'].order =  ICustomUGApplicant['phone'].order
     365ICustomUGApplicantEdit[
     366    'course1'].order =  ICustomUGApplicant['course1'].order
     367ICustomUGApplicantEdit[
     368    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
     369ICustomUGApplicantEdit[
     370    'sex'].order =  ICustomUGApplicant['sex'].order
     371ICustomUGApplicantEdit[
     372    'olevel_type'].order =  ICustomUGApplicant['olevel_type'].order
     373ICustomUGApplicantEdit[
     374    'jamb_subjects'].order =  ICustomUGApplicant['jamb_subjects'].order
     375ICustomUGApplicantEdit[
     376    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
    89377
    90378class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
     
    105393    """
    106394
    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 
    119395class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
    120396    """Representation of an applicant.
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/tests/test_browser.py

    r14716 r14721  
    1919Test the applicant-related UI components.
    2020"""
     21import shutil
     22import tempfile
     23import datetime
     24import pytz
    2125import os
    22 import datetime
     26from zope.component.hooks import setSite, clearSite
    2327from zope.component import createObject, getUtility
    2428from zope.catalog.interfaces import ICatalog
    2529from zope.intid.interfaces import IIntIds
    26 from hurry.workflow.interfaces import IWorkflowState
     30from zope.testbrowser.testing import Browser
    2731from kofacustom.dspg.testing import FunctionalLayer
    28 from waeup.kofa.browser.tests.test_pdf import samples_dir
    29 from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
     32from waeup.kofa.app import University
     33from waeup.kofa.university.faculty import Faculty
     34from waeup.kofa.university.department import Department
     35from waeup.kofa.testing import FunctionalTestCase
    3036from waeup.kofa.applicants.tests.test_batching import ApplicantImportExportSetup
    31 from kofacustom.dspg.applicants.export import CustomApplicantExporter
    32 from kofacustom.dspg.applicants.batching import CustomApplicantProcessor
     37from waeup.kofa.applicants.container import ApplicantsContainer
    3338
    34 class CustomApplicantUITests(ApplicantsFullSetup):
    35     # Tests for uploading/browsing the passport image of appplicants
     39session = datetime.datetime.now().year - 2
     40ndftcontainer_name = u'ndft%s' % session
    3641
     42class ApplicantUITest(FunctionalTestCase):
     43    """Perform some browser tests.
     44    """
    3745    layer = FunctionalLayer
     46
     47    def setUp(self):
     48        super(ApplicantUITest, self).setUp()
     49        # Setup a sample site for each test
     50        app = University()
     51        self.dc_root = tempfile.mkdtemp()
     52        app['datacenter'].setStoragePath(self.dc_root)
     53
     54        # Prepopulate the ZODB...
     55        self.getRootFolder()['app'] = app
     56        # we add the site immediately after creation to the
     57        # ZODB. Catalogs and other local utilities are not setup
     58        # before that step.
     59        self.app = self.getRootFolder()['app']
     60        # Set site here. Some of the following setup code might need
     61        # to access grok.getSite() and should get our new app then
     62        setSite(app)
     63
     64        # Add ndft applicants container
     65        self.ndftcontainer = ApplicantsContainer()
     66        self.ndftcontainer.mode = 'create'
     67        self.ndftcontainer.code = ndftcontainer_name
     68        self.ndftcontainer.prefix = u'ndft'
     69        self.ndftcontainer.application_category = u'ndft'
     70        self.ndftcontainer.year = session
     71        self.ndftcontainer.application_fee = 300.0
     72        #self.ndftcontainer.title = u'This is the %s container' % ndftcontainer_name
     73        self.app['applicants'][ndftcontainer_name] = self.ndftcontainer
     74
     75        delta = datetime.timedelta(days=10)
     76        self.ndftcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
     77        self.ndftcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
     78
     79        # Populate university
     80        self.certificate = createObject('waeup.Certificate')
     81        self.certificate.code = 'CERT1'
     82        self.certificate.application_category = 'ndft'
     83        self.certificate.start_level = 100
     84        self.certificate.end_level = 500
     85        self.certificate.study_mode = u'nce_ft'
     86        self.app['faculties']['fac1'] = Faculty()
     87        self.app['faculties']['fac1']['dep1'] = Department()
     88        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     89            self.certificate)
     90
     91        # Add (customized) applicants
     92        ndftapplicant = createObject(u'waeup.Applicant')
     93        ndftapplicant.firstname = u'Anna'
     94        ndftapplicant.lastname = u'Post'
     95        self.app['applicants'][ndftcontainer_name].addApplicant(ndftapplicant)
     96        self.ndftapplication_number = ndftapplicant.application_number
     97        self.ndftapplicant = self.app['applicants'][ndftcontainer_name][
     98            self.ndftapplication_number]
     99        self.ndftapplicant_path = ('http://localhost/app/applicants/%s/%s'
     100            % (ndftcontainer_name, self.ndftapplication_number))
     101
     102        self.browser = Browser()
     103        self.browser.handleErrors = False
     104
     105    def tearDown(self):
     106        super(ApplicantUITest, self).tearDown()
     107        shutil.rmtree(self.dc_root)
     108        clearSite()
     109        return
     110
     111    def fill_correct_values(self):
     112        self.browser.getControl(name="form.reg_number").value = '1234'
     113        self.browser.getControl(name="form.firstname").value = 'John'
     114        self.browser.getControl(name="form.lastname").value = 'Tester'
     115        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
     116        self.browser.getControl(name="form.lga").value = ['foreigner']
     117        #self.browser.getControl(name="form.nationality").value = ['NG']
     118        #self.browser.getControl(name="form.sex").value = ['m']
     119        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     120
     121    def test_manage_and_view_applicant(self):
     122        # Managers can manage ndft applicants.
     123        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     124        self.browser.open(self.ndftapplicant_path)
     125        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     126        self.assertTrue("'O' Level" in self.browser.contents)
     127        self.assertFalse("Higher" in self.browser.contents)
     128        self.browser.open(self.ndftapplicant_path + '/manage')
     129        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     130        self.assertTrue("'O' Level" in self.browser.contents)
     131        self.assertTrue("Higher" in self.browser.contents)
     132        self.browser.open(self.ndftapplicant_path + '/edit')
     133        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     134        self.assertTrue("'O' Level" in self.browser.contents)
     135        self.assertFalse("Higher" in self.browser.contents)
     136        self.browser.open(self.ndftapplicant_path + '/application_slip.pdf')
     137        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     138        # Now we turn the ndft applicant into an hndft applicant.
     139        self.ndftapplicant.applicant_id = u'hndft_anything'
     140        self.browser.open(self.ndftapplicant_path)
     141        self.assertTrue("Higher" in self.browser.contents)
     142        self.assertTrue("'O' Level" in self.browser.contents)
     143        self.browser.open(self.ndftapplicant_path + '/edit')
     144        self.assertTrue("Higher" in self.browser.contents)
     145        self.assertTrue("'O' Level" in self.browser.contents)
     146
     147        self.browser.open(self.ndftapplicant_path + '/manage')
     148        # Manager can fill and save the form
     149        self.fill_correct_values()
     150        self.browser.getControl("Save").click()
     151        self.assertMatches('...Form has been saved...', self.browser.contents)
     152        return
    38153
    39154class ApplicantExporterTest(ApplicantImportExportSetup):
     
    69184        applicant.password = 'any password'
    70185        return applicant
    71 
    72 class ApplicantsContainerUITests(ApplicantsFullSetup):
    73     # Tests for ApplicantsContainer class views and pages
    74 
    75     layer = FunctionalLayer
    76 
    77     def test_application_slip(self):
    78         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    79         self.slip_path = self.view_path + '/application_slip.pdf'
    80         self.browser.open(self.manage_path)
    81         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    82         self.fill_correct_values()
    83         self.browser.getControl("Save").click()
    84         IWorkflowState(self.applicant).setState('submitted')
    85         self.browser.open(self.manage_path)
    86         self.browser.getLink("Download application slip").click()
    87         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    88         self.assertEqual(self.browser.headers['Content-Type'],
    89                          'application/pdf')
    90         path = os.path.join(samples_dir(), 'application_slip.pdf')
    91         open(path, 'wb').write(self.browser.contents)
    92         print "Sample application_slip.pdf written to %s" % path
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/utils.py

    r14718 r14721  
    5454        'special': ['Supplementary Payment', 'SP'],
    5555        }
     56
     57    SEPARATORS_DICT = {
     58        'form.applicant_id': _(u'Base Data'),
     59        'form.course1': _(u'Programmes/Courses Desired'),
     60        'form.hq_type': _(u'Higher Education Record'),
     61        'form.jamb_subjects': _(u'JAMB Data'),
     62        'form.notice': _(u'Application Process Information'),
     63        'form.pp_school': _(u'Post Primary School Qualification'),
     64        'form.presently_inst': _(u'Presently attending a course or programme'),
     65        'form.olevel_type': _(u"'O' Level Record"),
     66        }
Note: See TracChangeset for help on using the changeset viewer.