Changeset 8037 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 4 Apr 2012, 06:19:20 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r8033 r8037 32 32 IApplicantsContainer, IApplicantsContainerAdd, 33 33 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils, 34 IApplicant UpdateByRegNo34 IApplicantRegisterUpdate 35 35 ) 36 36 from waeup.kofa.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED … … 869 869 form_fields['phone'].custom_widget = PhoneWidget 870 870 elif self.context.mode == 'update': 871 form_fields = grok.AutoFields(IApplicant UpdateByRegNo).select(872 ' reg_number','email')871 form_fields = grok.AutoFields(IApplicantRegisterUpdate).select( 872 'firstname','reg_number','email') 873 873 return form_fields 874 874 … … 898 898 def register(self, **data): 899 899 if not self.captcha_result.is_valid: 900 # captcha will display error messages automatically.900 # Captcha will display error messages automatically. 901 901 # No need to flash something. 902 902 return … … 908 908 elif self.context.mode == 'update': 909 909 # Update applicant 910 reg_number = data['reg_number'] 910 reg_number = data.get('reg_number','') 911 firstname = data.get('firstname','') 911 912 cat = getUtility(ICatalog, name='applicants_catalog') 912 913 results = list( … … 915 916 applicant = results[0] 916 917 if applicant.password is not None: 917 self.flash(_('Your password has already been set.')) 918 self.flash(_('Your password has already been set. ' 919 'You can proceed to the login page.')) 920 return 921 elif getattr(applicant,'firstname',None) is None: 922 self.flash(_('An error occurred.')) 923 return 924 elif applicant.firstname.lower() != firstname.lower(): 925 self.flash(_('No application record found.')) 918 926 return 919 927 applicant.email = data['email'] -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r8033 r8037 489 489 ) 490 490 491 class IApplicantRegisterUpdate(IApplicant): 492 """Representation of an applicant for first-time registration. 493 494 This interface is used when apllicants use the registration page to 495 update their records. 496 """ 497 reg_number = schema.TextLine( 498 title = u'Registration Number', 499 required = True, 500 ) 501 502 firstname = schema.TextLine( 503 title = _(u'First Name'), 504 required = True, 505 ) 506 507 email = schema.ASCIILine( 508 title = _(u'Email Address'), 509 required = True, 510 constraint=validate_email, 511 ) 512 491 513 class IApplicantOnlinePayment(IOnlinePayment): 492 514 """An applicant payment via payment gateways. -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r8033 r8037 806 806 self.assertEqual(self.browser.url, 807 807 self.container_path + '/registration_complete?email=xx%40yy.zz') 808 # Now we change the application mode and check if applicants 808 return 809 810 def test_register_applicant_update(self): 811 # We change the application mode and check if applicants 809 812 # can find and update imported records instead of creating new records. 810 813 # First we check what happens if record can't be found. 811 814 self.applicantscontainer.mode = 'update' 812 815 self.browser.open(self.container_path + '/register') 813 #self.browser.getControl(name="form.firstname").value = 'John'816 self.browser.getControl(name="form.firstname").value = 'John' 814 817 self.browser.getControl(name="form.reg_number").value = 'anynumber' 815 818 self.browser.getControl(name="form.email").value = 'xx@yy.zz' … … 817 820 self.assertTrue('No application record found.' 818 821 in self.browser.contents) 819 # Now we checkif password has already been set.820 #self.browser.getControl(name="form.firstname").value = 'John'822 # We can't register if password has already been set. 823 self.browser.getControl(name="form.firstname").value = 'John' 821 824 self.browser.getControl(name="form.reg_number").value = '1234' 822 825 self.browser.getControl("Get login credentials").click() … … 828 831 self.applicant.application_number]).context.password = None 829 832 self.browser.open(self.container_path + '/register') 830 #self.browser.getControl(name="form.firstname").value = 'John'833 self.browser.getControl(name="form.firstname").value = 'John' 831 834 self.browser.getControl(name="form.reg_number").value = '1234' 832 835 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 836 self.browser.getControl("Get login credentials").click() 837 self.assertTrue('An error occurred.'in self.browser.contents) 838 # The firstname attribute was None. Let's set this attribute manually 839 # and try to register with a wrong name. 840 self.applicant.firstname = u'John' 841 self.browser.open(self.container_path + '/register') 842 self.browser.getControl(name="form.firstname").value = 'Johnny' 843 self.browser.getControl(name="form.reg_number").value = '1234' 844 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 845 self.browser.getControl("Get login credentials").click() 846 self.assertTrue('No application record found.' 847 in self.browser.contents) 848 # Now we use the correct name. For verification 849 # the name is not case-sensitive. 850 self.browser.getControl(name="form.firstname").value = 'jOhn' 833 851 self.browser.getControl("Get login credentials").click() 834 852 self.assertTrue('Your registration was successful.'
Note: See TracChangeset for help on using the changeset viewer.