Changeset 14499
- Timestamp:
- 3 Feb 2017, 07:54:44 (8 years ago)
- Location:
- main/waeup.fceokene/trunk/src/waeup/fceokene/applicants
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/browser.py
r13877 r14499 28 28 from waeup.kofa.interfaces import IKofaUtils 29 29 from waeup.kofa.browser.interfaces import IPDFCreator 30 from waeup.kofa.applicants.workflow import ( 31 SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED) 30 32 31 33 from kofacustom.nigeria.applicants.browser import ( … … 194 196 form_fields['reg_number'].for_display = True 195 197 return form_fields 198 199 @property 200 def _student_per_school_exceeded(self): 201 container = self.context.__parent__ 202 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 == 20: 209 return True 210 return False 211 212 def dataNotComplete(self): 213 if self._student_per_school_exceeded: 214 return ("1st Choice TPZ and School: " 215 "Maximum number of applications per school exceeded. " 216 "Please select another first choice school.") 217 super(CustomApplicantEditFormPage, self).dataNotComplete() 218 return -
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py
r14335 r14499 57 57 58 58 class SchoolSource(BasicSourceFactory): 59 """A source that delivers all kinds of registrations.59 """A source that delivers all kinds of schools. 60 60 """ 61 61 def getValues(self): … … 65 65 return [item[0] for item in sorted_items] 66 66 67 def getToken(self, value): 68 return value 69 67 70 def getTitle(self, value): 68 71 return u"%s: %s -- %s" % ( … … 153 156 title = _(u'1st Choice TPZ and School'), 154 157 source = SchoolSource(), 155 required = False,158 required = True, 156 159 ) 157 160 -
main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py
r10876 r14499 20 20 import datetime 21 21 import pytz 22 import os 22 23 from zope.component.hooks import setSite, clearSite 23 24 from zope.component import createObject 24 25 from zope.testbrowser.testing import Browser 26 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 25 27 from waeup.kofa.app import University 26 28 from waeup.kofa.university.faculty import Faculty 27 29 from waeup.kofa.university.department import Department 28 30 from waeup.kofa.testing import FunctionalTestCase 31 from waeup.kofa.interfaces import ( 32 IExtFileStore, IFileStoreNameChooser, IUserAccount, IJobManager) 29 33 from waeup.kofa.applicants.container import ApplicantsContainer 30 34 from waeup.fceokene.testing import FunctionalLayer 31 35 32 36 session = datetime.datetime.now().year - 2 37 SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg') 33 38 34 39 class ApplicantUITest(FunctionalTestCase): … … 53 58 # to access grok.getSite() and should get our new app then 54 59 setSite(app) 60 61 self.login_path = 'http://localhost/app/login' 55 62 56 63 # Add bec applicants container … … 82 89 self.putmecontainer.enddate = datetime.datetime.now(pytz.utc) + delta 83 90 91 # Add tpu applicants container 92 self.tpucontainer = ApplicantsContainer() 93 self.tpucontainer.mode = 'create' 94 self.tpucontainer.code = u'tpu%s' % session 95 self.tpucontainer.prefix = u'tpu' 96 self.tpucontainer.application_category = u'no' 97 self.tpucontainer.year = session 98 self.tpucontainer.application_fee = 300.0 99 self.tpucontainer.title = u'This is the tpu%s container' % session 100 self.app['applicants'][self.tpucontainer.code] = self.tpucontainer 101 delta = datetime.timedelta(days=10) 102 self.tpucontainer.startdate = datetime.datetime.now(pytz.utc) - delta 103 self.tpucontainer.enddate = datetime.datetime.now(pytz.utc) + delta 104 84 105 # Populate university 85 106 self.certificate = createObject('waeup.Certificate') … … 115 136 % (session, self.putmeapplication_number)) 116 137 138 tpuapplicant = createObject(u'waeup.Applicant') 139 tpuapplicant.firstname = u'Michelle' 140 tpuapplicant.lastname = u'Obama' 141 self.app['applicants'][self.tpucontainer.code].addApplicant(tpuapplicant) 142 self.tpuapplication_number = tpuapplicant.application_number 143 self.tpuapplicant = self.app['applicants'][self.tpucontainer.code][ 144 self.tpuapplication_number] 145 self.tpuapplicant_path = ('http://localhost/app/applicants/tpu%s/%s' 146 % (session, self.tpuapplication_number)) 147 IUserAccount( 148 self.app['applicants'][self.tpucontainer.code][ 149 self.tpuapplicant.application_number]).setPassword('apwd') 150 117 151 self.browser = Browser() 118 152 self.browser.handleErrors = False … … 124 158 return 125 159 126 def fill_correct_values(self):127 self.browser.getControl(name="form.reg_number").value = '1234'128 self.browser.getControl(name="form.firstname").value = 'John'129 self.browser.getControl(name="form.lastname").value = 'Tester'130 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'131 self.browser.getControl(name="form.lga").value = ['foreigner']132 self.browser.getControl(name="form.nationality").value = ['NG']133 self.browser.getControl(name="form.sex").value = ['m']134 self.browser.getControl(name="form.email").value = 'xx@yy.zz'135 136 160 def test_manage_and_view_bec_applicant(self): 137 161 # Managers can manage bec applicants. … … 164 188 self.browser.open(self.putmeapplicant_path + '/application_slip.pdf') 165 189 self.assertEqual(self.browser.headers['Status'], '200 Ok') 190 191 192 def test_final_submit_tpu(self): 193 IWorkflowState(self.tpuapplicant).setState('paid') 194 self.browser.open(self.login_path) 195 self.browser.getControl( 196 name="form.login").value = self.tpuapplicant.applicant_id 197 self.browser.getControl(name="form.password").value = 'apwd' 198 self.browser.getControl("Login").click() 199 self.browser.open(self.tpuapplicant_path + '/edit') 200 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 201 self.browser.getControl(name="form.school1").value = ['s0010'] 202 image = open(SAMPLE_IMAGE, 'rb') 203 ctrl = self.browser.getControl(name='form.passport') 204 file_ctrl = ctrl.mech_control 205 file_ctrl.add_file(image, filename='myphoto.jpg') 206 self.browser.getControl(name="confirm_passport").value = True 207 self.browser.getControl("Save").click() 208 self.browser.getControl("Finally Submit").click() 209 self.assertTrue( 210 'Application submitted' in self.browser.contents) 211 # Create 20 applicants who already selected s0010 212 for i in range(1,21): 213 tpuapplicant = createObject(u'waeup.Applicant') 214 tpuapplicant.firstname = u'John' 215 tpuapplicant.lastname = u'Doe %s' %i 216 tpuapplicant.school1 = 's0010' 217 self.app['applicants'][ 218 self.tpucontainer.code].addApplicant(tpuapplicant) 219 IWorkflowState(tpuapplicant).setState('submitted') 220 IWorkflowState(self.tpuapplicant).setState('paid') 221 self.tpuapplicant.locked = False 222 self.browser.open(self.tpuapplicant_path + '/edit') 223 self.browser.getControl("Finally Submit").click() 224 self.assertTrue("Maximum number of applications per school exceeded." 225 in self.browser.contents) 226 self.assertEqual(self.tpuapplicant.state, 'paid') 166 227 return 228
Note: See TracChangeset for help on using the changeset viewer.