Ignore:
Timestamp:
20 Dec 2011, 07:39:33 (13 years ago)
Author:
Henrik Bettermann
Message:

Define send_mail function and move sendCredentials code from browser.py to utils.py.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r7392 r7399  
    10591059        self.applyData(applicant, **data)
    10601060        self.context.addApplicant(applicant)
    1061         password = getUtility(ISIRPUtils).genPassword()
     1061        sirp_utils = getUtility(ISIRPUtils)
     1062        password = sirp_utils.genPassword()
    10621063        IUserAccount(applicant).setPassword(password)
    10631064        # Send email with credentials
    1064         if self.sendCredentials(applicant, password):
     1065        login_url = self.url(grok.getSite(), 'login')
     1066        if sirp_utils.sendCredentials(applicant, password, login_url):
    10651067            self.redirect(self.url(self.context, 'registration_complete',
    10661068                                   data = dict(email=applicant.email)))
     
    10691071            self.flash('Email could not been sent. Please retry later.')
    10701072        return
    1071 
    1072     def sendCredentials(self, applicant, password):
    1073         """Send credentials as email.
    1074 
    1075         Input is the applicant for which credentials are sent and the
    1076         password.
    1077 
    1078         Returns True or False to indicate successful operation.
    1079         """
    1080         sirp_utils = getUtility(ISIRPUtils)
    1081         username = applicant.applicant_id
    1082         fullname = applicant.display_fullname
    1083         subject = 'Your SIRP credentials'
    1084         msg = 'You have successfully been registered for the'
    1085         email_to = applicant.email
    1086         login_url = self.url(grok.getSite(), 'login')
    1087         success = sirp_utils.sendPassword(fullname,msg,username,
    1088             password,login_url,email_to,subject)
    1089         return success
    10901073
    10911074class ApplicantRegistrationEmailSent(SIRPPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/applicantregemailsent.pt

    r7379 r7399  
    66  <p>
    77    An email with your user name and password
    8     has been sent to <span tal:replace="view/email">user@foo.baz</span>
     8    has been sent to <span tal:replace="view/email">user@foo.baz</span>.
    99  </p>
    1010  <p>
     
    1212  </p>
    1313  <p>
    14     Thanks for using SIRP.
     14    Thanks for using SIRP!
     15  </p>
    1516</div>
Note: See TracChangeset for help on using the changeset viewer.