- Timestamp:
- 18 Dec 2011, 15:26:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7378 r7380 1134 1134 return 1135 1135 1136 @grok.action(' Sendlogin credentials')1136 @grok.action('Get login credentials') 1137 1137 def register(self, **data): 1138 1138 if not self.captcha_result.is_valid: … … 1140 1140 # No need to flash something. 1141 1141 return 1142 sirp_utils = getUtility(ISIRPUtils)1143 1142 # Add applicant and create password 1144 1143 applicant = createObject('waeup.Applicant') 1145 1144 self.applyData(applicant, **data) 1146 1145 self.context.addApplicant(applicant) 1147 p wd = sirp_utils.genPassword()1148 IUserAccount(applicant).setPassword(p wd)1146 password = getUtility(ISIRPUtils).genPassword() 1147 IUserAccount(applicant).setPassword(password) 1149 1148 # Send email with credentials 1149 if self.sendCredentials(applicant, password): 1150 self.redirect(self.url(self.context, 'registration_complete', 1151 data = dict(email=applicant.email))) 1152 return 1153 else: 1154 self.flash('Email could not been sent. Please retry later.') 1155 return 1156 1157 def sendCredentials(self, applicant, password): 1158 """Send credentials as email. 1159 1160 Input is the applicant for which credentials are sent and the 1161 password. 1162 1163 Returns True or False to indicate successful operation. 1164 """ 1165 sirp_utils = getUtility(ISIRPUtils) 1150 1166 username = applicant.applicant_id 1151 1167 fullname = applicant.display_fullname 1152 1168 subject = 'Your SIRP credentials' 1153 msg = 'You have successfully registered for the'1169 msg = 'You have successfully been registered for the' 1154 1170 email_to = applicant.email 1155 1171 login_url = self.url(grok.getSite(), 'login') 1156 1172 success = sirp_utils.sendPassword(fullname,msg,username, 1157 pwd,login_url,email_to,subject) 1158 if success: 1159 self.flash('An email with your user name and password ' + 1160 'has been sent to %s.' % email_to) 1161 else: 1162 self.flash('An smtp server error occurred.') 1163 return 1173 password,login_url,email_to,subject) 1174 return success 1175 1176 class ApplicantRegistrationEmailSent(SIRPPage): 1177 """Landing page after successful registration. 1178 """ 1179 grok.name('registration_complete') 1180 grok.require('waeup.Public') 1181 grok.template('applicantregemailsent') 1182 title = 'Registration Completed' 1183 label = 'Your registration was successful' 1184 1185 def update(self, email=None): 1186 self.email = email 1187 return
Note: See TracChangeset for help on using the changeset viewer.