Skip to content

Commit

Permalink
api linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoutAllaert committed May 23, 2024
1 parent 5fe98d2 commit 8afa820
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
2 changes: 0 additions & 2 deletions api/middleware/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def __call__(self, request):
return self.get_response(request)




class DisableCSRFMiddleware(object):

def __init__(self, get_response):
Expand Down
3 changes: 1 addition & 2 deletions api/middleware/middleware_lesgever_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):

mail = "[email protected]"
try:
user = User.objects.get(username=mail)
Expand Down Expand Up @@ -64,7 +64,6 @@ def __call__(self, request):


class DisableCSRFMiddleware(object):

def __init__(self, get_response):
self.get_response = get_response

Expand Down
3 changes: 0 additions & 3 deletions api/middleware/middleware_original.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ def __call__(self, request):
return self.get_response(request)




class DisableCSRFMiddleware(object):

def __init__(self, get_response):
self.get_response = get_response

Expand Down
4 changes: 1 addition & 3 deletions api/middleware/middleware_student_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):

mail = "[email protected]"
try:
user = User.objects.get(username=mail)
Expand All @@ -51,7 +51,6 @@ def __call__(self, request):
if serializer.is_valid():
serializer.save()


gebruiker_post_data = {
"user": request.user.id,
"subjects": [],
Expand All @@ -65,7 +64,6 @@ def __call__(self, request):


class DisableCSRFMiddleware(object):

def __init__(self, get_response):
self.get_response = get_response

Expand Down
6 changes: 4 additions & 2 deletions api/views/groep.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def groep_detail(request, id, format=None):
return Response(serializer.data)

if request.method in ["PUT", "PATCH"]:
if has_permissions(request.user) or validate_new_students(request.user, groep, request.data):
if has_permissions(request.user) or validate_new_students(
request.user, groep, request.data
):
if request.method == "PUT":
serializer = GroepSerializer(groep, data=request.data)
else:
Expand All @@ -99,5 +101,5 @@ def groep_detail(request, id, format=None):

def validate_new_students(user, current_groep, data):
old = set(map(lambda student: student.user.id, current_groep.studenten.all()))
new = set(data.get('studenten'))
new = set(data.get("studenten"))
return (old - new).union(new - old) == {user.id}

0 comments on commit 8afa820

Please sign in to comment.