Ignore:
Timestamp:
7 Apr 2016, 14:21:25 (9 years ago)
Author:
Henrik Bettermann
Message:

Define IUnibenRegistration for ICTWK registrations and implement RegTypesSource?.

Location:
main/waeup.uniben/trunk/src/waeup/uniben
Files:
4 edited

Legend:

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

    r13796 r13814  
    4040    NigeriaPDFApplicationSlip)
    4141from waeup.uniben.applicants.interfaces import (
    42     ICustomApplicant)
     42    ICustomApplicant, IUnibenRegistration)
    4343from waeup.kofa.applicants.workflow import ADMITTED, PAID
    4444
     
    6161PASTQ_MSS = ['ACC','BNK','BUS','ECO','GEO','POL','SAA','SWK'] + PASTQ_ALL
    6262
    63 ICT_WEEK_FIELDS = (
    64     'course1',
    65     'course2',
    66     'aggregate',
    67     'screening_score',
    68     'screening_venue',
    69     'screening_date',
    70     'jamb_subjects',
    71     'jamb_score',
    72     'jamb_reg_number',
    73     'hq_type',
    74     'hq_matric_no',
    75     'hq_degree',
    76     'hq_school',
    77     'hq_session',
    78     'hq_disc',
    79     'student_id',
    80     'course_admitted',
     63REGISTRATION_OMIT_DISPLAY_FIELDS = (
     64    'locked',
     65    'suspended',
    8166    )
    8267
     68REGISTRATION_OMIT_EDIT_FIELDS = (
     69    'locked',
     70    'suspended',
     71    'applicant_id',
     72    )
     73
     74REGISTRATION_OMIT_MANAGE_FIELDS = (
     75    'applicant_id',
     76    )
     77
     78
     79REGISTRATION_OMIT_PDF_FIELDS = (
     80    'locked',
     81    'suspended',
     82    )
    8383class CustomApplicantsContainerPage(ApplicantsContainerPage):
    8484    """The standard view for regular applicant containers.
     
    140140               and self.context.state in ('paid', 'submitted')
    141141
    142     # Customizations for admission checking payments
    143 
    144     @property
    145     def form_fields(self):
    146         form_fields = super(CustomApplicantDisplayFormPage, self).form_fields
    147         if self.target == 'ictwk':
    148             for field in ICT_WEEK_FIELDS:
     142    @property
     143    def label(self):
     144        if self.target == 'ictwk':
     145            container_title = self.context.__parent__.title
     146            return _('${a} <br /> Registration Record ${b}', mapping = {
     147                'a':container_title, 'b':self.context.application_number})
     148        return super(CustomApplicantDisplayFormPage, self).label
     149
     150    @property
     151    def form_fields(self):
     152        if self.target == 'ictwk':
     153            form_fields = grok.AutoFields(IUnibenRegistration)
     154            for field in REGISTRATION_OMIT_DISPLAY_FIELDS:
    149155                form_fields = form_fields.omit(field)
    150156            return form_fields
     157        form_fields = super(CustomApplicantDisplayFormPage, self).form_fields
    151158        if not self.context.admchecking_fee_paid():
    152159            form_fields = form_fields.omit(
     
    256263
    257264    @property
    258     def form_fields(self):
     265    def label(self):
     266        if self.target == 'ictwk':
     267            container_title = self.context.__parent__.title
     268            return _('${a} <br /> Registration Record ${b}', mapping = {
     269                'a':container_title, 'b':self.context.application_number})
     270        return super(CustomApplicantManageFormPage, self).label
     271
     272    @property
     273    def form_fields(self):
     274        if self.target == 'ictwk':
     275            form_fields = grok.AutoFields(IUnibenRegistration)
     276            for field in REGISTRATION_OMIT_MANAGE_FIELDS:
     277                form_fields = form_fields.omit(field)
     278            return form_fields
    259279        form_fields = super(CustomApplicantManageFormPage, self).form_fields
    260         if self.target == 'ictwk':
    261             for field in ICT_WEEK_FIELDS:
    262                 form_fields = form_fields.omit(field)
    263280        return form_fields
    264281
     
    270287    @property
    271288    def form_fields(self):
     289        if self.target == 'ictwk':
     290            form_fields = grok.AutoFields(IUnibenRegistration)
     291            for field in REGISTRATION_OMIT_EDIT_FIELDS:
     292                form_fields = form_fields.omit(field)
     293            return form_fields
    272294        form_fields = super(CustomApplicantEditFormPage, self).form_fields
    273         if self.target == 'ictwk':
    274             for field in ICT_WEEK_FIELDS:
    275                 form_fields = form_fields.omit(field)
    276         return form_fields
     295        return form_fields
     296
     297    @property
     298    def label(self):
     299        if self.target == 'ictwk':
     300            container_title = self.context.__parent__.title
     301            return _('${a} <br /> Registration Record ${b}', mapping = {
     302                'a':container_title, 'b':self.context.application_number})
     303        return super(CustomApplicantEditFormPage, self).label
    277304
    278305class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage):
     
    328355
    329356    @property
     357    def form_fields(self):
     358        if self.target == 'ictwk':
     359            form_fields = grok.AutoFields(IUnibenRegistration)
     360            for field in REGISTRATION_OMIT_PDF_FIELDS:
     361                form_fields = form_fields.omit(field)
     362            return form_fields
     363        form_fields = super(CustomPDFApplicationSlip, self).form_fields
     364        return form_fields
     365
     366    @property
    330367    def title(self):
    331368        container_title = self.context.__parent__.title
     
    333370        ar_translation = translate(_('Application Record'),
    334371            'waeup.kofa', target_language=portal_language)
    335         if 'afas' in self.target:
     372        if self.target == 'ictwk':
     373            return '%s - Registration Record %s' % (container_title,
     374            self.context.application_number)
     375        elif 'afas' in self.target:
    336376            return 'Federal College of Education (Technical) Asaba - %s %s %s' % (
    337377                container_title, ar_translation,
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py

    r9057 r13814  
     1# -*- coding: utf-8 -*-
    12## $Id$
    23##
     
    2021
    2122from zope import schema
     23from zc.sourcefactory.basic import BasicSourceFactory
    2224from waeup.kofa.applicants.interfaces import (
    2325    IApplicantBaseData,
     
    2527from waeup.kofa.schoolgrades import ResultEntryField
    2628from waeup.kofa.interfaces import (
    27     SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
    28 from waeup.kofa.schema import FormattedDate, TextLineChoice
     29    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
     30    IKofaObject, ContextualDictSourceFactoryBase)
     31from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
    2932from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
    3033from waeup.kofa.applicants.interfaces import contextual_reg_num_source
     
    4043from waeup.uniben.payments.interfaces import ICustomOnlinePayment
    4144
     45
     46REGISTRATION_CATS = {
     47    'corporate': ('Corporate Registration', 250000, 1),
     48    'group': ('Group Registration', 200000, 2),
     49    'individual': ('Individual Registration', 45000, 3),
     50    'student': ('Student Registration', 5000, 4),
     51    'fullpage': ('Full Page', 250000, 5),
     52    'halfpage': ('Half Page', 150000, 6),
     53    'quarterpage': ('Quarter Page', 100000, 7),
     54    }
     55
     56class RegTypesSource(BasicSourceFactory):
     57    """A source that delivers all kinds of registrations.
     58    """
     59    def getValues(self):
     60        sorted_items = sorted(REGISTRATION_CATS.items(),
     61                              key=lambda element: element[1][2])
     62        return [item[0] for item in sorted_items]
     63
     64    def getTitle(self, value):
     65        return u"%s @ ₦ %s" % (
     66            REGISTRATION_CATS[value][0],
     67            REGISTRATION_CATS[value][1])
     68
     69class IUnibenRegistration(IKofaObject):
     70    """A Uniben registrant.
     71    """
     72
     73    suspended = schema.Bool(
     74        title = _(u'Account suspended'),
     75        default = False,
     76        required = False,
     77        )
     78
     79    locked = schema.Bool(
     80        title = _(u'Form locked'),
     81        default = False,
     82        required = False,
     83        )
     84
     85    applicant_id = schema.TextLine(
     86        title = _(u'Registrant Id'),
     87        required = False,
     88        readonly = False,
     89        )
     90
     91    firstname = schema.TextLine(
     92        title = _(u'First Name'),
     93        required = True,
     94        )
     95
     96    middlename = schema.TextLine(
     97        title = _(u'Middle Name'),
     98        required = False,
     99        )
     100
     101    lastname = schema.TextLine(
     102        title = _(u'Last Name (Surname)'),
     103        required = True,
     104        )
     105
     106    #matric_number = schema.TextLine(
     107    #    title = _(u'Matriculation Number'),
     108    #    readonly = False,
     109    #    required = False,
     110    #    )
     111
     112    date_of_birth = FormattedDate(
     113        title = _(u'Date of Birth'),
     114        required = False,
     115        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
     116        show_year = True,
     117        )
     118
     119    place_of_birth = schema.TextLine(
     120        title = _(u'Place of Birth'),
     121        readonly = False,
     122        required = False,
     123        )
     124
     125    nationality = schema.Choice(
     126        vocabulary = nats_vocab,
     127        title = _(u'Nationality'),
     128        required = False,
     129        )
     130
     131    email = schema.ASCIILine(
     132        title = _(u'Email Address'),
     133        required = True,
     134        constraint=validate_email,
     135        )
     136
     137    phone = PhoneNumber(
     138        title = _(u'Phone'),
     139        description = u'',
     140        required = False,
     141        )
     142
     143    perm_address = schema.Text(
     144        title = _(u'Current Local Address'),
     145        required = False,
     146        readonly = False,
     147        )
     148
     149    registration_cats = schema.List(
     150        title = _(u'Registration Categories'),
     151        value_type = schema.Choice(source=RegTypesSource()),
     152        required = True,
     153        default = [],
     154        )
     155
     156
     157
    42158class ICustomUGApplicant(INigeriaUGApplicant):
    43159    """An undergraduate applicant.
     
    57173
    58174
    59 class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
     175class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
     176    IUnibenRegistration):
    60177    """An interface for both types of applicants.
    61178
     
    100217    """
    101218
     219
    102220class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
    103221    """An applicant payment via payment gateways.
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r13615 r13814  
     1# -*- coding: utf-8 -*-
    12## $Id$
    23##
     
    225226        open(path, 'wb').write(self.browser.contents)
    226227        print "Sample nils_application_slip.pdf written to %s" % path
     228
     229    def test_ictwk_application_slip(self):
     230
     231        # Remove required FieldProperty attribute first ...
     232        #delattr(ApplicantsContainer, 'prefix')
     233        # ... and replace by ictw
     234        self.applicantscontainer.prefix = 'ictwk'
     235        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     236        self.slip_path = self.view_path + '/application_slip.pdf'
     237        self.browser.open(self.manage_path)
     238        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     239        self.browser.getControl(name="form.firstname").value = 'John'
     240        self.browser.getControl(name="form.middlename").value = 'Anthony'
     241        self.browser.getControl(name="form.lastname").value = 'Tester'
     242        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
     243        #self.browser.getControl(name="form.sex").value = ['m']
     244        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     245        self.browser.getControl("Save").click()
     246        self.applicant.registration_cats = ['group', 'corporate']
     247        IWorkflowState(self.applicant).setState('submitted')
     248        self.browser.open(self.view_path)
     249        self.assertTrue('Group Registration @ ₦ 200000' in self.browser.contents)
     250        self.browser.open(self.manage_path)
     251        self.browser.getLink("Download application slip").click()
     252        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     253        self.assertEqual(self.browser.headers['Content-Type'],
     254                         'application/pdf')
     255        path = os.path.join(samples_dir(), 'ictwk_application_slip.pdf')
     256        open(path, 'wb').write(self.browser.contents)
     257        print "Sample ictwk_application_slip.pdf written to %s" % path
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r13785 r13814  
    350350            return _('This type of payment has already been made.'), None
    351351        if self._isPaymentDisabled(p_session, category, student):
    352             return _('Payment temporarily disabled.'), None
     352            return _('This category of payments has been disabled.'), None
    353353        payment = createObject(u'waeup.StudentOnlinePayment')
    354354        timestamp = ("%d" % int(time()*10000))[1:]
Note: See TracChangeset for help on using the changeset viewer.