12345678910111213141516171819202122232425 |
- from django.shortcuts import render
- from rest_framework.views import APIView
- from rest_framework.response import Response
- from django.views.generic import View
- from gauth.models import Location
- from .utils import get_review_count_by_month, get_review_count_by_week
- class ChartDataByMonth(APIView):
- def get(self, request, *args, **kwargs):
- location_id = request.GET['location_id']
- time_interval = request.GET['time_interval']
- if time_interval == 'month':
- res = get_review_count_by_month(location_id)
- else:
- res = get_review_count_by_week(location_id)
- return Response(res)
- class AnalyticsData(View):
- def get(self, request, *args, **kwargs):
- locations = Location.objects.all()
- return render(request, 'charts.html', {'location_list': locations})
|