Changeset 1552 in main for trunk


Ignore:
Timestamp:
07/24/12 15:29:27 (9 years ago)
Author:
pcosquer
Message:

sponsor: adds a new settings (NEW_ACCOUNT_SUBJECT) to customize the subject of a sponsor mail (see #126)

Location:
trunk/openPLM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/controllers/user.py

    r1516 r1552  
    3434from django.utils.translation import ugettext_lazy as _ 
    3535from django.contrib.sites.models import Site 
     36from django.template import Context, Template 
    3637 
    3738import openPLM.plmapp.models as models 
     
    4142from openPLM.plmapp.exceptions import PermissionError 
    4243from openPLM.plmapp.controllers.base import Controller, permission_required 
     44 
     45NEW_ACCOUNT_SUBJECT = u"New account on OpenPLM" 
    4346 
    4447class UserController(Controller): 
     
    228231        """ 
    229232        return self.delegationlink_delegator.order_by("role", "delegatee__username") 
     233 
     234    def get_sponsor_subject(self, new_user): 
     235        subject = getattr(settings, "NEW_ACCOUNT_SUBJECT", NEW_ACCOUNT_SUBJECT) 
     236        return Template(subject).render(Context(dict(new_user=new_user, sponsor=self._user))) 
    230237 
    231238    @permission_required(role=models.ROLE_OWNER) 
     
    260267               } 
    261268        update_index.delay("auth", "user", new_user.pk) 
    262         self._send_mail(send_mail, "New account on openPLM", [new_user], 
     269        self._send_mail(send_mail, self.get_sponsor_subject(new_user), [new_user], 
    263270                ctx, "mails/new_account")  
    264271        models.UserHistory.objects.create(action="Create", user=self._user, 
     
    290297                "password" : password, 
    291298               } 
    292         self._send_mail(send_mail, "New account on openPLM", [new_user], 
     299        self._send_mail(send_mail, self.get_sponsor_subject(new_user), [new_user], 
    293300                ctx, "mails/new_account")  
    294301 
  • trunk/openPLM/settings.py

    r1539 r1552  
    171171EMAIL_OPENPLM = "no-reply@openplm.example.com" 
    172172 
     173#XYZ: 
     174#: Subject of a sponsor mail. 
     175#: It can be a valid django template string, two variables are available: 
     176#: ``new_user`` and ``sponsor`` (:class:`.User` instances) 
     177#: for example, it could be 
     178#: ``u"Welcome {{new_user.get_full_name}}, {{sponsor.get_full_name}} has sponsored you on OpenPLM"``. 
     179NEW_ACCOUNT_SUBJECT = u"New account on OpenPLM" 
     180 
    173181#: Max file size for documents in bytes, -1 means illimited 
    174182MAX_FILE_SIZE = -1 
Note: See TracChangeset for help on using the changeset viewer.