Skip to content

Commit

Permalink
[pre-commit] fixes from hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 6, 2023
1 parent 2b70e5c commit 7a9377c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
hostname: parkour2-django
build:
dockerfile: ./Dockerfile
target: pk2_dev
target: pk2_base
env_file:
- ./misc/parkour.env
restart: always
Expand Down
2 changes: 1 addition & 1 deletion misc/parkour.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ [email protected]
EMAIL_HOST=mail.server.tld
EMAIL_SUBJECT_PREFIX=[Parkour]
SERVER_EMAIL=[email protected]
CSRF_TRUSTED_ORIGINS=http://127.0.0.1,https://*.server.tld,http://localhost:5173
CSRF_TRUSTED_ORIGINS=http://127.0.0.1,https://*.server.tld
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_PASSWORD=change_me__stay_safe
Expand Down
24 changes: 15 additions & 9 deletions parkour_app/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from django.db.models import Q
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, render
from request.models import Request
from django.utils import timezone
from request.models import Request
from rest_framework import status, viewsets
from rest_framework.authentication import SessionAuthentication
from rest_framework.decorators import action
Expand Down Expand Up @@ -212,18 +212,24 @@ def responsibles(self, request, *args, **kwargs):

def list(self, request, *args, **kwargs):
today_var = timezone.now()
start_date_var = request.query_params.get('start_date')
end_date_var = request.query_params.get('end_date')
ongoing_var = request.query_params.get('ongoing')
upcoming_var = request.query_params.get('upcoming')
start_date_var = request.query_params.get("start_date")
end_date_var = request.query_params.get("end_date")
ongoing_var = request.query_params.get("ongoing")
upcoming_var = request.query_params.get("upcoming")
queryset_var = self.queryset.filter()

if str(ongoing_var).lower() in ["true", 't', 'yes','y', '1']:
queryset_var = self.queryset.filter(Q(start_date__lte=today_var, end_date__gte=today_var) | Q(start_date__lte=today_var, end_date__isnull=True))
elif str(upcoming_var).lower() in ["true", 't', 'yes','y', '1']:
if str(ongoing_var).lower() in ["true", "t", "yes", "y", "1"]:
queryset_var = self.queryset.filter(
Q(start_date__lte=today_var, end_date__gte=today_var)
| Q(start_date__lte=today_var, end_date__isnull=True)
)
elif str(upcoming_var).lower() in ["true", "t", "yes", "y", "1"]:
queryset_var = self.queryset.filter(start_date__gte=today_var)
elif start_date_var and end_date_var:
queryset_var = self.queryset.filter(Q(start_date__gte=start_date_var, start_date__lte=end_date_var)| Q(start_date__gte=start_date_var, end_date__isnull=True))
queryset_var = self.queryset.filter(
Q(start_date__gte=start_date_var, start_date__lte=end_date_var)
| Q(start_date__gte=start_date_var, end_date__isnull=True)
)

serializer = DutySerializer(queryset_var, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
Expand Down
4 changes: 2 additions & 2 deletions parkour_app/wui/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# CORS Configuration
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_ALL_ORIGINS = False
CORS_ALLOWED_ORIGINS = ['http://localhost:5173']
CORS_ALLOWED_ORIGINS = ["http://localhost:5173"]

# Application definition
INSTALLED_APPS = [
Expand Down Expand Up @@ -75,7 +75,7 @@
"stats",
"metadata_exporter",
"drf_spectacular",
'corsheaders',
"corsheaders",
]

MIDDLEWARE = [
Expand Down

0 comments on commit 7a9377c

Please sign in to comment.