|
@@ -2,7 +2,7 @@ from django.http import Http404
|
|
from django.shortcuts import render, redirect
|
|
from django.shortcuts import render, redirect
|
|
from django.views.generic import View
|
|
from django.views.generic import View
|
|
from django.contrib import messages
|
|
from django.contrib import messages
|
|
-from .forms import UserRegisterForm, StaffRegistrationForm
|
|
|
|
|
|
+from .forms import UserRegisterForm, StaffRegistrationForm, StaffSheetDateForm
|
|
from .models import UserAccount
|
|
from .models import UserAccount
|
|
from gauth.models import Location
|
|
from gauth.models import Location
|
|
from review.models import Review
|
|
from review.models import Review
|
|
@@ -11,13 +11,16 @@ from yelp.models import YelpReview
|
|
from name_extractor.models import Staff
|
|
from name_extractor.models import Staff
|
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
|
|
|
|
|
|
|
+from name_extractor.utils import extract_names_from_reviews
|
|
|
|
+
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from .utils import (
|
|
from .utils import (
|
|
get_google_review_report,
|
|
get_google_review_report,
|
|
get_facebook_report,
|
|
get_facebook_report,
|
|
get_yelp_review_report,
|
|
get_yelp_review_report,
|
|
get_this_month_analytics,
|
|
get_this_month_analytics,
|
|
- get_review_count_by_month
|
|
|
|
|
|
+ get_review_count_by_month,
|
|
|
|
+ date_str2datetime
|
|
)
|
|
)
|
|
from rest_framework.views import APIView
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from rest_framework.response import Response
|
|
@@ -133,9 +136,11 @@ class StaffLeaderBoard(View):
|
|
def get(self, request, *args, **kwargs):
|
|
def get(self, request, *args, **kwargs):
|
|
staffs = Staff.objects.filter(location=request.user.useraccount.location).order_by('-total_units')
|
|
staffs = Staff.objects.filter(location=request.user.useraccount.location).order_by('-total_units')
|
|
form = StaffRegistrationForm()
|
|
form = StaffRegistrationForm()
|
|
|
|
+ date_form = StaffSheetDateForm()
|
|
|
|
|
|
context = {
|
|
context = {
|
|
'staffs': staffs,
|
|
'staffs': staffs,
|
|
|
|
+ 'date_form': date_form,
|
|
'form': form
|
|
'form': form
|
|
}
|
|
}
|
|
return render(request, 'staff_list.html', context)
|
|
return render(request, 'staff_list.html', context)
|
|
@@ -155,3 +160,18 @@ class StaffLeaderBoard(View):
|
|
)
|
|
)
|
|
messages.success(request, f'A new staff {staff} has been created!')
|
|
messages.success(request, f'A new staff {staff} has been created!')
|
|
return redirect('location-analytics')
|
|
return redirect('location-analytics')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class ExportStaffLeaderBoard(View):
|
|
|
|
+
|
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
|
+ start_date = date_str2datetime(request.POST.get('start_date'))
|
|
|
|
+ end_date = date_str2datetime(request.POST.get('end_date'))
|
|
|
|
+ location_id = request.user.useraccount.location_id
|
|
|
|
+
|
|
|
|
+ extract_names_from_reviews(
|
|
|
|
+ start_date=start_date,
|
|
|
|
+ end_date=end_date,
|
|
|
|
+ location_id=location_id
|
|
|
|
+ )
|
|
|
|
+ return redirect('staff-leaderboard')
|