Changeset 13544 for main


Ignore:
Timestamp:
16 Dec 2015, 06:07:20 (9 years ago)
Author:
Henrik Bettermann
Message:

Use new ITranscriptApplicant interface for application.

Adjust importer and exporter.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/applicants
Files:
1 added
5 edited

Legend:

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

    r11617 r13544  
    2323from kofacustom.nigeria.applicants.applicant import NigeriaApplicant
    2424from waeup.aaue.applicants.interfaces import(
    25     ICustomApplicant, ICustomUGApplicantEdit, ICustomPGApplicantEdit, IPUTMEApplicantEdit)
     25    ICustomApplicant, ICustomUGApplicantEdit, ICustomPGApplicantEdit,
     26    IPUTMEApplicantEdit, ITranscriptApplicant)
    2627
    2728class CustomApplicant(NigeriaApplicant):
    2829
    2930    grok.implements(ICustomApplicant, ICustomUGApplicantEdit,
    30         ICustomPGApplicantEdit, IPUTMEApplicantEdit)
     31        ICustomPGApplicantEdit, IPUTMEApplicantEdit, ITranscriptApplicant)
    3132    grok.provides(ICustomApplicant)
    3233
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/browser.py

    r13541 r13544  
    2626from waeup.kofa.utils.helpers import string_from_bytes, file_size
    2727from waeup.kofa.applicants.browser import ApplicantCheckStatusPage
    28 from waeup.kofa.applicants.interfaces import ISpecialApplicant
    2928from waeup.kofa.applicants.viewlets import PDFActionButton
    3029from waeup.aaue.interfaces import MessageFactory as _
     
    4140    UG_OMIT_EDIT_FIELDS)
    4241from waeup.aaue.applicants.interfaces import (
    43     ICustomApplicant,
    4442    ICustomUGApplicant,
    45     ICustomUGApplicantEdit
     43    ICustomUGApplicantEdit,
     44    ITranscriptApplicant
    4645    )
    4746
     
    7170    def form_fields(self):
    7271        if self.target is not None and self.target == 'trans':
    73             return grok.AutoFields(ISpecialApplicant).omit(
    74                 'locked', 'suspended', 'special_application')
     72            form_fields = grok.AutoFields(ITranscriptApplicant).omit(
     73                'locked', 'suspended')
     74            form_fields['dispatch_address'].custom_widget = BytesDisplayWidget
     75            form_fields['perm_address'].custom_widget = BytesDisplayWidget
     76            return form_fields
    7577        # AAUE is using the same interface for all regular applications.
    7678        form_fields = grok.AutoFields(ICustomUGApplicant)
     
    160162    def form_fields(self):
    161163        if self.target is not None and self.target == 'trans':
    162             form_fields = grok.AutoFields(ISpecialApplicant).omit(
    163                 'special_application')
     164            form_fields = grok.AutoFields(ITranscriptApplicant)
    164165            form_fields['applicant_id'].for_display = True
    165166            return form_fields
     
    188189    def form_fields(self):
    189190        if self.target is not None and self.target == 'trans':
    190             form_fields = grok.AutoFields(ISpecialApplicant).omit(
    191                 'locked', 'suspended', 'special_application')
     191            form_fields = grok.AutoFields(ITranscriptApplicant).omit(
     192                'locked', 'suspended')
    192193            form_fields['applicant_id'].for_display = True
    193194            return form_fields
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/export.py

    r13093 r13544  
    2323from kofacustom.nigeria.applicants.interfaces import (
    2424    INigeriaUGApplicant, INigeriaPGApplicant)
    25 from waeup.aaue.applicants.interfaces import ICustomUGApplicant
     25from waeup.aaue.applicants.interfaces import (
     26    ICustomUGApplicant, ITranscriptApplicant)
    2627
    2728class CustomApplicantExporter(NigeriaApplicantExporter):
     
    3334        #INigeriaUGApplicant.names() +
    3435        INigeriaPGApplicant.names() +
    35         IApplicantBaseData.names()
     36        IApplicantBaseData.names() +
     37        ITranscriptApplicant.names()
    3638        )))
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/interfaces.py

    r11542 r13544  
    2727from waeup.kofa.interfaces import (
    2828    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
    29 from waeup.kofa.schema import FormattedDate, TextLineChoice
    30 from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
     29from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
     30from waeup.kofa.interfaces import IKofaObject
     31from waeup.kofa.students.vocabularies import (
     32    nats_vocab, GenderSource, StudyLevelSource)
    3133from waeup.kofa.applicants.interfaces import (
    3234    contextual_reg_num_source,
    3335    IApplicantBaseData)
     36from waeup.kofa.university.vocabularies import StudyModeSource
    3437from kofacustom.nigeria.applicants.interfaces import (
    3538    LGASource, high_qual, high_grade, exam_types,
     
    279282    """
    280283
    281 class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
    282     """An interface for both types of applicants.
     284class ITranscriptApplicant(IKofaObject):
     285    """A transcript applicant.
     286    """
     287
     288    suspended = schema.Bool(
     289        title = _(u'Account suspended'),
     290        default = False,
     291        required = False,
     292        )
     293
     294    locked = schema.Bool(
     295        title = _(u'Form locked'),
     296        default = False,
     297        required = False,
     298        )
     299
     300    applicant_id = schema.TextLine(
     301        title = _(u'Applicant Id'),
     302        required = False,
     303        readonly = False,
     304        )
     305
     306    firstname = schema.TextLine(
     307        title = _(u'First Name'),
     308        required = True,
     309        )
     310
     311    middlename = schema.TextLine(
     312        title = _(u'Middle Name'),
     313        required = False,
     314        )
     315
     316    lastname = schema.TextLine(
     317        title = _(u'Last Name (Surname)'),
     318        required = True,
     319        )
     320
     321    matric_number = schema.TextLine(
     322        title = _(u'Matriculation Number'),
     323        readonly = False,
     324        required = True,
     325        )
     326
     327    date_of_birth = FormattedDate(
     328        title = _(u'Date of Birth'),
     329        required = False,
     330        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
     331        show_year = True,
     332        )
     333
     334    place_of_birth = schema.TextLine(
     335        title = _(u'Place of Birth'),
     336        readonly = False,
     337        required = False,
     338        )
     339
     340    nationality = schema.Choice(
     341        vocabulary = nats_vocab,
     342        title = _(u'Nationality'),
     343        required = False,
     344        )
     345
     346    email = schema.ASCIILine(
     347        title = _(u'Email Address'),
     348        required = True,
     349        constraint=validate_email,
     350        )
     351
     352    phone = PhoneNumber(
     353        title = _(u'Phone'),
     354        description = u'',
     355        required = False,
     356        )
     357
     358    perm_address = schema.Text(
     359        title = _(u'Current Local Address'),
     360        required = False,
     361        readonly = False,
     362        )
     363
     364    dispatch_address = schema.Text(
     365        title = _(u'Dispatch Address'),
     366        description = u'Address to which transcript should be posted.',
     367        required = False,
     368        readonly = False,
     369        )
     370
     371    entry_mode = schema.Choice(
     372        title = _(u'Entry Mode'),
     373        source = StudyModeSource(),
     374        required = False,
     375        readonly = False,
     376        )
     377
     378    entry_session = schema.Choice(
     379        title = _(u'Entry Session'),
     380        source = academic_sessions_vocab,
     381        required = False,
     382        readonly = False,
     383        )
     384
     385    end_session = schema.Choice(
     386        title = _(u'End Session'),
     387        source = academic_sessions_vocab,
     388        required = False,
     389        readonly = False,
     390        )
     391
     392    course_studied = schema.Choice(
     393        title = _(u'Course of Study / Degree'),
     394        source = CertificateSource(),
     395        required = False,
     396        readonly = False,
     397        )
     398
     399    purpose = schema.TextLine(
     400        title = _(u'Purpose of this Application'),
     401        readonly = False,
     402        required = False,
     403        )
     404
     405    course_changed = schema.Choice(
     406        title = _(u'Change of Study Course'),
     407        description = u'If yes, select previous course of study.',
     408        source = CertificateSource(),
     409        readonly = False,
     410        required = False,
     411        )
     412
     413    change_level = schema.Choice(
     414        title = _(u'Change Level'),
     415        description = u'If yes, select level at which you changed course of study.',
     416        source = StudyLevelSource(),
     417        required = False,
     418        readonly = False,
     419        )
     420
     421
     422class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
     423    ITranscriptApplicant):
     424    """An interface for all three types of applicants.
    283425
    284426    Attention: The ICustomPGApplicant field seetings will be overwritten
     
    355497    """
    356498
     499
     500
  • main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py

    r11755 r13544  
    1717##
    1818import grok
     19import datetime
     20import pytz
    1921from zope.event import notify
    2022from zope.component import createObject, getUtility
    2123from waeup.kofa.configuration import SessionConfiguration
     24from waeup.kofa.applicants.container import ApplicantsContainer
    2225from waeup.aaue.testing import FunctionalLayer
    2326from waeup.kofa.applicants.tests.test_browser import (
     
    6568                 'application/pdf')
    6669        return
     70
     71    def test_transcript_application_manage(self):
     72        # Add trans applicants container
     73        self.transcontainer = ApplicantsContainer()
     74        self.transcontainer.mode = 'create'
     75        self.transcontainer.code = u'trans%s' % session_1
     76        self.transcontainer.prefix = u'trans'
     77        self.transcontainer.application_category = u'no'
     78        self.transcontainer.year = session_1
     79        self.transcontainer.application_fee = 300.0
     80        self.transcontainer.title = u'This is the trans%s container' % session_1
     81        self.app['applicants'][self.transcontainer.code] = self.transcontainer
     82        delta = datetime.timedelta(days=10)
     83        self.transcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
     84        self.transcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
     85        # Add applicant
     86        transapplicant = createObject(u'waeup.Applicant')
     87        transapplicant.firstname = u'Anna'
     88        transapplicant.lastname = u'Post'
     89        self.app['applicants'][self.transcontainer.code].addApplicant(transapplicant)
     90        self.transapplication_number = transapplicant.application_number
     91        self.transapplicant = self.app['applicants'][self.transcontainer.code][
     92            self.transapplication_number]
     93        self.transapplicant_path = ('http://localhost/app/applicants/trans%s/%s'
     94            % (session_1, self.transapplication_number))
     95        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     96        self.browser.open(self.transapplicant_path)
     97        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     98        self.assertTrue("Dispatch Address" in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.