summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--workshop_app/forms.py5
-rw-r--r--workshop_app/models.py2
-rw-r--r--workshop_app/reminder_script.py2
-rw-r--r--workshop_app/templates/workshop_app/propose_workshop.html2
-rw-r--r--workshop_app/templates/workshop_app/view_profile.html4
-rw-r--r--workshop_app/templates/workshop_app/workshop_stats.html207
-rw-r--r--workshop_app/views.py43
7 files changed, 171 insertions, 94 deletions
diff --git a/workshop_app/forms.py b/workshop_app/forms.py
index 8ba486e..81eef79 100644
--- a/workshop_app/forms.py
+++ b/workshop_app/forms.py
@@ -71,7 +71,6 @@ class UserRegistrationForm(forms.Form):
password = forms.CharField(max_length=32, widget=forms.PasswordInput())
confirm_password = forms.CharField\
(max_length=32, widget=forms.PasswordInput())
-
title = forms.ChoiceField(choices=title)
first_name = forms.CharField(max_length=32)
last_name = forms.CharField(max_length=32)
@@ -224,5 +223,5 @@ class ProposeWorkshopDateForm(forms.ModelForm):
'proposed_workshop_coordinator']
widgets = {
'proposed_workshop_date': forms.DateInput(attrs={
- 'class':'datepicker'}),
- } \ No newline at end of file
+ 'class':'datepicker'})
+ } \ No newline at end of file
diff --git a/workshop_app/models.py b/workshop_app/models.py
index 5ee9150..408b36a 100644
--- a/workshop_app/models.py
+++ b/workshop_app/models.py
@@ -85,7 +85,7 @@ class Profile(models.Model):
self.user.id,
self.user.first_name,
self.user.last_name,
- self.user.email,
+ self.user.email
)
diff --git a/workshop_app/reminder_script.py b/workshop_app/reminder_script.py
index 4c4350c..e346c6d 100644
--- a/workshop_app/reminder_script.py
+++ b/workshop_app/reminder_script.py
@@ -80,4 +80,4 @@ def send_email():
[w.requested_workshop_instructor.email], fail_silently=False
)
-send_email()
+send_email() \ No newline at end of file
diff --git a/workshop_app/templates/workshop_app/propose_workshop.html b/workshop_app/templates/workshop_app/propose_workshop.html
index 95a4008..ce90dc8 100644
--- a/workshop_app/templates/workshop_app/propose_workshop.html
+++ b/workshop_app/templates/workshop_app/propose_workshop.html
@@ -22,7 +22,7 @@
changeMonth: true,
changeYear: true,
minDate: dateToday,
- maxDate: upto,
+ maxDate: upto
// You can put more options here.
});
});
diff --git a/workshop_app/templates/workshop_app/view_profile.html b/workshop_app/templates/workshop_app/view_profile.html
index 91efdf1..8f1fbae 100644
--- a/workshop_app/templates/workshop_app/view_profile.html
+++ b/workshop_app/templates/workshop_app/view_profile.html
@@ -69,6 +69,10 @@
<th><label for="id_department"><h5>{{ user.profile.department }}</h5></label></th>
</tr>
<tr>
+ <th><label for="id_location"><h5>Location:</h5></label></th>
+ <th><label for="id_location"><h5>{{ user.profile.location }}</h5></label></th>
+ </tr>
+ <tr>
<th><label for="id_position"><h5>Position:</h5></label></th>
<th><label for="id_position"><h5>{{ user.profile.position }}</h5></label></th>
</tr>
diff --git a/workshop_app/templates/workshop_app/workshop_stats.html b/workshop_app/templates/workshop_app/workshop_stats.html
index 464c625..bc6387b 100644
--- a/workshop_app/templates/workshop_app/workshop_stats.html
+++ b/workshop_app/templates/workshop_app/workshop_stats.html
@@ -63,18 +63,17 @@
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
-
- function getDate( element ) {
- var date;
- try {
- date = $.datepicker.parseDate( dateFormat, element.value );
- } catch( error ) {
- date = null;
- }
-
- return date;
- }
- } );
+
+ function getDate( element ) {
+ var date;
+ try {
+ date = $.datepicker.parseDate( dateFormat, element.value );
+ } catch( error ) {
+ date = null;
+ }
+ return date;
+ }
+ } );
</script>
@@ -82,22 +81,22 @@
{% block content %}
- <div class="container">
+<div class="container">
{% if show_workshop_stats %}
<div align="right">
<form method="POST" >
- {% csrf_token %}
- <div class="form-group">
- <label for="from">From</label>
- <input type="text" id="from" name="from">
- <label for="to">to</label>
- <input type="text" id="to" name="to">
- <button class="btn btn-warning" type="submit" name="Download" value="Download">Download</button>
- <button class="btn btn-info" type="submit" name="View" value="View">View</button>
- </div>
+ {% csrf_token %}
+ <div class="form-group">
+ <label for="from">From</label>
+ <input type="text" id="from" name="from">
+ <label for="to">to</label>
+ <input type="text" id="to" name="to">
+ <button class="btn btn-warning" type="submit" name="Download" value="Download">Download</button>
+ <button class="btn btn-info" type="submit" name="View" value="View">View</button>
+ </div>
</form>
- {% if messages %}
+ {% if messages %}
<ul class="messages">
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">
@@ -106,7 +105,8 @@
</div>
{% endfor %}
</ul>
- {% endif %}
+ {% endif %}
+
</div>
<br>
<table class="table table-hover">
@@ -177,69 +177,114 @@
{% else %}
<div class="jumbotron">
<h2>Permission to View Upcoming Workshops is set to false, please set it to true in settings.py</h2>
- </div>
+ </div>
{% endif %}
- </div>
+</div>
+
<br>
- <div class="row">
+<div class="row">
+ <br>
+ <div class="col-md-12 ">
<br>
- <div class="col-md-12 ">
- <br>
- <canvas id="myChart" width="300px" height="40px"></canvas>
+ <div class="widget" style="padding-left: 22px;">
+ <fieldset>
+ <label for="radio-1">Number of Workshops per Month</label>
+ <input type="radio" name="radio-1" id="radio-1" value="NWPM">
+ <label for="radio-2">Overall Workshop Count</label>
+ <input type="radio" name="radio-1" id="radio-2" value="OWC">
+ </fieldset>
+ </div>
+ <canvas id="myChartPie" width="90px" height="12px"></canvas>
+
<script>
- var ctx = document.getElementById("myChart").getContext('2d');
- var myChart = new Chart(ctx, {
- type: 'bar',
- data: {
- labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', ' December'],
- datasets: [{
- label: 'Number of workshops per Month for '+ dateToday.getFullYear(),
- data: {{ workshop_count }},
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(255, 206, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- 'rgba(242, 38, 19, 0.2)',
- 'rgba(25, 91, 13, 0.2)',
- 'rgba(54, 12, 235, 0.2)',
- 'rgba(150, 40, 27, 0.2)',
- 'rgba(66, 114, 155, 0.2)',
- 'rgba(219, 10, 91, 0.2)',
- 'rgba(191, 191, 191, 0.2)'
- ],
- borderColor: [
- 'rgba(255, 99, 132, 1)',
- 'rgba(54, 162, 235, 1)',
- 'rgba(255, 206, 86, 1)',
- 'rgba(75, 192, 192, 1)',
- 'rgba(153, 102, 255, 1)',
- 'rgba(242, 38, 19, 1)',
- 'rgba(25, 91, 13, 1)',
- 'rgba(54, 12, 235, 1)',
- 'rgba(150, 40, 27 ,1)',
- 'rgba(66, 114, 155, 1)',
- 'rgba(219, 10, 91, 1)',
- 'rgba(191, 191, 191, 1)'
- ],
- borderWidth: 1
- }]
- },
- options: {
- responsive: true,
- scales: {
- yAxes: [{
- ticks: {
- beginAtZero:true
- }
- }]
+ $( function() {
+ $( "fieldset" ).controlgroup();
+ });
+
+ var ctx1 = document.getElementById("myChartPie").getContext('2d');
+ var myChart;
+ $('input[type=radio]').change(function() {
+ if (this.value == 'NWPM') {//Number of Workshops per month
+ if(myChart){
+ myChart.destroy();
+ }
+ myChart = new Chart(ctx1, {
+ type: 'bar',
+ data: {
+ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', ' December'],
+ datasets: [{
+ label: 'Number of workshops per Month for '+ dateToday.getFullYear(),
+ data: {{ workshop_count }},
+ backgroundColor: [
+ 'rgba(255, 99, 132, 0.2)',
+ 'rgba(54, 162, 235, 0.2)',
+ 'rgba(255, 206, 86, 0.2)',
+ 'rgba(75, 192, 192, 0.2)',
+ 'rgba(153, 102, 255, 0.2)',
+ 'rgba(242, 38, 19, 0.2)',
+ 'rgba(25, 91, 13, 0.2)',
+ 'rgba(54, 12, 235, 0.2)',
+ 'rgba(150, 40, 27, 0.2)',
+ 'rgba(66, 114, 155, 0.2)',
+ 'rgba(219, 10, 91, 0.2)',
+ 'rgba(191, 191, 191, 0.2)'
+ ],
+ borderColor: [
+ 'rgba(255, 99, 132, 1)',
+ 'rgba(54, 162, 235, 1)',
+ 'rgba(255, 206, 86, 1)',
+ 'rgba(75, 192, 192, 1)',
+ 'rgba(153, 102, 255, 1)',
+ 'rgba(242, 38, 19, 1)',
+ 'rgba(25, 91, 13, 1)',
+ 'rgba(54, 12, 235, 1)',
+ 'rgba(150, 40, 27 ,1)',
+ 'rgba(66, 114, 155, 1)',
+ 'rgba(219, 10, 91, 1)',
+ 'rgba(191, 191, 191, 1)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options: {
+ responsive: true,
+ scales: {
+ yAxes: [{
+ ticks: {
+ beginAtZero:true
+ }
+ }]
+ }
+ }
+ });
+ }
+ else if (this.value == 'OWC') { //Overall Workshop Count
+ if(myChart){
+ myChart.destroy();
}
- }
- });
+ myChart = new Chart(ctx1, {
+ type: 'pie',
+ data: {
+ labels : {{ workshoptype_count.0 | safe}},
+ datasets: [{
+ data: {{ workshoptype_count.1 }},
+ //Add more color scheme if workshop number increases
+ backgroundColor: [
+ 'rgba(153, 102, 255, 1)',
+ 'rgba(191, 191, 1, 1)',
+ 'rgba(75, 192, 192, 1)',
+ 'rgba(153, 102, 255, 1)'
+ ]
+ }]
+ },
+ options: {
+ responsive: true
+ }
+ });
+ }
+ });
</script>
- </div>
-
</div>
+</div>
<br>
{% endblock %}
diff --git a/workshop_app/views.py b/workshop_app/views.py
index 8e065f9..d037d3b 100644
--- a/workshop_app/views.py
+++ b/workshop_app/views.py
@@ -28,7 +28,6 @@ from textwrap import dedent
from django.conf import settings
from os import listdir, path, sep
from zipfile import ZipFile
-from django.db.models import Count
from django.contrib import messages
import datetime as dt
import csv
@@ -910,12 +909,39 @@ def workshop_stats(request):
#For Monthly Chart
workshop_count = [0] * 12
for x in range(12):
- workshop_count[x-1] +=RequestedWorkshop.objects.filter(
+ workshop_count[x] +=RequestedWorkshop.objects.filter(
requested_workshop_date__year=str(today.year),
- requested_workshop_date__month=str(x)).count()
- workshop_count[x-1] +=ProposeWorkshopDate.objects.filter(
+ requested_workshop_date__month=str(x+1),
+ status='ACCEPTED').count()
+ workshop_count[x] +=ProposeWorkshopDate.objects.filter(
proposed_workshop_date__year=str(today.year),
- proposed_workshop_date__month=str(x)).count()
+ proposed_workshop_date__month=str(x+1),
+ status='ACCEPTED').count()
+
+ #Count Total Number of workshops for each type
+ workshop_titles = WorkshopType.objects.all()
+ workshoptype_dict = {}
+ for title in workshop_titles:
+ workshoptype_dict[title]=0
+
+ for title in workshoptype_dict.keys():
+ workshoptype_dict[title] += RequestedWorkshop.objects.filter(
+ requested_workshop_title=title,
+ status='ACCEPTED').count()
+ workshoptype_dict[title] += ProposeWorkshopDate.objects.filter(
+ proposed_workshop_title=title,
+ status='ACCEPTED').count()
+ #For Pie Chart
+ workshoptype_num = []
+ workshoptype_title = []
+ for title in workshoptype_dict.keys():
+ workshoptype_title.append(str(title))
+
+ for count in workshoptype_dict.values():
+ workshoptype_num.append(count)
+
+ workshoptype_count = [workshoptype_title, workshoptype_num]
+ del workshoptype_title, workshoptype_num
if request.method == 'POST':
try:
@@ -995,7 +1021,9 @@ def workshop_stats(request):
{
"upcoming_workshops": upcoming_workshops,
"show_workshop_stats": settings.SHOW_WORKSHOP_STATS,
- "workshop_count": workshop_count
+ "workshop_count": workshop_count,
+ "workshoptype_count": workshoptype_count,
+
})
except:
messages.info(request, 'Please enter Valid Dates')
@@ -1045,7 +1073,8 @@ def workshop_stats(request):
{
"upcoming_workshops": upcoming_workshops,
"show_workshop_stats": settings.SHOW_WORKSHOP_STATS,
- "workshop_count": workshop_count
+ "workshop_count": workshop_count,
+ "workshoptype_count": workshoptype_count,
})
else:
redirect('/manage/')