Changeset 10831


Ignore:
Timestamp:
10 Dec 2013, 06:24:03 (11 years ago)
Author:
Henrik Bettermann
Message:

Implement a special application procedure. This application is meant for supplementary payments by alumni and other persons who are not students of the portal.

Attention: All custom packages have to be adjusted.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
8 edited

Legend:

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

    r10092 r10831  
    8989        history = IObjectHistory(self)
    9090        return history
     91
     92    @property
     93    def special(self):
     94        return self.__parent__.prefix.startswith('special')
    9195
    9296    @property
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r10655 r10831  
    6060from waeup.kofa.utils.helpers import string_from_bytes, file_size, now
    6161from waeup.kofa.widgets.datewidget import (
    62     FriendlyDateDisplayWidget, FriendlyDateDisplayWidget,
     62    FriendlyDateDisplayWidget,
    6363    FriendlyDatetimeDisplayWidget)
    6464from waeup.kofa.widgets.htmlwidget import HTMLDisplayWidget
     
    522522    grok.require('waeup.viewApplication')
    523523    grok.template('applicantdisplaypage')
    524     form_fields = grok.AutoFields(IApplicant).omit(
    525         'locked', 'course_admitted', 'password', 'suspended')
    526524    label = _('Applicant')
    527525    pnav = 3
    528526    hide_hint = False
     527
     528    @property
     529    def form_fields(self):
     530        if self.context.special:
     531            form_fields = grok.AutoFields(IApplicant).select(
     532                'applicant_id', 'firstname', 'middlename', 'lastname',
     533                'reg_number', 'date_of_birth', 'email', 'special_application')
     534        else:
     535            form_fields = grok.AutoFields(IApplicant).omit(
     536                'locked', 'course_admitted', 'password', 'suspended',
     537                'special_application')
     538        return form_fields
    529539
    530540    @property
     
    650660        container = self.context.__parent__
    651661        payment = createObject(self.factory)
    652         error = applicants_utils.setPaymentDetails(container, payment)
     662        error = applicants_utils.setPaymentDetails(
     663            container, payment, self.context)
    653664        if error is not None:
    654665            self.flash(error)
     
    796807    grok.name('manage')
    797808    grok.require('waeup.manageApplication')
    798     form_fields = grok.AutoFields(IApplicant)
    799     form_fields['student_id'].for_display = True
    800     form_fields['applicant_id'].for_display = True
    801809    grok.template('applicanteditpage')
    802810    manage_applications = True
     
    804812    display_actions = [[_('Save'), _('Final Submit')],
    805813        [_('Add online payment ticket'),_('Remove selected tickets')]]
     814
     815    @property
     816    def form_fields(self):
     817        if self.context.special:
     818            form_fields = grok.AutoFields(IApplicant).select(
     819                'applicant_id', 'firstname', 'middlename', 'lastname',
     820                'reg_number', 'date_of_birth', 'email', 'special_application',
     821                'locked')
     822        else:
     823            form_fields = grok.AutoFields(IApplicant)
     824            form_fields['student_id'].for_display = True
     825            form_fields['applicant_id'].for_display = True
     826        return form_fields
    806827
    807828    @property
     
    941962    grok.name('edit')
    942963    grok.require('waeup.handleApplication')
    943     form_fields = grok.AutoFields(IApplicantEdit).omit(
    944         'locked', 'course_admitted', 'student_id',
    945         'suspended'
    946         )
    947     form_fields['applicant_id'].for_display = True
    948     form_fields['reg_number'].for_display = True
    949964    grok.template('applicanteditpage')
    950965    manage_applications = False
    951966    submit_state = PAID
     967
     968    @property
     969    def form_fields(self):
     970        if self.context.special:
     971            form_fields = grok.AutoFields(IApplicantEdit).select(
     972                'applicant_id', 'firstname', 'middlename', 'lastname',
     973                'reg_number', 'date_of_birth', 'email', 'special_application')
     974        else:
     975            form_fields = grok.AutoFields(IApplicantEdit).omit(
     976                'locked', 'course_admitted', 'student_id',
     977                'suspended', 'special_application'
     978                )
     979            form_fields['applicant_id'].for_display = True
     980            form_fields['reg_number'].for_display = True
     981        return form_fields
    952982
    953983    @property
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r10384 r10831  
    3636from waeup.kofa.schema import PhoneNumber
    3737from waeup.kofa.students.vocabularies import GenderSource, RegNumberSource
    38 from waeup.kofa.university.vocabularies import AppCatSource, CertificateSource
     38from waeup.kofa.university.vocabularies import (
     39    AppCatSource, CertificateSource, SpecialApplicationSource)
    3940
    4041#: Maximum upload size for applicant passport photographs (in bytes)
     
    442443        )
    443444
     445    special_application = schema.Choice(
     446        title = _(u'Special Application'),
     447        source = SpecialApplicationSource(),
     448        required = False,
     449        )
     450
    444451class IApplicant(IApplicantBaseData):
    445452    """An applicant.
     
    497504        readonly = True,
    498505        )
     506    special_application = schema.Choice(
     507        title = _(u'Special Application'),
     508        source = SpecialApplicationSource(),
     509        required = True,
     510        )
    499511
    500512IApplicantEdit['email'].order = IApplicantEdit[
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r10655 r10831  
    868868            in logcontent)
    869869        return
     870
     871
     872    def test_pay_special_fee(self):
     873        # Add special application container
     874        container_name = u'special%s' % session_1
     875        applicantscontainer = ApplicantsContainer()
     876        applicantscontainer.code = container_name
     877        applicantscontainer.prefix = 'special'
     878        applicantscontainer.year = session_1
     879        applicantscontainer.title = u'This is a special app container'
     880        applicantscontainer.application_category = 'no'
     881        applicantscontainer.mode = 'create'
     882        applicantscontainer.strict_deadline = True
     883        delta = timedelta(days=10)
     884        applicantscontainer.startdate = datetime.now(pytz.utc) - delta
     885        applicantscontainer.enddate = datetime.now(pytz.utc) + delta
     886        self.app['applicants'][container_name] = applicantscontainer
     887        # Add an applicant
     888        applicant = createObject('waeup.Applicant')
     889        # reg_number is the only field which has to be preset here
     890        # because managers are allowed to edit this required field
     891        applicant.reg_number = u'12345'
     892        self.app['applicants'][container_name].addApplicant(applicant)
     893        IUserAccount(
     894            self.app['applicants'][container_name][
     895            applicant.application_number]).setPassword('apwd')
     896        # Add session configuration object
     897        configuration = SessionConfiguration()
     898        configuration.academic_session = session_1
     899        configuration.transcript_fee = 200.0
     900        self.app['configuration'].addSessionConfiguration(configuration)
     901        # Login
     902        self.browser.open(self.login_path)
     903        self.browser.getControl(
     904            name="form.login").value = applicant.applicant_id
     905        self.browser.getControl(name="form.password").value = 'apwd'
     906        self.browser.getControl("Login").click()
     907        self.browser.getLink("Edit application record").click()
     908        self.browser.getControl(name="form.firstname").value = 'John'
     909        self.browser.getControl(name="form.middlename").value = 'Anthony'
     910        self.browser.getControl(name="form.lastname").value = 'Tester'
     911        self.browser.getControl(name="form.special_application").value = [
     912            'transcript']
     913        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
     914        #self.browser.getControl(name="form.sex").value = ['m']
     915        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     916        self.browser.getControl("Save").click()
     917        self.browser.getControl("Add online payment ticket").click()
     918        self.assertMatches('...Payment ticket created...',
     919                           self.browser.contents)
     920        self.assertTrue(
     921            '<span>Transcript Fee</span>' in self.browser.contents)
     922        self.assertTrue(
     923            'This is a special app container' in self.browser.contents)
     924        self.assertTrue(
     925            '<span>200.0</span>' in self.browser.contents)
     926        return
     927
    870928
    871929    def test_duplicate_choice(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py

    r10654 r10831  
    142142            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    143143            'history,lastname,locked,middlename,notice,password,phone,'
    144             'reg_number,sex,state,'
     144            'reg_number,sex,special_application,state,'
    145145            'student_id,suspended,container_code\r\n'
    146146            'dp2011_654321,,654321,,,,,Anna Tester,,Anna,'
     
    148148        self.assertTrue(
    149149            'Application initialized by system\'],Tester,'
    150             '0,,,,,,,initialized,,0,dp2011\r\n'
     150            '0,,,,,,,,initialized,,0,dp2011\r\n'
    151151            in result)
    152152        return
     
    166166            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    167167            'history,lastname,locked,middlename,notice,password,phone,'
    168             'reg_number,sex,state,'
     168            'reg_number,sex,special_application,state,'
    169169            'student_id,suspended,container_code\r\n'
    170170            'dp2011_654321,,654321,CERT1,CERT1,CERT1,1981-02-04#,'
     
    174174            'Application initialized by system\'],'
    175175            'Tester,0,M.,"Some notice\nin lines.",any password,'
    176             '+234-123-12345#,123456,f,initialized,,0,dp2011\r\n'
     176            '+234-123-12345#,123456,f,,initialized,,0,dp2011\r\n'
    177177            in result)
    178178
     
    190190            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    191191            'history,lastname,locked,middlename,notice,password,phone,'
    192             'reg_number,sex,state,'
     192            'reg_number,sex,special_application,state,'
    193193            'student_id,suspended,container_code\r\n'
    194194            'dp2011_654321,,654321,CERT1,CERT1,CERT1,1981-02-04#,'
     
    198198            'Application initialized by system\'],'
    199199            'Tester,0,M.,"Some notice\nin lines.",any password,'
    200             '+234-123-12345#,123456,f,initialized,,0,dp2011\r\n'
     200            '+234-123-12345#,123456,f,,initialized,,0,dp2011\r\n'
    201201            in result)
    202202        return
     
    212212            'course_admitted,date_of_birth,display_fullname,email,firstname,'
    213213            'history,lastname,locked,middlename,notice,password,phone,'
    214             'reg_number,sex,state,'
     214            'reg_number,sex,special_application,state,'
    215215            'student_id,suspended,container_code\r\n'
    216216            'dp2011_654321,,654321,CERT1,CERT1,CERT1,1981-02-04#,'
     
    220220            'Application initialized by system\'],'
    221221            'Tester,0,M.,"Some notice\nin lines.",any password,'
    222             '+234-123-12345#,123456,f,initialized,,0,dp2011\r\n'
     222            '+234-123-12345#,123456,f,,initialized,,0,dp2011\r\n'
    223223            in result)
    224224        # In empty container no applicants are exported
     
    233233            'course2,course_admitted,date_of_birth,display_fullname,email,'
    234234            'firstname,history,lastname,locked,middlename,notice,password,'
    235             'phone,reg_number,sex,state,student_id,suspended,container_code\r\n'
    236             in result)
    237         return
     235            'phone,reg_number,sex,special_application,state,student_id,'
     236            'suspended,container_code\r\n'
     237            in result)
     238        return
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py

    r10208 r10831  
    3535    APP_TYPES_DICT = {
    3636      'app': ['General Studies', 'APP'],
     37      'special': ['Special Application', 'SPE'],
    3738      }
    3839
     
    4243      }
    4344
    44     def setPaymentDetails(self, container, payment):
     45    def setPaymentDetails(self, container, payment, applicant):
    4546        """Set the payment data of an applicant.
    4647        """
     
    5657                return _(u'Session configuration object is not available.')
    5758            payment.amount_auth = session_config.application_fee
     59            payment.p_category = 'application'
     60        if container.prefix.startswith('special'):
     61            fee_name = applicant.special_application + '_fee'
     62            payment.amount_auth = getattr(session_config, fee_name, 0.0)
     63            payment.p_category = applicant.special_application
    5864        payment.p_id = "p%s" % timestamp
    5965        payment.p_item = container.title
    6066        payment.p_session = container.year
    61         payment.p_category = 'application'
    6267        return None
    6368
  • main/waeup.kofa/trunk/src/waeup/kofa/university/vocabularies.py

    r10436 r10831  
    121121    def getTitle(self, context, value):
    122122        return "%s - %s" % (value.code, value.title)
     123
     124class SpecialApplicationSource(ContextualDictSourceFactoryBase):
     125    """A special application source delivers all types of
     126    applications which are not linked with certificates.
     127    """
     128    #: name of dict to deliver from kofa utils.
     129    DICT_NAME = 'SPECIAL_APP_DICT'
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r10449 r10831  
    150150        'regular': 'Regular Hostel',
    151151        'blocked': 'Blocked Hostel',
    152         'pd': 'Postgraduate Hostel'
     152        'pg': 'Postgraduate Hostel'
     153        }
     154
     155    SPECIAL_APP_DICT = {
     156        'transcript': 'Transcript Fee Payment',
    153157        }
    154158
Note: See TracChangeset for help on using the changeset viewer.