django-utils

personal collection of django utilities
git clone https://git.ce9e.org/django-utils.git

commit
5f9b6fa87381e9c502abf9d4634efd1ff3ef3d3e
parent
479d5ae5bef52f5a99983b02afc40d5dfdf4d40c
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-02-28 11:55
use BasBackend from django >= 3.0

Diffstat

M utils/context_groups.py 20 +-------------------

1 files changed, 1 insertions, 19 deletions


diff --git a/utils/context_groups.py b/utils/context_groups.py

@@ -1,5 +1,6 @@
    1     1 from django import template
    2     2 from django.db import models
   -1     3 from django.contrib.auth.backends import BaseBackend
    3     4 from django.contrib.auth.models import User
    4     5 from django.contrib.auth.models import Permission
    5     6 from django.contrib.auth import mixins as auth_mixins
@@ -27,25 +28,6 @@ class ContextGroup(models.Model):
   27    28         return ['{}.{}'.format(ct, name) for ct, name in perms]
   28    29 
   29    30 
   30    -1 class BaseBackend:
   31    -1     def authenticate(self, request, **kwargs):
   32    -1         return None
   33    -1 
   34    -1     def get_user(self, user_id):
   35    -1         return None
   36    -1 
   37    -1     def get_group_permissions(self, user, obj=None):
   38    -1         return set()
   39    -1 
   40    -1     def get_all_permissions(self, user, obj=None):
   41    -1         return self.get_group_permissions(user, obj=obj)
   42    -1 
   43    -1     def has_perm(self, user, perm, obj=None):
   44    -1         # you may want to override this for performance reasons
   45    -1         perms = self.get_all_permissions(user, obj=obj)
   46    -1         return perm in perms
   47    -1 
   48    -1 
   49    31 class BasicObjectBackend(BaseBackend):
   50    32     # See https://code.djangoproject.com/ticket/20218
   51    33