diff options
author | Akshen | 2018-02-16 13:50:23 +0530 |
---|---|---|
committer | GitHub | 2018-02-16 13:50:23 +0530 |
commit | aadf4afec1ff4517f8b4df7ed662ece52fb56ffd (patch) | |
tree | 0fc19095e7b40791b754c5f05d240d05a66c516c | |
parent | 71b90d34ef823839776851440c48a11628f60ff3 (diff) | |
parent | 0dfe3a2e7321ee10bb956ffd16ed960c7a81b19f (diff) | |
download | workshop_booking-aadf4afec1ff4517f8b4df7ed662ece52fb56ffd.tar.gz workshop_booking-aadf4afec1ff4517f8b4df7ed662ece52fb56ffd.tar.bz2 workshop_booking-aadf4afec1ff4517f8b4df7ed662ece52fb56ffd.zip |
Merge pull request #39 from Akshen/develop
Add Profile Statistics
14 files changed, 192 insertions, 2 deletions
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 %} + <nav class="navbar navbar-default navbar-custom"> + <div class="container-fluid"> + <div class="navbar-header"> + <a class="navbar-brand" href="{{ URL_ROOT }}/manage/">Home</a> + </div> + <ul class="nav navbar-nav"> + <li ><a href="{{ URL_ROOT }}/create_workshop/">Create Workshop</a></li> + <li ><a href="{{ URL_ROOT }}/view_workshoptype_list/"> Workshop List</a></li> + <li ><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> + <li><a href="{{ URL_ROOT }}/workshop_stats/" >Workshop Stats</a></li> + <li class="active"><a href="{{ URL_ROOT }}/profile_stats/" >Profile Stats</a></li> + </ul> + <ul class="nav navbar-nav navbar-right"> + <li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li> + <li><a href="{{ URL_ROOT }}/logout/"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li> + </ul> + </div> + </nav> +{% endblock %} + +{% block extra %} + <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> + <script src="https://code.jquery.com/jquery-1.12.4.js"></script> + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> + <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> + + <script type="text/javascript"> + $( function() { + $( "fieldset" ).controlgroup(); + }); + + + $(document).ready(function() { + $('input[type=radio]').change(function() { + if (this.value == "CP") { + var ielem = document.getElementById('instructor_data'); + var celem = document.getElementById('coordinator_data'); + ielem.style.display = "none"; + celem.style.display = "table"; + } + else{ + var ielem = document.getElementById('instructor_data'); + var celem = document.getElementById('coordinator_data'); + ielem.style.display = "table"; + celem.style.display = "none"; + + } + }); + }); + </script> +{% endblock %} + + +{% block content %} + <div class="container"> + <div class="row"> + <div class="col-md-6" align="left" > + <fieldset data-mini="true"> + <label for="radio-1">Instructor Statistics </label> + <input type="radio" name="radio-1" id="radio-1" value="IP"> + <label for="radio-2">Coordinator Statistics</label> + <input type="radio" name="radio-1" id="radio-2" value="CP"> + </fieldset> + </div> + <br> + <br> + <!-- Instructor Data Table --> + <table class="table" id="instructor_data" style="display: none"> + <thead> + <tr> + <th>User</th> + <th>Institute Name</th> + <th>Workshop Count</th> + </tr> + </thead> + {% csrf_token %} + {% for profile_data in instructor_data %} + <tbody> + <tr> + <td>{{ profile_data.profile.user}}</td> + <td>{{ profile_data.profile.institute}}</td> + <td>{{ profile_data.count}}</td> + </tr> + </tbody> + {% endfor %} + </table> + + <!-- Coordinator Data Table --> + <table class="table" id="coordinator_data" style="display: none"> + <thead> + <tr> + <th>User</th> + <th>Institute Name</th> + <th>Registration Date</th> + <th>Workshop Count</th> + </tr> + </thead> + {% csrf_token %} + {% for profile_data in coordinator_data %} + <tbody> + <tr> + <td>{{ profile_data.profile.user}}</td> + <td>{{ profile_data.profile.institute}}</td> + <td>{{ profile_data.profile.user.date_joined | date}}</td> + <td>{{ profile_data.count}}</td> + </tr> + </tbody> + {% endfor %} + </table> + </div> + </div> + +{% 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 @@ <li ><a href="{{ URL_ROOT }}/view_workshoptype_list/"> Workshop List</a></li> <li ><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li class="active"><a href="{{ URL_ROOT }}/workshop_stats/" >Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/profile_stats/" >Profile Stats</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li> 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 @@ <li ><a href="{{ URL_ROOT }}/view_workshoptype_list/"> Workshop List</a></li> <li ><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li><a href="{{ URL_ROOT }}/statistics/">Workshop stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li> 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 @@ <li><a href="{{ URL_ROOT }}/view_workshoptype_list/">Workshop List</a></li> <li><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li><a href="{{ URL_ROOT }}/statistics/">Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> {% else %} <div class="navbar-header"> diff --git a/workshop_app/templates/workshop_app/manage.html b/workshop_app/templates/workshop_app/manage.html index 9f0c94f..d9fb6b1 100644 --- a/workshop_app/templates/workshop_app/manage.html +++ b/workshop_app/templates/workshop_app/manage.html @@ -11,6 +11,7 @@ <li ><a href="{{ URL_ROOT }}/view_workshoptype_list/"> Workshop List</a></li> <li ><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li><a href="{{ URL_ROOT }}/statistics/">Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li> diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html index 4bb8c0c..7c0f625 100644 --- a/workshop_app/templates/workshop_app/my_workshops.html +++ b/workshop_app/templates/workshop_app/my_workshops.html @@ -130,6 +130,7 @@ <li><a href="{{ URL_ROOT }}/view_workshoptype_list/">Workshop List</a></li> <li class="active"><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li><a href="{{ URL_ROOT }}/workshop_stats/">Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> {% else %} <div class="navbar-header"> diff --git a/workshop_app/templates/workshop_app/profile_updated.html b/workshop_app/templates/workshop_app/profile_updated.html index 495a6ed..8553471 100644 --- a/workshop_app/templates/workshop_app/profile_updated.html +++ b/workshop_app/templates/workshop_app/profile_updated.html @@ -16,6 +16,7 @@ <li><a href="{{ URL_ROOT }}/view_workshoptype_details/"> Workshop List</a></li> <li><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li><a href="{{ URL_ROOT }}/statistics/">Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> {% else %} <div class="navbar-header"> diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html index be06808..f688017 100644 --- a/workshop_app/templates/workshop_app/view_profile.html +++ b/workshop_app/templates/workshop_app/view_profile.html @@ -16,6 +16,7 @@ <li><a href="{{ URL_ROOT }}/view_workshoptype_list/">Workshop List</a></li> <li><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li><a href="{{ URL_ROOT }}/statistics/">Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> {% else %} <div class="navbar-header"> diff --git a/workshop_app/templates/workshop_app/view_workshoptype_list.html b/workshop_app/templates/workshop_app/view_workshoptype_list.html index 804d671..dfbc5d7 100644 --- a/workshop_app/templates/workshop_app/view_workshoptype_list.html +++ b/workshop_app/templates/workshop_app/view_workshoptype_list.html @@ -16,6 +16,7 @@ {% if request.user.profile.position == 'instructor'%} <li><a href="{{ URL_ROOT }}/create_workshop/">Create Workshop</a></li> <li><a href="{{ URL_ROOT }}/statistics/">Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> {% else %} <li><a href="{{ URL_ROOT }}/book/">Book</a></li> <li><a href="{{ URL_ROOT }}/propose_workshop/">Propose a Workshop</a></li> diff --git a/workshop_app/templates/workshop_app/workshop_stats.html b/workshop_app/templates/workshop_app/workshop_stats.html index b5473e3..78832ec 100644 --- a/workshop_app/templates/workshop_app/workshop_stats.html +++ b/workshop_app/templates/workshop_app/workshop_stats.html @@ -11,6 +11,7 @@ <li ><a href="{{ URL_ROOT }}/view_workshoptype_list/"> Workshop List</a></li> <li ><a href="{{ URL_ROOT }}/my_workshops/">My Workshops</a></li> <li class="active"><a href="{{ URL_ROOT }}/workshop_stats/" >Workshop Stats</a></li> + <li><a href="{{ URL_ROOT }}/statistics/profile_stats/" >Profile Stats</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="{{ URL_ROOT }}/view_profile/"><span class="glyphicon glyphicon-user"></span> Profile </a></li> diff --git a/workshop_app/views.py b/workshop_app/views.py index ea5d8d6..2835b49 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -940,7 +940,7 @@ def check_workshop_type(x): def workshop_stats(request): user = request.user today = datetime.now() - upto = today + dt.timedelta(days=15) + upto = today + dt.timedelta(days=30) #For Monthly Chart workshop_count = [0] * 12 |