From 0dfe3a2e7321ee10bb956ffd16ed960c7a81b19f Mon Sep 17 00:00:00 2001
From: Akshen
Date: Fri, 16 Feb 2018 13:46:23 +0530
Subject: Add Profile Statistics
- Instructor can view stats of Coordinator and Instructors
- Upcoming Workshop limit increased to 30 days
---
.../templates/statistics_app/profile_stats.html | 123 +++++++++++++++++++++
.../statistics_app/workshop_public_stats.html | 2 +-
.../templates/statistics_app/workshop_stats.html | 1 +
statistics_app/urls.py | 1 +
statistics_app/views.py | 57 ++++++++++
.../templates/workshop_app/create_workshop.html | 1 +
.../templates/workshop_app/edit_profile.html | 1 +
workshop_app/templates/workshop_app/manage.html | 1 +
.../templates/workshop_app/my_workshops.html | 1 +
.../templates/workshop_app/profile_updated.html | 1 +
.../templates/workshop_app/view_profile.html | 1 +
.../workshop_app/view_workshoptype_list.html | 1 +
.../templates/workshop_app/workshop_stats.html | 1 +
workshop_app/views.py | 2 +-
14 files changed, 192 insertions(+), 2 deletions(-)
create mode 100644 statistics_app/templates/statistics_app/profile_stats.html
diff --git a/statistics_app/templates/statistics_app/profile_stats.html b/statistics_app/templates/statistics_app/profile_stats.html
new file mode 100644
index 0000000..a5f4685
--- /dev/null
+++ b/statistics_app/templates/statistics_app/profile_stats.html
@@ -0,0 +1,123 @@
+{% extends 'workshop_app/base.html' %}
+
+{% block title %}
+ Profile Statistics
+{% endblock %}
+
+{% block header %}
+
+{% endblock %}
+
+{% block extra %}
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+
+
+ User |
+ Institute Name |
+ Workshop Count |
+
+
+ {% csrf_token %}
+ {% for profile_data in instructor_data %}
+
+
+ {{ profile_data.profile.user}} |
+ {{ profile_data.profile.institute}} |
+ {{ profile_data.count}} |
+
+
+ {% endfor %}
+
+
+
+
+
+
+ User |
+ Institute Name |
+ Registration Date |
+ Workshop Count |
+
+
+ {% csrf_token %}
+ {% for profile_data in coordinator_data %}
+
+
+ {{ profile_data.profile.user}} |
+ {{ profile_data.profile.institute}} |
+ {{ profile_data.profile.user.date_joined | date}} |
+ {{ profile_data.count}} |
+
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/statistics_app/templates/statistics_app/workshop_public_stats.html b/statistics_app/templates/statistics_app/workshop_public_stats.html
index 78e08f8..237bcbc 100644
--- a/statistics_app/templates/statistics_app/workshop_public_stats.html
+++ b/statistics_app/templates/statistics_app/workshop_public_stats.html
@@ -303,7 +303,7 @@
$( "#visualization" ).dialog({
resizable: false,
draggable: true,
- title: 'State wise Completed Workshops(Map of India)',
+ title: 'State wise Completed Workshops(Map of India)',
closeOnEscape: true,
stack: true,
zIndex: 10000,
diff --git a/statistics_app/templates/statistics_app/workshop_stats.html b/statistics_app/templates/statistics_app/workshop_stats.html
index 03a3fb1..7775eba 100644
--- a/statistics_app/templates/statistics_app/workshop_stats.html
+++ b/statistics_app/templates/statistics_app/workshop_stats.html
@@ -14,6 +14,7 @@
Workshop List
My Workshops
Workshop Stats
+ Profile Stats
- Profile
diff --git a/statistics_app/urls.py b/statistics_app/urls.py
index a846192..94b358e 100644
--- a/statistics_app/urls.py
+++ b/statistics_app/urls.py
@@ -9,4 +9,5 @@ import django
urlpatterns = [
url(r'^statistics/$', views.workshop_stats),
url(r'^statistics/public_stats/$', views.workshop_public_stats),
+ url(r'^statistics/profile_stats/$', views.profile_stats),
]
diff --git a/statistics_app/views.py b/statistics_app/views.py
index be79a78..0613546 100644
--- a/statistics_app/views.py
+++ b/statistics_app/views.py
@@ -453,3 +453,60 @@ def workshop_public_stats(request):
"workshoptype_list": workshoptype_list[::-1],
"workshoptype_count": workshoptype_count,
"india_map": states})
+
+
+@login_required
+def profile_stats(request):
+ user = request.user
+ if is_instructor(user) and is_email_checked(user):
+ profiles = Profile.objects.all()
+
+ rworkshops = RequestedWorkshop.objects.filter(status='ACCEPTED')
+ pworkshops = ProposeWorkshopDate.objects.filter(status='ACCEPTED')
+
+ iprofile = Profile.objects.filter(position='instructor')
+ cprofile = Profile.objects.filter(position='coordinator')
+
+ instructor_profile = []
+ coordinator_profile = []
+
+ for p in iprofile:
+ instructor_profile.append({"profile": p,
+ "count": 0
+ })
+
+
+ for p in cprofile:
+ coordinator_profile.append({"profile": p,
+ "count": 0
+ })
+
+ for p in instructor_profile:
+ p['count'] += RequestedWorkshop.objects.filter(
+ requested_workshop_instructor_id=p['profile'].user.id,
+ status='ACCEPTED').count()
+
+ p['count'] += ProposeWorkshopDate.objects.filter(
+ proposed_workshop_instructor_id=p['profile'].user.id,
+ status='ACCEPTED').count()
+
+ for p in coordinator_profile:
+ p['count'] += RequestedWorkshop.objects.filter(
+ requested_workshop_coordinator_id=p['profile'].user.id,
+ status='ACCEPTED').count()
+
+ p['count'] += ProposeWorkshopDate.objects.filter(
+ proposed_workshop_coordinator_id=p['profile'].user.id,
+ status='ACCEPTED').count()
+
+ return render(request, "statistics_app/profile_stats.html",
+ {
+ "instructor_data": instructor_profile,
+ "coordinator_data": coordinator_profile,
+ })
+ else:
+ logout(request)
+ return render(request, "workshop_app/logout.html")
+
+
+
diff --git a/workshop_app/templates/workshop_app/create_workshop.html b/workshop_app/templates/workshop_app/create_workshop.html
index 192fb14..1cb5a31 100644
--- a/workshop_app/templates/workshop_app/create_workshop.html
+++ b/workshop_app/templates/workshop_app/create_workshop.html
@@ -22,6 +22,7 @@
- Workshop List
- My Workshops
- Workshop stats
+ - Profile Stats
- Profile
diff --git a/workshop_app/templates/workshop_app/edit_profile.html b/workshop_app/templates/workshop_app/edit_profile.html
index 17a07c2..e611888 100644
--- a/workshop_app/templates/workshop_app/edit_profile.html
+++ b/workshop_app/templates/workshop_app/edit_profile.html
@@ -16,6 +16,7 @@
- Workshop List
- My Workshops
- Workshop Stats
+ - Profile Stats
{% else %}