Changeset 15635 for main/waeup.fceokene


Ignore:
Timestamp:
3 Oct 2019, 20:47:58 (5 years ago)
Author:
Henrik Bettermann
Message:

If applicants haven't saved the form before submission (which is allowed), the attribute was not set and wasn't counted. This use case was not covered by the test.

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

    r15027 r15635  
    197197        return form_fields
    198198
    199     @property
    200     def _student_per_school_exceeded(self):
     199    def _student_per_school_exceeded(self, data):
    201200        container = self.context.__parent__
    202201        counter = 0
    203         if self.context.school1:
    204             for appl in container.values():
    205                 if appl.state in (SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED) \
    206                     and appl.school1 == self.context.school1:
    207                     counter += 1
    208                     if counter == 10:
    209                         return True
     202        for appl in container.values():
     203            if appl.state in (SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED) \
     204                and (appl.school1 == self.context.school1 \
     205                     or appl.school1 == data.get('school1')):
     206                counter += 1
     207                if counter == 10:
     208                    return True
    210209        return False
    211210
    212     def dataNotComplete(self):
    213         if self._student_per_school_exceeded:
     211    def dataNotComplete(self, data):
     212        if self._student_per_school_exceeded(data):
    214213            return ("1st Choice TPZ and School: "
    215214                    "Maximum number of applications per school exceeded. "
    216215                    "Please select another first choice school.")
    217         super(CustomApplicantEditFormPage, self).dataNotComplete()
     216        super(CustomApplicantEditFormPage, self).dataNotComplete(data)
    218217        return
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py

    r15594 r15635  
    161161        )
    162162
    163     #school2 = schema.Choice(
    164     #    title = _(u'2nd Choice TPZ and School'),
    165     #    source = SchoolSource(),
    166     #    required = False,
    167     #    )
    168 
    169     #school3 = schema.Choice(
    170     #    title = _(u'3rd Choice TPZ and School'),
    171     #    source = SchoolSource(),
    172     #    required = False,
    173     #    )
    174 
    175163class ICustomUGApplicant(INigeriaUGApplicant):
    176164    """An undergraduate applicant.
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py

    r15027 r15635  
    189189        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    190190       
    191 
    192191    def test_final_submit_tpu(self):
    193192        IWorkflowState(self.tpuapplicant).setState('paid')
     
    209208        self.assertTrue(
    210209            'Application submitted' in self.browser.contents)
    211         # Create 20 applicants who already selected s0010
     210        # Create 10 applicants who already selected s0010
    212211        for i in range(1,11):
    213             tpuapplicant = createObject(u'waeup.Applicant')
    214             tpuapplicant.firstname = u'John'
    215             tpuapplicant.lastname = u'Doe %s' %i
    216             tpuapplicant.school1 = 's0010'
     212            dummy = createObject(u'waeup.Applicant')
     213            dummy.firstname = u'John'
     214            dummy.lastname = u'Doe %s' %i
     215            dummy.school1 = 's0010'
    217216            self.app['applicants'][
    218                 self.tpucontainer.code].addApplicant(tpuapplicant)
    219             IWorkflowState(tpuapplicant).setState('submitted')
     217                self.tpucontainer.code].addApplicant(dummy)
     218            IWorkflowState(dummy).setState('submitted')
    220219        IWorkflowState(self.tpuapplicant).setState('paid')
     220        self.tpuapplicant.school1 = None
    221221        self.tpuapplicant.locked = False
    222222        self.browser.open(self.tpuapplicant_path + '/edit')
     223        self.browser.getControl(name="form.school1").value = ['s0010']
    223224        self.browser.getControl("Finally Submit").click()
    224225        self.assertTrue("Maximum number of applications per school exceeded."
Note: See TracChangeset for help on using the changeset viewer.