Skip to content

Commit

Permalink
chore: black
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed Sep 10, 2024
1 parent b94dc08 commit ec2f5bb
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions aanmelden/src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View

from aanmelden.src.mixins import ClientCredentialsRequiredMixin, SlotContextMixin, AuthenticatedMixin
from aanmelden.src.mixins import (
ClientCredentialsRequiredMixin,
SlotContextMixin,
AuthenticatedMixin,
)
from aanmelden.src.models import DjoUser
from aanmelden.src.models import Presence, MacAddress, Slot, DAY_NUMBERS
from aanmelden.src.utils import (
Expand Down Expand Up @@ -142,9 +146,8 @@ def get(self, request):
)

dates = list(
request.user.presence_set.filter(
date__gte=datetime.today()
).order_by("date")
request.user.presence_set.filter(date__gte=datetime.today())
.order_by("date")
.values_list("date", flat=True)
)

Expand Down Expand Up @@ -221,11 +224,27 @@ def patch(self, request, *args, **kwargs):
if "add" in body:
for add in body["add"]:
add_date = parse_date(add)
register_future(add_date, Slot.objects.filter(name=list(DAY_NUMBERS.keys())[list(DAY_NUMBERS.values()).index(add_date.weekday())]).first(), request.user)
register_future(
add_date,
Slot.objects.filter(
name=list(DAY_NUMBERS.keys())[
list(DAY_NUMBERS.values()).index(add_date.weekday())
]
).first(),
request.user,
)

if "remove" in body:
for remove in body["remove"]:
remove_date = parse_date(remove)
deregister_future(remove_date, Slot.objects.filter(name=list(DAY_NUMBERS.keys())[list(DAY_NUMBERS.values()).index(remove_date.weekday())]).first(), request.user)
deregister_future(
remove_date,
Slot.objects.filter(
name=list(DAY_NUMBERS.keys())[
list(DAY_NUMBERS.values()).index(remove_date.weekday())
]
).first(),
request.user,
)

return JsonResponse({"error": None})

0 comments on commit ec2f5bb

Please sign in to comment.