Skip to content

Instantly share code, notes, and snippets.

@iopsthecloud
Created September 21, 2015 22:03
Show Gist options
  • Save iopsthecloud/9db2a8185966b01ee8e9 to your computer and use it in GitHub Desktop.
Save iopsthecloud/9db2a8185966b01ee8e9 to your computer and use it in GitHub Desktop.
class CategoryCreateView(GroupRequiredMixin, CreateView):
template_name = "catalogs/category/create.html"
model = Category
group_required = [u"admin", u"supervisor"]
login_url = '/error/'
raise_exception = True
redirect_unauthenticated_users = True
(...)
class PermissionDeniedView(TemplateView):
template_name = "core/error.html"
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated() is False:
redirect_to = request.GET.get('next', None)
if redirect_to is not None:
return redirect(reverse('authorization:login') + "?next=%s" % redirect_to)
return redirect(reverse('authorization:login'))
return super(PermissionDeniedView, self).dispatch(request, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment