From d82e1daa5cd61d7e12a22c685a35668aa2211852 Mon Sep 17 00:00:00 2001 From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de> Date: Fri, 10 Nov 2017 22:21:13 +0100 Subject: [PATCH] Deleted custom_annotations --- backend/core/custom_annotations.py | 23 ----------------------- backend/core/models.py | 2 +- backend/core/views.py | 1 + 3 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 backend/core/custom_annotations.py diff --git a/backend/core/custom_annotations.py b/backend/core/custom_annotations.py deleted file mode 100644 index 0b1463a5..00000000 --- a/backend/core/custom_annotations.py +++ /dev/null @@ -1,23 +0,0 @@ -from django.contrib.auth.decorators import user_passes_test - - -"""I collect custom decorators here that I use for the simple premission system - -Currently the following options are available - - group_required - - in_groups -""" - - -def in_groups(user, group_list): - return bool(user.groups.filter(name__in=group_list)) # or user.is_superuser - - -def group_required(*group_names): - """Requires user membership in at least one of the groups passed in. Should - only be used in annotations - """ - def _in_groups(u): - if u.is_authenticated(): - return in_groups(u, group_names) - return user_passes_test(_in_groups) diff --git a/backend/core/models.py b/backend/core/models.py index 32189b7e..abfd54d6 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -46,7 +46,7 @@ def get_annotated_tutor_list(): Returns: TYPE: the annotated QuerySet """ - return User.objects\ + return get_user_model().objects\ .filter(groups__name='Tutors')\ .annotate(Count('feedback_list'))\ .order_by('-feedback_list__count') diff --git a/backend/core/views.py b/backend/core/views.py index 2d20a7f8..17ee5bce 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -8,6 +8,7 @@ from core.serializers import (FeedbackSerializer, StudentSerializer, log = logging.getLogger(__name__) + class StudentApiView(RetrieveAPIView): permission_classes = (IsStudent,) -- GitLab