Created
March 1, 2012 10:05
-
-
Save amccloud/1948674 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.decorators import login_required | |
class LoginRequiredMixin(object): | |
login_required = True | |
def get_login_required(self): | |
return self.login_required | |
def dispatch(self, request, *args, **kwargs): | |
self.request = request | |
self.args = args | |
self.kwargs = kwargs | |
dispatch = super(LoginRequiredMixin, self).dispatch | |
if self.get_login_required(): | |
dispatch = login_required(dispatch) | |
return dispatch(request, *args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment