Changeset 7407


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

Harmonize sendCredentials which can now be used for all kinds of users.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
3 edited

Legend:

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

    r7399 r7407  
    10641064        # Send email with credentials
    10651065        login_url = self.url(grok.getSite(), 'login')
    1066         if sirp_utils.sendCredentials(applicant, password, login_url):
     1066        msg = 'You have successfully been registered for the'
     1067        if sirp_utils.sendCredentials(IUserAccount(applicant),
     1068            password, login_url, msg):
    10671069            self.redirect(self.url(self.context, 'registration_complete',
    10681070                                   data = dict(email=applicant.email)))
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7404 r7407  
    22342234        IUserAccount(student).setPassword(pwd)
    22352235        # Send email with new redentials
    2236         username = student.student_id
    2237         fullname = student.display_fullname
    2238         subject = 'Your SIRP credentials'
    22392236        msg = 'You have successfully changed your password for the'
    2240         email_to = student.email
    22412237        login_url = self.url(grok.getSite(), 'login')
    2242         success = sirp_utils.sendPassword(fullname,msg,username,
    2243             pwd,login_url,email_to,subject)
     2238        success = sirp_utils.sendCredentials(
     2239            IUserAccount(student),pwd,login_url,msg)
    22442240        if success:
    22452241            self.flash('An email with your user name and password ' +
    2246                 'has been sent to %s.' % email_to)
     2242                'has been sent to %s.' % email)
    22472243        else:
    22482244            self.flash('An smtp server error occurred.')
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py

    r7404 r7407  
    9999
    100100
    101     def sendCredentials(self, applicant, password, login_url):
     101    def sendCredentials(self, user, password=None, login_url=None, msg=None):
    102102        """Send credentials as email.
    103103
     
    107107        Returns True or False to indicate successful operation.
    108108        """
    109         username = applicant.applicant_id
    110109        subject = 'Your SIRP credentials'
    111         msg = 'You have successfully been registered for the'
    112110        text = """Dear %s,
    113111
     
    130128        from_name = config.name_admin
    131129        from_addr = config.email_admin
    132         rcpt_name = applicant.display_fullname
    133         rcpt_addr = applicant.email
     130        rcpt_name = user.title
     131        rcpt_addr = user.email
    134132        body = text % (
    135                 rcpt_name, msg,config.name,username,password,login_url)
     133                rcpt_name, msg,config.name,user.name,password,login_url)
    136134        return send_mail(
    137135            from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
Note: See TracChangeset for help on using the changeset viewer.