- Timestamp:
- 17 Dec 2011, 18:47:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7364 r7365 51 51 from waeup.sirp.interfaces import ( 52 52 ISIRPObject, ILocalRolesAssignable, IExtFileStore, 53 IFileStoreNameChooser, IPasswordValidator, IUserAccount )53 IFileStoreNameChooser, IPasswordValidator, IUserAccount, ISIRPUtils) 54 54 from waeup.sirp.permissions import get_users_with_local_roles 55 55 from waeup.sirp.students.viewlets import PrimaryStudentNavTab … … 1089 1089 return image 1090 1090 1091 class ApplicantRegistrationSuccessful(SIRPPage):1092 """Info page when applicant registration was successful.1093 """1094 grok.context(IApplicantsContainer)1095 grok.name('register_success')1096 grok.require('waeup.Public')1097 grok.template('applicantregister_succ')1098 label = 'Applicant Registration Successful'1099 title = label1100 1101 def update(self, app_id=None):1102 if app_id is None:1103 self.redirect(self.url(self.context, 'register'))1104 self.app_id = app_id1105 self.login_url = self.url(grok.getSite(), 'login')1106 1107 1091 class ApplicantRegistrationPage(SIRPAddFormPage): 1108 1092 """Captcha'd registration page for applicants. … … 1131 1115 # No need to flash something. 1132 1116 return 1133 1134 # handle password field manually 1135 form = self.request.form 1136 password = form.get('password', None) 1137 password_ctl = form.get('control_password', None) 1138 if password: 1139 validator = getUtility(IPasswordValidator) 1140 errors = validator.validate_password(password, password_ctl) 1141 if errors: 1142 self.flash( ' '.join(errors)) 1143 return 1144 1145 # add applicant and redirect to success page 1117 sirp_utils = getUtility(ISIRPUtils) 1118 # Add applicant and create password 1146 1119 applicant = createObject('waeup.Applicant') 1147 1120 self.applyData(applicant, **data) 1148 1121 self.context.addApplicant(applicant) 1149 IUserAccount(applicant).setPassword(password) 1150 app_id = applicant.applicant_id 1151 self.redirect(self.url(self.context, 'register_success', 1152 data=dict(app_id=app_id))) 1153 return 1122 pwd = sirp_utils.genPassword() 1123 IUserAccount(applicant).setPassword(pwd) 1124 # Send email with credentials 1125 username = applicant.applicant_id 1126 fullname = applicant.display_fullname 1127 subject = 'Your SIRP credentials' 1128 msg = 'You have successfully registered for the' 1129 email_to = applicant.email 1130 login_url = self.url(grok.getSite(), 'login') 1131 success = sirp_utils.sendPassword(fullname,msg,username, 1132 pwd,login_url,email_to,subject) 1133 if success: 1134 self.flash('An email with your user name and password' + 1135 'has been sent to %s.' % email_to) 1136 else: 1137 self.flash('An smtp server error occurred.') 1138 return
Note: See TracChangeset for help on using the changeset viewer.