Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggrid #74

Merged
merged 17 commits into from
Nov 6, 2023
25 changes: 23 additions & 2 deletions parkour_app/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.db.models import Q
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from request.models import Request
from rest_framework import status, viewsets
from rest_framework.authentication import SessionAuthentication
Expand Down Expand Up @@ -209,8 +210,28 @@ def responsibles(self, request, *args, **kwargs):
)
return Response(serializer.data, status=status.HTTP_200_OK)

def get(self, request, *args, **kwargs):
serializer = DutySerializer(self.queryset, many=True)
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")
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"]:
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)
)

serializer = DutySerializer(queryset_var, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)

def post(self, request, *args, **kwargs):
Expand Down
59 changes: 59 additions & 0 deletions parkour_app/duties/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# Yarn Integrity file
.yarn-integrity

# Yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
12 changes: 12 additions & 0 deletions parkour_app/duties/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Duties</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
Loading