summaryrefslogtreecommitdiff
path: root/statistics_app/views.py
diff options
context:
space:
mode:
authorankitjavalkar2019-09-25 15:46:43 +0530
committerankitjavalkar2019-09-25 15:46:43 +0530
commit194ee67048b80655f3da6be1f5018fdc278ffc58 (patch)
tree4cc8b2f6db31171cb5009da00e9082dc3d7f6229 /statistics_app/views.py
parent432998c8df215cf24512bc2e50e47ee6fdf952d0 (diff)
downloadworkshop_booking-194ee67048b80655f3da6be1f5018fdc278ffc58.tar.gz
workshop_booking-194ee67048b80655f3da6be1f5018fdc278ffc58.tar.bz2
workshop_booking-194ee67048b80655f3da6be1f5018fdc278ffc58.zip
Multiple Changes:
- Add teams - Fix bug that causes todays booked workshops to disappear from queue - Add a graph to display viz for accepted workshops in a team - Remove unnecessary loops
Diffstat (limited to 'statistics_app/views.py')
-rw-r--r--statistics_app/views.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/statistics_app/views.py b/statistics_app/views.py
index 1507196..8c3a6f0 100644
--- a/statistics_app/views.py
+++ b/statistics_app/views.py
@@ -10,6 +10,8 @@ from workshop_app.models import (
BookedWorkshop, ProposeWorkshopDate,
Testimonial
)
+from teams.models import Team
+
from django.template.loader import get_template
from django.template import RequestContext
from datetime import datetime, date
@@ -582,3 +584,27 @@ def profile_stats(request):
else:
logout(request)
return render(request, "workshop_app/logout.html")
+
+@login_required
+def team_stats(request, team_id):
+ user = request.user
+ team = Team.objects.get(team_id)
+ if user not in team.members.all():
+ if user.groups.filter(name='instructor').count() > 0:
+ return redirect('/manage/')
+ return redirect('/book/')
+
+ member_workshop_data = {}
+ for member in team.members.all():
+ workshop_count = ProposeWorkshopDate.objects.filter(proposed_workshop_instructor=member.id).count()
+ if member_workshop_data.get('data'):
+ member_workshop_data['data'].append(workshop_count)
+ else:
+ member_workshop_data['data'] = [workshop_count]
+ if member_workshop_data.get('labels'):
+ member_workshop_data['labels'].append(member.user.username)
+ else:
+ member_workshop_data['labels'] = [member.user.username]
+ return render(request, 'statistics_app/team_stats.html', {'workshop_data': member_workshop_data})
+
+