From ae9b3bf5c5e10bc027534a41cea2ab2e8ac4a94b Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Fri, 26 Jul 2024 13:19:33 +0200 Subject: [PATCH] stroopwafel eindpunt --- playlist/urls.py | 1 + playlist/views.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/playlist/urls.py b/playlist/urls.py index 03218a5..395f796 100644 --- a/playlist/urls.py +++ b/playlist/urls.py @@ -14,5 +14,6 @@ urlpatterns = [ path('overview/playlist', views.PlaylistListView.as_view(), name="playlist-list"), path('overview/playlist/', views.PlaylistDetailView.as_view(), name="playlist-detail"), path('spotify/callback', views.SpotifyCallbackView.as_view(), name="spotify-callback"), + path('stroopwafel', views.StroopwafelView.as_view(), name="stroopwafel"), path('', views.AuthView.as_view()), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/playlist/views.py b/playlist/views.py index c049fbd..b69277a 100644 --- a/playlist/views.py +++ b/playlist/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render from django.views import View -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.template.response import TemplateResponse from django.contrib.auth.mixins import LoginRequiredMixin from django.db.models import Avg @@ -287,4 +287,16 @@ class PlaylistImportView(LoginRequiredMixin, View): except Exception as e: print(e) - return self.get(request) \ No newline at end of file + return self.get(request) + +class StroopwafelView(View): + def get(self, request): + nominated_count = Track.objects.all().count() + return JsonResponse( + { + "openDate": os.getenv('DATE_OPEN'), + "deadlineNominations": os.getenv('DATE_NOM_END'), + "deadlineVoting": os.getenv('DATE_VOTE_END'), + "stemCount": nominated_count + } + )