Changeset 7369 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 18 Dec 2011, 08:24:04 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7364 r7369 26 26 from zope.catalog.interfaces import ICatalog 27 27 from zope.component import queryUtility, getUtility 28 #from hurry.query import Eq 29 #from hurry.query.query import Query 28 30 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 29 31 from zope.component import createObject … … 33 35 from waeup.sirp.browser import ( 34 36 SIRPPage, SIRPEditFormPage, SIRPAddFormPage, SIRPDisplayFormPage, 35 ContactAdminForm) 37 ContactAdminForm, SIRPForm) 38 from waeup.sirp.browser.interfaces import ICaptchaManager 36 39 from waeup.sirp.browser.breadcrumbs import Breadcrumb 37 40 from waeup.sirp.browser.resources import datepicker, datatable, tabs, warning … … 41 44 from waeup.sirp.interfaces import ( 42 45 ISIRPObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm, 43 ISIRPUtils )46 ISIRPUtils, IUniversity) 44 47 from waeup.sirp.widgets.datewidget import ( 45 48 FriendlyDateWidget, FriendlyDateDisplayWidget, … … 51 54 IStudentAccommodation, IStudentClearanceEdit, IStudentStudyLevel, 52 55 ICourseTicket, ICourseTicketAdd, IStudentPaymentsContainer, 53 IStudentOnlinePayment, IBedTicket, IStudentsUtils 56 IStudentOnlinePayment, IBedTicket, IStudentsUtils, IStudentChangePassword 54 57 ) 55 58 from waeup.sirp.students.catalog import search … … 193 196 grok.context(ISIRPObject) 194 197 grok.name('setpassword') 195 grok.require('waeup. Public')198 grok.require('waeup.Anonymous') 196 199 grok.template('setpassword') 197 200 title = '' … … 1469 1472 students_utils = getUtility(IStudentsUtils) 1470 1473 acc_details = students_utils.getAccommodationDetails(student) 1474 if not acc_details: 1475 self.flash("Your data are incomplete.") 1476 self.redirect(self.url(self.context)) 1477 return 1471 1478 if not student.state in acc_details['allowed_states']: 1472 1479 self.flash("You are in the wrong registration state.") … … 2186 2193 self.redirect(self.url(self.context, u'@@edit')) 2187 2194 return 2195 2196 class ChangePasswordRequestPage(SIRPForm): 2197 """Captcha'd page for students to request a password change. 2198 """ 2199 grok.context(IUniversity) 2200 grok.name('changepw') 2201 grok.require('waeup.Anonymous') 2202 grok.template('changepw') 2203 title = 'Change Password Request' 2204 label = 'Change my password' 2205 form_fields = grok.AutoFields(IStudentChangePassword) 2206 2207 def update(self): 2208 # Handle captcha 2209 self.captcha = getUtility(ICaptchaManager).getCaptcha() 2210 self.captcha_result = self.captcha.verify(self.request) 2211 self.captcha_code = self.captcha.display(self.captcha_result.error_code) 2212 return 2213 2214 @grok.action('Send request') 2215 def request(self, **data): 2216 if not self.captcha_result.is_valid: 2217 # Captcha will display error messages automatically. 2218 # No need to flash something. 2219 return 2220 # Search student 2221 cat = queryUtility(ICatalog, name='students_catalog') 2222 reg_number = data['reg_number'] 2223 email = data['email'] 2224 results = cat.searchResults( 2225 reg_number=(reg_number, reg_number), 2226 email=(email,email)) 2227 if len(results) == 0: 2228 self.flash('No student record found.') 2229 return 2230 student = list(results)[0] 2231 # Change password 2232 sirp_utils = getUtility(ISIRPUtils) 2233 pwd = sirp_utils.genPassword() 2234 IUserAccount(student).setPassword(pwd) 2235 # Send email with new redentials 2236 username = student.student_id 2237 fullname = student.display_fullname 2238 subject = 'Your SIRP credentials' 2239 msg = 'You have successfully changed your password for the' 2240 email_to = student.email 2241 login_url = self.url(grok.getSite(), 'login') 2242 success = sirp_utils.sendPassword(fullname,msg,username, 2243 pwd,login_url,email_to,subject) 2244 if success: 2245 self.flash('An email with your user name and password ' + 2246 'has been sent to %s.' % email_to) 2247 else: 2248 self.flash('An smtp server error occurred.') 2249 return -
main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py
r7364 r7369 38 38 student_id = index.Field(attribute='student_id') 39 39 fullname = index.Text(attribute='fullname') 40 email = index.Field(attribute='email') 40 41 reg_number = index.Field(attribute='reg_number') 41 42 matric_number = index.Field(attribute='matric_number') -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r7364 r7369 453 453 454 454 """ 455 456 class IStudentChangePassword(ISIRPObject): 457 """Interface needed for change pasword page. 458 459 """ 460 461 reg_number = schema.TextLine( 462 title = u'Registration Number', 463 default = None, 464 required = True, 465 readonly = False, 466 ) 467 468 email = schema.ASCIILine( 469 title = u'Email', 470 required = True, 471 constraint=validate_email, 472 ) -
main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py
r7365 r7369 191 191 # Determine bed type 192 192 studycourse = student['studycourse'] 193 certificate = getattr(studycourse,'certificate',None) 193 194 entry_session = studycourse.entry_session 194 195 current_level = studycourse.current_level 195 end_level = studycourse.certificate.end_level 196 if not (entry_session and current_level and certificate): 197 return 198 end_level = certificate.end_level 196 199 if entry_session == grok.getSite()['configuration'].accommodation_session: 197 200 bt = 'fr'
Note: See TracChangeset for help on using the changeset viewer.