- Timestamp:
- 14 Jul 2021, 11:39:09 (3 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r16550 r16551 4 4 1.7.2.dev0 (unreleased) 5 5 ======================= 6 7 * Send email to student after single record creation. 6 8 7 9 * Forward credentials to login page after password reset request. -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py
r16545 r16551 22 22 from hurry.query import Eq, Text 23 23 from hurry.query.query import Query 24 from urllib import urlencode 24 25 from zope.component import getUtility, createObject, getAdapter 25 26 from zope.component.interfaces import IFactory … … 171 172 return 172 173 173 def createStudent(self, view=None, graduated=False ):174 def createStudent(self, view=None, graduated=False, send_email=False): 174 175 """Create a student, fill with base data, create an application slip, 175 copy applicant data and files .176 copy applicant data and files, send an email (optional). 176 177 """ 177 178 site = grok.getSite() … … 266 267 view=view) 267 268 self._saveApplicationPDF(student, applicant_slip, view=view) 269 if view and send_email: 270 kofa_utils = getUtility(IKofaUtils) 271 pw = self.application_number 272 args = {'login':student.student_id, 'password':pw} 273 login_url = view.url(grok.getSite()) + '/login?%s' % urlencode(args) 274 rpw_url = view.url(grok.getSite(), 'changepw') 275 kofa_utils.informNewStudent( 276 IUserAccount(student), pw, login_url, rpw_url) 268 277 return True, _('Student ${a} created', mapping = {'a':student.student_id}) 269 278 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r16545 r16551 730 730 731 731 def update(self): 732 success, msg = self.context.createStudent(view=self )732 success, msg = self.context.createStudent(view=self, send_email=True) 733 733 if success: 734 734 self.flash(msg) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r16545 r16551 1411 1411 return 1412 1412 1413 def test_create_student(self): 1414 # Managers can contact student 1415 IWorkflowState(self.applicant).setState('admitted') 1416 self.applicant.certificate = self.certificate 1417 self.applicant.course_admitted = self.certificate 1418 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1419 self.browser.open(self.manage_path) 1420 self.fill_correct_values() 1421 image = open(SAMPLE_IMAGE, 'rb') 1422 ctrl = self.browser.getControl(name='form.passport') 1423 file_ctrl = ctrl.mech_control 1424 file_ctrl.add_file(image, filename='myphoto.jpg') 1425 self.browser.getControl("Save").click() 1426 self.browser.open(self.view_path) 1427 self.browser.getLink("Create student").click() 1428 self.assertTrue('Student K1000000 created' in self.browser.contents) 1429 self.assertMatches( 1430 'Sending email from no-reply@waeup.org to xx@yy.zz:' 1431 '\nMessage:' 1432 '\nmsg: MIME-Version: 1.0' 1433 '\nmsg: Content-Type: text/plain; charset="us-ascii"' 1434 '\nmsg: Content-Transfer-Encoding: 7bit' 1435 '\nmsg: From: Administrator <no-reply@waeup.org>' 1436 '\nmsg: To: John Anthony Tester <xx@yy.zz>' 1437 '\nmsg: Reply-To: Administrator <contact@waeup.org>' 1438 '\nmsg: Subject: Your new Kofa student account' 1439 '\nmsg:' 1440 '\nmsg: Dear John Anthony Tester,' 1441 '\nmsg:' 1442 '\nmsg: Your student record of the Student Registration and Information Portal of' 1443 '\nmsg: Sample University has been created for you.' 1444 '\nmsg:' 1445 '\nmsg: Your user name: K1000000' 1446 '\nmsg: Your password: %s' 1447 '\nmsg: Login: http://localhost/app/login?login=K1000000&password=%s' 1448 '\nmsg:' 1449 '\nmsg: Or request a new secure password here: http://localhost/app/changepw' 1450 '\nmsg:' 1451 '\nmsg: Regards' 1452 '\nmsg:' % (self.applicant.application_number, self.applicant.application_number), 1453 self.get_fake_smtp_output() 1454 ) 1455 return 1413 1456 1414 1457 class ApplicantRegisterTests(ApplicantsFullSetup): -
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r16431 r16551 359 359 subject, body, config) 360 360 361 def informNewStudent(self, user, pw, login_url, rpw_url): 362 """Inform student that a new student account has been created. 363 """ 364 subject = 'Your new Kofa student account' 365 text = _(u"""Dear ${a}, 366 367 Your student record of the Student Registration and Information Portal of 368 ${b} has been created for you. 369 370 Your user name: ${c} 371 Your password: ${d} 372 Login: ${e} 373 374 Or request a new secure password here: ${f} 375 376 Regards 377 """) 378 config = grok.getSite()['configuration'] 379 from_name = config.name_admin 380 from_addr = config.email_admin 381 rcpt_name = user.title 382 rcpt_addr = user.email 383 384 text = _(text, mapping={ 385 'a': rcpt_name, 386 'b': config.name, 387 'c': user.name, 388 'd': pw, 389 'e': login_url, 390 'f': rpw_url 391 }) 392 body = translate(text, 'waeup.kofa', 393 target_language=self.PORTAL_LANGUAGE) 394 return send_mail( 395 from_name, from_addr, rcpt_name, rcpt_addr, 396 subject, body, config) 397 398 361 399 def inviteReferee(self, referee, applicant, url_info=None): 362 400 """Send invitation email to referee.
Note: See TracChangeset for help on using the changeset viewer.