Changeset 15609 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 26 Sep 2019, 11:38:36 (5 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/loginpage.pt
r13089 r15609 33 33 <strong><a href="changepw"> here</a></strong>. 34 34 </p> 35 <p i18n:translate="login_trouble4"> You are student parents and want to monitor study progress 36 of your child? Then request a temporary parents password <strong><a href="requestppw"> here</a></strong>. 37 Prerequisite for getting access is that you have a valid email address and that this address 38 has been entered by the student into the parents' email address field. 39 </p> 35 40 </form> -
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r15287 r15609 438 438 'adm_code,clr_code,date_of_birth,email,' 439 439 'employer,firstname,flash_notice,lastname,matric_number,middlename,' 440 'nationality,officer_comment,perm_address,personal_updated,' 440 'nationality,officer_comment,parents_email,' 441 'perm_address,personal_updated,' 441 442 'phone,reg_number,sex,student_id,suspended,suspended_comment,' 442 443 'password,state,history,certcode,is_postgrad,current_level,' -
main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py
r15416 r15609 320 320 SEMESTER_DICT = Attribute("Dict of semesters or trimesters") 321 321 SYSTEM_MAX_LOAD = Attribute("Dict of maximum system loads.") 322 TEMP_PASSWORD_MINUTES = Attribute( 323 "Temporary passwords and parents password validity period") 322 324 323 325 def sendContactForm( -
main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
r15607 r15609 102 102 elif self._setPassword(): 103 103 msg = _('Parents password has been successfully set. ' 104 'Login with your parents password.')104 'Login with your new parents password.') 105 105 grok.getSite().logger.info( 106 106 'ParentsPasswordMandate used: %s ' -
main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py
r15607 r15609 291 291 self.assertEqual(msg, 292 292 'Parents password has been successfully set. ' 293 'Login with your parents password.')293 'Login with your new parents password.') 294 294 self.assertEqual(redirect_path, '/login') 295 295 self.assertTrue(IUserAccount(student).checkPassword('mypwd1')) -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r15546 r15609 50 50 academic_sessions_vocab, IDataCenter, DOCLINK) 51 51 from waeup.kofa.interfaces import MessageFactory as _ 52 from waeup.kofa.mandates.mandate import PasswordMandate 52 from waeup.kofa.mandates.mandate import PasswordMandate, ParentsPasswordMandate 53 53 from waeup.kofa.university.interfaces import ( 54 54 IDepartment, ICertificate, ICourse) … … 392 392 grok.template('loginasstep1') 393 393 pnav = 4 394 395 def update(self): 396 super(LoginAsStudentStep1, self).update() 397 kofa_utils = getUtility(IKofaUtils) 398 self.temp_password_minutes = kofa_utils.TEMP_PASSWORD_MINUTES 399 return 394 400 395 401 def label(self): … … 2555 2561 grok.require('waeup.handleStudent') 2556 2562 form_fields = grok.AutoFields(IStudentBase).select( 2557 'email', 'phone' )2563 'email', 'phone', 'parents_email') 2558 2564 label = _('Edit base data') 2559 2565 pnav = 4 … … 3216 3222 return 3217 3223 3224 class ParentsUser: 3225 pass 3226 3227 class RequestParentsPasswordPage(StudentRequestPasswordPage): 3228 """Captcha'd request password page for parents. 3229 """ 3230 grok.name('requestppw') 3231 grok.template('requestppw') 3232 label = _('Request password for parents access') 3233 3234 def update(self): 3235 super(RequestParentsPasswordPage, self).update() 3236 kofa_utils = getUtility(IKofaUtils) 3237 self.temp_password_minutes = kofa_utils.TEMP_PASSWORD_MINUTES 3238 return 3239 3240 @action(_('Send temporary login credentials to email address'), style='primary') 3241 def get_credentials(self, **data): 3242 if not self.captcha_result.is_valid: 3243 # Captcha will display error messages automatically. 3244 # No need to flash something. 3245 return 3246 number = data.get('number','') 3247 lastname = data.get('lastname','') 3248 email = data['email'] 3249 cat = getUtility(ICatalog, name='students_catalog') 3250 results = list( 3251 cat.searchResults(reg_number=(number, number))) 3252 if not results: 3253 results = list( 3254 cat.searchResults(matric_number=(number, number))) 3255 if results: 3256 student = results[0] 3257 if getattr(student,'lastname',None) is None: 3258 self.flash(_('An error occurred.'), type="danger") 3259 return 3260 elif student.lastname.lower() != lastname.lower(): 3261 # Don't tell the truth here. Anonymous must not 3262 # know that a record was found and only the lastname 3263 # verification failed. 3264 self.flash(_('No student record found.'), type="warning") 3265 return 3266 elif email != student.parents_email: 3267 self.flash(_('Wrong email address.'), type="warning") 3268 return 3269 else: 3270 self._redirect_no_student() 3271 return 3272 kofa_utils = getUtility(IKofaUtils) 3273 password = kofa_utils.genPassword() 3274 mandate = ParentsPasswordMandate() 3275 mandate.params['password'] = password 3276 mandate.params['student'] = student 3277 site = grok.getSite() 3278 site['mandates'].addMandate(mandate) 3279 # Send email with credentials 3280 args = {'mandate_id':mandate.mandate_id} 3281 mandate_url = self.url(site) + '/mandate?%s' % urlencode(args) 3282 url_info = u'Confirmation link: %s' % mandate_url 3283 msg = _('You have successfully requested a parents password for the') 3284 # Create a fake user 3285 user = ParentsUser() 3286 user.name = student.student_id 3287 user.title = "Parents of %s" % student.display_fullname 3288 user.email = student.parents_email 3289 if kofa_utils.sendCredentials(user, password, url_info, msg): 3290 email_sent = user.email 3291 else: 3292 email_sent = None 3293 self._redirect(email=email_sent, password=password, 3294 student_id=student.student_id) 3295 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 3296 self.context.logger.info( 3297 '%s - %s (%s) - %s' % (ob_class, number, student.student_id, email_sent)) 3298 return 3299 3218 3300 class StudentRequestPasswordEmailSent(KofaPage): 3219 3301 """Landing page after successful password request. -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/loginasstep1.pt
r9338 r15609 5 5 for 6 6 <span i18n:name="minutes" 7 tal:replace=view/ context/temp_password_minutes></span>7 tal:replace=view/temp_password_minutes></span> 8 8 minutes. The student can't login 9 9 during this time period. After expiration the student can login -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r15606 r15609 306 306 ) 307 307 308 parents_email = schema.ASCIILine( 309 title = _(u"Parents' Email"), 310 required = False, 311 constraint=validate_email, 312 ) 313 308 314 def setTempPassword(user, password): 309 315 """Set a temporary password (LDAP-compatible) SSHA encoded for … … 427 433 number = schema.TextLine( 428 434 title = _(u'Registr. or Matric. Number'), 429 required = True,430 )431 432 firstname = schema.TextLine(433 title = _(u'First Name'),434 435 required = True, 435 436 ) -
main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
r15606 r15609 58 58 grok.provides(IStudent) 59 59 60 temp_password_minutes = 1061 62 60 def __init__(self): 63 61 super(Student, self).__init__() … … 91 89 """ 92 90 temp_password_dict = getattr(self, 'temp_password', None) 91 kofa_utils = getUtility(IKofaUtils) 92 temp_password_minutes = kofa_utils.TEMP_PASSWORD_MINUTES 93 93 if temp_password_dict is not None: 94 delta = timedelta(minutes= self.temp_password_minutes)94 delta = timedelta(minutes=temp_password_minutes) 95 95 now = datetime.utcnow() 96 96 if now < temp_password_dict.get('timestamp') + delta: … … 120 120 """ 121 121 parents_password_dict = getattr(self, 'parents_password', None) 122 kofa_utils = getUtility(IKofaUtils) 123 temp_password_minutes = kofa_utils.TEMP_PASSWORD_MINUTES 122 124 if parents_password_dict is not None: 123 delta = timedelta(minutes= self.temp_password_minutes)125 delta = timedelta(minutes=temp_password_minutes) 124 126 now = datetime.utcnow() 125 127 if now < parents_password_dict.get('timestamp') + delta: -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r15606 r15609 3783 3783 'adm_code,clr_code,date_of_birth,email,employer,' 3784 3784 'firstname,flash_notice,lastname,matric_number,middlename,nationality,' 3785 'officer_comment,perm_address,personal_updated,phone,reg_number,' 3785 'officer_comment,parents_email,perm_address,' 3786 'personal_updated,phone,reg_number,' 3786 3787 'sex,student_id,suspended,suspended_comment,' 3787 3788 'password,state,history,certcode,is_postgrad,' 3788 3789 'current_level,current_session\r\n' 3789 ',,1981-02-04#,aa@aa.ng,,Anna,,Tester,234,,,,,, '3790 ',,1981-02-04#,aa@aa.ng,,Anna,,Tester,234,,,,,,,' 3790 3791 '1234#,123,m,K1000000,0,,{SSHA}' in self.browser.contents) 3791 3792 self.browser.open('http://localhost/app/datacenter/@@export') … … 3911 3912 'adm_code,clr_code,date_of_birth,email,employer,' 3912 3913 'firstname,flash_notice,lastname,matric_number,middlename,nationality,' 3913 'officer_comment,perm_address,personal_updated,phone,reg_number,' 3914 'officer_comment,parents_email,perm_address,' 3915 'personal_updated,phone,reg_number,' 3914 3916 'sex,student_id,suspended,suspended_comment,' 3915 3917 'password,state,history,certcode,is_postgrad,' 3916 3918 'current_level,current_session\r\n' 3917 ',,1981-02-04#,aa@aa.ng,,Anna,,Tester,234,,,,,, '3919 ',,1981-02-04#,aa@aa.ng,,Anna,,Tester,234,,,,,,,' 3918 3920 '1234#,123,m,K1000000,0,,{SSHA}' in self.browser.contents) 3919 3921 self.assertEqual(len(self.app['datacenter'].running_exports), 1) … … 4675 4677 # Tests for UI actions when acting as parents. 4676 4678 4679 def test_request_ppw(self): 4680 self.app['students'][self.student_id].parents_email = 'par@yy.zz' 4681 self.browser.open('http://localhost/app/requestppw') 4682 self.browser.getControl(name="form.lastname").value = 'tESTer' 4683 self.browser.getControl(name="form.number").value = '123' 4684 self.browser.getControl(name="form.email").value = 'par@yy.zz' 4685 self.browser.getControl("Send temporary login credentials").click() 4686 self.assertTrue('Your password request was successful.' 4687 in self.browser.contents) 4688 logfile = os.path.join( 4689 self.app['datacenter'].storage, 'logs', 'main.log') 4690 logcontent = open(logfile).read() 4691 self.assertTrue('zope.anybody - students.browser.RequestParentsPasswordPage - ' 4692 '123 (K1000000) - par@yy.zz' in logcontent) 4693 return 4694 4677 4695 def test_login_as_parents(self): 4678 # S student login still works after all the changes made4696 # Student login still works after all the changes made 4679 4697 self.browser.open(self.login_path) 4680 4698 self.browser.getControl(name="form.login").value = self.student_id -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r15546 r15609 126 126 std_csv_entry = ( 127 127 'my adm code,my clr code,1981-02-04#,anna@sample.com,,' 128 'Anna,,Tester,234,M.,NG,, "Studentroad 21\nLagos 123456\n",,'128 'Anna,,Tester,234,M.,NG,,,"Studentroad 21\nLagos 123456\n",,' 129 129 '+234-123-12345#,123,f,A111111,0,,,created' 130 130 ) … … 158 158 'adm_code,clr_code,date_of_birth,email,' 159 159 'employer,firstname,flash_notice,lastname,matric_number,middlename,' 160 'nationality,officer_comment,perm_address,personal_updated,' 160 'nationality,officer_comment,parents_email,' 161 'perm_address,personal_updated,' 161 162 'phone,reg_number,sex,student_id,suspended,suspended_comment,' 162 163 'password,state,history,' 163 164 'certcode,is_postgrad,current_level,current_session\r\n' 164 165 'my adm code,my clr code,' 165 '1981-02-04#,anna@sample.com,,Anna,,Tester,234,M.,NG,, '166 '1981-02-04#,anna@sample.com,,Anna,,Tester,234,M.,NG,,,' 166 167 '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,123,f,' 167 168 'A111111,0,,,created' … … 180 181 'adm_code,clr_code,date_of_birth,email,' 181 182 'employer,firstname,flash_notice,lastname,matric_number,middlename,' 182 'nationality,officer_comment,perm_address,personal_updated,' 183 'nationality,officer_comment,parents_email,' 184 'perm_address,personal_updated,' 183 185 'phone,reg_number,sex,student_id,suspended,suspended_comment,' 184 186 'password,state,history,certcode,' 185 187 'is_postgrad,current_level,current_session\r\n' 186 188 'my adm code,my clr code,1981-02-04#,anna@sample.com,,' 187 'Anna,,Tester,234,M.,NG,, "Studentroad 21\nLagos 123456\n"'189 'Anna,,Tester,234,M.,NG,,,"Studentroad 21\nLagos 123456\n"' 188 190 ',,+234-123-12345#,123,f,A111111,0,,,created' 189 191 in result … … 200 202 'adm_code,clr_code,date_of_birth,email,' 201 203 'employer,firstname,flash_notice,lastname,matric_number,middlename,' 202 'nationality,officer_comment,perm_address,personal_updated,' 204 'nationality,officer_comment,parents_email,' 205 'perm_address,personal_updated,' 203 206 'phone,reg_number,sex,student_id,suspended,suspended_comment,' 204 207 'password,state,history,certcode,' 205 208 'is_postgrad,current_level,current_session\r\n' 206 209 'my adm code,my clr code,1981-02-04#,anna@sample.com,,' 207 'Anna,,Tester,234,M.,NG,, "Studentroad 21\nLagos 123456\n"'210 'Anna,,Tester,234,M.,NG,,,"Studentroad 21\nLagos 123456\n"' 208 211 ',,+234-123-12345#,123,f,A111111,0,,,created' 209 212 in result -
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r15553 r15609 232 232 MAX_FILES = 100 233 233 234 #: Temporary passwords and parents password validity period 235 TEMP_PASSWORD_MINUTES = 10 236 234 237 def sendContactForm(self, from_name, from_addr, rcpt_name, rcpt_addr, 235 238 from_username, usertype, portal, body, subject):
Note: See TracChangeset for help on using the changeset viewer.