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

feat: add proposals api and view #1128

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add proposals api and view
  • Loading branch information
baby230211 committed Mar 6, 2023
commit 0d39f03963f15e4017e1db7ff01cb0c56063a29b
Empty file added src/proposals/api/__init__.py
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions src/proposals/api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from proposals.api.views import ProposalAPIView

urlpatterns = [
path("summary/", ProposalAPIView.as_view()),
]
26 changes: 26 additions & 0 deletions src/proposals/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from rest_framework import views
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated

from core.authentication import TokenAuthentication
from proposals.models import TalkProposal, TutorialProposal
from reviews.models import Review


class ProposalAPIView(views.APIView):
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved

authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request):
num_proposed_talk = TalkProposal.objects.filter(cancelled=False).count()
num_proposed_tutorial = TutorialProposal.objects.filter(cancelled=False).count()
num_stage_1_reviews = Review.objects.filter(stage=1).count()
num_stage_2_reviews = Review.objects.filter(stage=2).count()

response_data = {}
response_data["num_proposed"] = num_proposed_talk + num_proposed_tutorial
response_data["num_stage_1_reviews"] = num_stage_1_reviews
response_data["num_stage_2_reviews"] = num_stage_2_reviews

return Response(response_data)
1 change: 1 addition & 0 deletions src/pycontw2016/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
urlpatterns += [
url(r'^ccip/', include('ccip.urls')),
url(r'^api/sponsors/', include('sponsors.api.urls')),
url(r'^api/proposals/', include('proposals.api.urls')),
url(r'^api/events/', include('events.api.urls', namespace="events")),
url(r'^set-language/$', set_language, name='set_language'),
url(r'^admin/', admin.site.urls),
Expand Down