bread-and-pepper/django-userena — pull request #191 by jscherer26 (2012-05-03 01:16:26+00:00)
Title: Added userena.views.signout with messages.success

Very nice code. I didn't see anyone suggest this so I thought I would.

signin has a messages.success of 'You have been signed in.'
signout should have a messages.success of 'You have been signed out.'

I have my USERENA_REDIRECT_ON_SIGNOUT = '/' and I use messages to inform the user. I actually have a section on my base.html between my menu section and content section that automatically displays the messages if there are any, which greatly simplifies my code. I think this is a pretty common usage.

These changes should be backward compatible as there was not previously a userena.views.signout. The changes to userena.views.urls appears cleaner, simpler and more uniform to me. I could have done this

def signout(request, *args, **kwargs):
if request.user.is_authenticated() and userena_settings.USERENA_USE_MESSAGES:
messages.success(request, _('You have been signed out.'), fail_silently=True)
return djangoLogout(request, template_name='userena/signout.html', *args, **kwargs)

I didn't want to assume the logout would be successful. I tested the code as best that I could. I tried to write tests, but I don't understand them well enough to know how to check signout results, or I would have included them.