Python django.contrib.auth.mixins 模块,AccessMixin() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.contrib.auth.mixins.AccessMixin()

项目:Server    作者:malaonline    | 项目源码 | 文件源码
def logout(request):
    auth.logout(request)
    return redirect('import_:login')


# class StaffRoleRequiredMixin(AccessMixin):
#     def dispatch(self, request, *args, **kwargs):
#         url_name = self.request.resolver_match.url_name
#         for group in self.request.user.groups.all():
#             for staff_permission in group.staffpermission_set.all():
#                 if staff_permission.allowed_url_name == 'all' \
#                         or staff_permission.allowed_url_name == url_name:
#                     return super(StaffRoleRequiredMixin, self).dispatch(
#                             request, *args, **kwargs)
#
#         return HttpResponse("Not Allowed.", status=403)