Modify

Opened 5 years ago

#5501 new enhancement

Using email from django for announcer plugin

Reported by: jug Owned by: waylan
Priority: normal Component: DjangoAuthIntegration
Severity: normal Keywords: django auth email announcerplugin
Cc: Trac Release: 0.11

Description

Add the following to the plugin and enable it in trac.ini (or WebAdmin) to get the AnnouncerPlugin using email addresses from your django db.

from announcerplugin.api import IAnnouncementAddressResolver
    
class DjangoEmailResolver(Component):
    implements(IAnnouncementAddressResolver)
        
    def get_address_for_name(self, name, authenticated):
        settings = self.config.get('djangoauth', 'django_settings_module')
        os.environ['DJANGO_SETTINGS_MODULE'] = settings
        from django.contrib.auth.models import User
        try:
            user = User.objects.get(username=name)
            return user.email
        except User.DoesNotExist:
            return None

Attachments (0)

Change History (0)

Add Comment

Modify Ticket

Action
as new The owner will remain waylan.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.