Changeset 8033
- Timestamp:
- 3 Apr 2012, 20:40:17 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r8014 r8033 24 24 from datetime import datetime, date 25 25 from zope.component import getUtility, createObject, getAdapter 26 from zope.catalog.interfaces import ICatalog 26 27 from zope.i18n import translate 27 28 from hurry.workflow.interfaces import ( … … 30 31 IApplicant, IApplicantEdit, IApplicantsRoot, 31 32 IApplicantsContainer, IApplicantsContainerAdd, 32 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils 33 MAX_UPLOAD_SIZE, IApplicantOnlinePayment, IApplicantsUtils, 34 IApplicantUpdateByRegNo 33 35 ) 34 36 from waeup.kofa.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED … … 858 860 grok.require('waeup.Anonymous') 859 861 grok.template('applicantregister') 860 form_fields = grok.AutoFields(IApplicantEdit).select( 861 'firstname', 'middlename', 'lastname', 'email', 'phone') 862 form_fields['phone'].custom_widget = PhoneWidget 862 863 @property 864 def form_fields(self): 865 form_fields = None 866 if self.context.mode == 'create': 867 form_fields = grok.AutoFields(IApplicantEdit).select( 868 'firstname', 'middlename', 'lastname', 'email', 'phone') 869 form_fields['phone'].custom_widget = PhoneWidget 870 elif self.context.mode == 'update': 871 form_fields = grok.AutoFields(IApplicantUpdateByRegNo).select( 872 'reg_number','email') 873 return form_fields 863 874 864 875 @property … … 890 901 # No need to flash something. 891 902 return 892 # Add applicant and create password 893 applicant = createObject(u'waeup.Applicant') 894 self.applyData(applicant, **data) 895 self.context.addApplicant(applicant) 903 if self.context.mode == 'create': 904 # Add applicant 905 applicant = createObject(u'waeup.Applicant') 906 self.applyData(applicant, **data) 907 self.context.addApplicant(applicant) 908 elif self.context.mode == 'update': 909 # Update applicant 910 reg_number = data['reg_number'] 911 cat = getUtility(ICatalog, name='applicants_catalog') 912 results = list( 913 cat.searchResults(reg_number=(reg_number, reg_number))) 914 if results: 915 applicant = results[0] 916 if applicant.password is not None: 917 self.flash(_('Your password has already been set.')) 918 return 919 applicant.email = data['email'] 920 else: 921 self.flash(_('No application record found.')) 922 return 923 else: 924 return 896 925 kofa_utils = getUtility(IKofaUtils) 897 926 password = kofa_utils.genPassword() -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantregister.pt
r7811 r8033 16 16 </tbody> 17 17 </table> 18 <p i18n:translate="" >18 <p i18n:translate="" tal:condition="python: context.mode=='create'"> 19 19 An account will be created for you and an email with your login 20 credentials will be sent to the address provided. 21 </p> 22 <p i18n:translate="" tal:condition="python: context.mode=='update'"> 23 Your application record will be looked up and an email with your login 20 24 credentials will be sent to the address provided. 21 25 </p> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r8016 r8033 29 29 from waeup.kofa.schema import TextLineChoice 30 30 from waeup.kofa.interfaces import ( 31 IKofaObject, year_range, validate_email, academic_sessions_vocab) 31 IKofaObject, year_range, validate_email, academic_sessions_vocab, 32 SimpleKofaVocabulary) 32 33 from waeup.kofa.interfaces import MessageFactory as _ 33 34 from waeup.kofa.payments.interfaces import IOnlinePayment … … 135 136 # apppins_dict[value][1],self.apppins_dict[value][0]) 136 137 138 application_modes_vocab = SimpleKofaVocabulary( 139 (_('Create Application Records'), 'create'), 140 (_('Update Application Records'), 'update'), 141 ) 137 142 138 143 class IApplicantsUtils(Interface): … … 176 181 values = year_range(), 177 182 readonly = True, 183 ) 184 185 mode = schema.Choice( 186 title = _(u'Application Mode'), 187 vocabulary = application_modes_vocab, 188 required = True, 178 189 ) 179 190 … … 202 213 required = False, 203 214 default = u'''This text can been seen by anonymous users. 204 Here we put mult -lingual information about the study courses provided, the application procedure and deadlines.215 Here we put multi-lingual information about the study courses provided, the application procedure and deadlines. 205 216 >>de<< 206 217 Dieser Text kann von anonymen Benutzern gelesen werden. … … 298 309 ) 299 310 reg_number = TextLineChoice( 300 title = _(u' JAMBRegistration Number'),311 title = _(u'Registration Number'), 301 312 readonly = False, 302 313 required = True, … … 337 348 email = schema.ASCIILine( 338 349 title = _(u'Email Address'), 339 required = True,350 required = False, 340 351 constraint=validate_email, 341 352 ) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/sample_container_data.csv
r7910 r8033 1 code,title,prefix,entry_level,year, provider,application_category,description,startdate,enddate,strict_deadline2 app2012,General Studies 2012/2013,app,100,2012, waeup.kofa.applicants.ApplicantsContainer,basic,"This text can been seen by anonymous users.1 code,title,prefix,entry_level,year,application_category,description,startdate,enddate,strict_deadline,mode 2 app2012,General Studies 2012/2013,app,100,2012,basic,"This text can been seen by anonymous users. 3 3 >>de<< 4 Dieser Text kann von anonymen Benutzern gelesen werden.",2012-03-01,2012-04-25,1 5 app2013,General Studies 2013/2014,app,100,2012, waeup.kofa.applicants.ApplicantsContainer,basic,"This text can been seen by anonymous users.4 Dieser Text kann von anonymen Benutzern gelesen werden.",2012-03-01,2012-04-25,1,create 5 app2013,General Studies 2013/2014,app,100,2012,basic,"This text can been seen by anonymous users. 6 6 >>de<< 7 Dieser Text kann von anonymen Benutzern gelesen werden.",2013-03-01,2013-04-25,1 7 Dieser Text kann von anonymen Benutzern gelesen werden.",2013-03-01,2013-04-25,1,create -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r8008 r8033 84 84 applicantscontainer.entry_level = 100 85 85 applicantscontainer.application_category = 'basic' 86 applicantscontainer.mode = 'create' 86 87 delta = timedelta(days=10) 87 88 applicantscontainer.startdate = date.today() - delta … … 248 249 self.browser.getControl(name="form.year").value = ['2010'] 249 250 self.browser.getControl(name="form.entry_level").value = ['100'] 251 self.browser.getControl(name="form.mode").value = ['create'] 250 252 self.browser.getControl( 251 253 name="form.application_category").value = ['basic'] … … 262 264 self.browser.getControl(name="form.year").value = ['2010'] 263 265 self.browser.getControl(name="form.entry_level").value = ['100'] 266 self.browser.getControl(name="form.mode").value = ['create'] 264 267 self.browser.getControl( 265 268 name="form.application_category").value = ['basic'] … … 276 279 self.browser.getControl(name="form.year").value = ['2010'] 277 280 self.browser.getControl(name="form.entry_level").value = ['100'] 281 self.browser.getControl(name="form.mode").value = ['create'] 278 282 #self.browser.getControl(name="form.ac_prefix").value = ['APP'] 279 283 self.browser.getControl( … … 788 792 layer = FunctionalLayer 789 793 790 def test_register_applicant (self):794 def test_register_applicant_create(self): 791 795 # An applicant can register himself. 792 796 self.browser.open(self.container_path) … … 802 806 self.assertEqual(self.browser.url, 803 807 self.container_path + '/registration_complete?email=xx%40yy.zz') 808 # Now we change the application mode and check if applicants 809 # can find and update imported records instead of creating new records. 810 # First we check what happens if record can't be found. 811 self.applicantscontainer.mode = 'update' 812 self.browser.open(self.container_path + '/register') 813 #self.browser.getControl(name="form.firstname").value = 'John' 814 self.browser.getControl(name="form.reg_number").value = 'anynumber' 815 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 816 self.browser.getControl("Get login credentials").click() 817 self.assertTrue('No application record found.' 818 in self.browser.contents) 819 # Now we check if password has already been set. 820 #self.browser.getControl(name="form.firstname").value = 'John' 821 self.browser.getControl(name="form.reg_number").value = '1234' 822 self.browser.getControl("Get login credentials").click() 823 self.assertTrue('Your password has already been set.' 824 in self.browser.contents) 825 # We unset the password and try to register again. 826 IUserAccount( 827 self.app['applicants']['app2009'][ 828 self.applicant.application_number]).context.password = None 829 self.browser.open(self.container_path + '/register') 830 #self.browser.getControl(name="form.firstname").value = 'John' 831 self.browser.getControl(name="form.reg_number").value = '1234' 832 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 833 self.browser.getControl("Get login credentials").click() 834 self.assertTrue('Your registration was successful.' 835 in self.browser.contents) 804 836 return 805 837
Note: See TracChangeset for help on using the changeset viewer.