Changeset 16848 for main


Ignore:
Timestamp:
28 Feb 2022, 22:19:59 (3 years ago)
Author:
Henrik Bettermann
Message:

Subjects are certificates stored in Kofa.

Do only allow one application per subject-school combination.

Location:
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants
Files:
3 edited

Legend:

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

    r15961 r16848  
    191191        counter = 0
    192192        for appl in container.values():
    193             if appl.state in (SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED) \
    194                 and (appl.school1 == self.context.school1 \
    195                      or appl.school1 == data.get('school1')):
    196                 counter += 1
     193            if appl.state in (SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED):
     194                if appl.school1 == self.context.school1 \
     195                    or appl.school1 == data.get('school1'):
     196                    counter += 1
     197                    if appl != self.context \
     198                        and (appl.subj_comb == self.context.subj_comb \
     199                            or appl.subj_comb == data.get('subj_comb')):
     200                        return True
    197201                if counter == 10:
    198202                    return True
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py

    r16844 r16848  
    158158        title = _(u'Subject Combination'),
    159159        source = AppCatCertificateSource(),
    160         required = False,
     160        required = True,
    161161        )
    162162
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py

    r15635 r16848  
    2121import pytz
    2222import os
     23import grok
     24from zope.event import notify
    2325from zope.component.hooks import setSite, clearSite
    2426from zope.component import createObject
     
    9496        self.tpucontainer.code = u'tpu%s' % session
    9597        self.tpucontainer.prefix = u'tpu'
    96         self.tpucontainer.application_category = u'no'
     98        self.tpucontainer.application_category = u'tpu'
    9799        self.tpucontainer.year = session
    98100        self.tpucontainer.application_fee = 300.0
     
    190192       
    191193    def test_final_submit_tpu(self):
     194        self.certificate.application_category = 'tpu'
     195        notify(grok.ObjectModifiedEvent(self.certificate))
    192196        IWorkflowState(self.tpuapplicant).setState('paid')
    193197        self.browser.open(self.login_path)
     
    199203        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
    200204        self.browser.getControl(name="form.school1").value = ['s0010']
     205        self.browser.getControl(name="form.subj_comb").value = ['CERT1']
    201206        image = open(SAMPLE_IMAGE, 'rb')
    202207        ctrl = self.browser.getControl(name='form.passport')
     
    226231            in self.browser.contents)
    227232        self.assertEqual(self.tpuapplicant.state, 'paid')
     233        # Create one applicant with same subject and same school
     234        dummy = createObject(u'waeup.Applicant')
     235        dummy.firstname = u'John'
     236        dummy.lastname = u'Doe %s' %i
     237        dummy.school1 = 's0012'
     238        dummy.subj_comb = self.certificate
     239        self.app['applicants'][
     240            self.tpucontainer.code].addApplicant(dummy)
     241        IWorkflowState(dummy).setState('submitted')
     242        self.browser.open(self.tpuapplicant_path + '/edit')
     243        self.browser.getControl(name="form.school1").value = ['s0012']
     244        self.browser.getControl(name="form.subj_comb").value = ['CERT1']
     245        self.browser.getControl("Finally Submit").click()
     246        self.assertTrue("Maximum number of applications per school exceeded."
     247            in self.browser.contents)
     248        self.assertEqual(self.tpuapplicant.state, 'paid')
     249        self.browser.open(self.tpuapplicant_path + '/edit')
     250        self.browser.getControl(name="form.school1").value = ['s0013']
     251        self.browser.getControl(name="form.subj_comb").value = ['CERT1']
     252        self.browser.getControl("Finally Submit").click()
     253        self.assertTrue(
     254            'Application submitted' in self.browser.contents)
     255        self.assertEqual(self.tpuapplicant.state, 'submitted')
    228256        return
    229257
Note: See TracChangeset for help on using the changeset viewer.