pennersr/django-allauth — pull request #309 by jacekmitrega (2013-06-25 15:39:00+00:00)
Title: Tag messages

Hello,

I'm using Django messaging framework in my project, as soon as I enabled it, I started receiving messages from django-allauth. I needed to selectively enable/disable messages from django-allauth. I added extra_tags to all messages and they can be filtered in Django settings, like this:

```python
# Empty collection disables filtering
MESSAGE_FILTER_TAGS = set((
'account_email_confirm',
'account_email_send',
))
```

I use the following TEMPLATE_CONTEXT_PROCESSOR to filter messages:
```python
def messages(request):
"""
Returns filtered 'messages' context variable.

"""
messages = get_messages(request) or []
if settings.MESSAGE_FILTER_TAGS:
messages = [m for m in messages
if settings.MESSAGE_FILTER_TAGS.intersection(
m.extra_tags.split() if m.extra_tags else ())]
return {'messages': messages}
```

Is this something that could be useful for a broader community of users of django-allauth?