Permalink
Browse files

adding chart data

  • Loading branch information...
1 parent af00d44 commit 393612f17d272a12b232e95223b720da16e7c2fe @chriscasey committed Mar 24, 2012
View
4 README
@@ -1 +1,5 @@
#READ ME FOR REBOOT OUR SCHOOLS
+
+INSTALLS:
+pip install django_chartit
+sudo easy_install -U GChartWrapper
@@ -39,7 +39,7 @@ class SchoolAdmin(admin.ModelAdmin):
list_display = ('full_name', 'school_code', 'district')
list_filter = ['district',]
search_fields = ['full_name', 'school_code']
-# inlines = [ComputersInline, TabletsInline]
+ inlines = [ComputersInline]
class DistrictAdmin(admin.ModelAdmin):
fieldsets = [
@@ -48,7 +48,7 @@ class DistrictAdmin(admin.ModelAdmin):
list_display = ('full_name', 'district_code', 'city', 'state', 'county')
list_filter = ['district_code']
search_fields = ['full_name', 'district_code', 'city', 'state', 'county']
- inlines = [SchoolsInline]
+ inlines = [SchoolsInline]
admin.site.register(School, SchoolAdmin)
@@ -7,6 +7,7 @@
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
+ <script src="/static/highcharts/highcharts.js"></script>
</head>
<body>
<header>
@@ -1,7 +1,20 @@
{% extends "base.html" %}
+<head>
+ {% load chartit %}
+ {{ sampleChart|load_charts:"container" }}
+</head>
+
+
+
{% block content %}
-User : {{ user.username }}<br />
-District : {{ userDistrict.full_name }}<br />
-District Assets : {{ districtAssets.count }}<br />
+
+<h1>{% block title %}{{ userDistrict.full_name }} ({{ userDistrict.district_code }}){% endblock %}</h1>
+<h3>{{ userDistrict.city }}, {{ userDistrict.state }}</h3><br/>
+<h4>{{ schoolCount }} schools in this district
+<hr/>
+
+<div id='container'></div>
+
+
{% endblock %}
@@ -1,5 +1,6 @@
{% extends "base.html" %}
+
{% block content %}
<h2>{{ school }}</h2>
<h3>Total Computers: {{ computerCount }}</h3>
@@ -30,6 +31,10 @@ <h4>{{ osxCount }} Mac | {{ linuxCount }} Linux | {{ windowsCount }} Windows</h4
</tbody>
</table>
+<img src="{{ osChart }}">
+<img src="{{ hdChart }}">
+<img src="{{ ramChart }}">
+
<div class="modal hide fade" id="addComputerForm">
<div class="modal-header">
<a href="#" id="close" class="close">&times;</a>
@@ -4,6 +4,7 @@
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
+from GChartWrapper import *
from technologytracker.models import *
@@ -67,13 +68,51 @@ def schoolDetail(request, school_id):
form = ComputerForm() # An unbound form
+ ##os chart
+ osxCount = Computer.objects.filter(school=school, os='OSX').count()
+ linuxCount = Computer.objects.filter(school=school, os='LINUX').count()
+ windowsCount = Computer.objects.filter(school=school, os='WINDOWS').count()
+
+ osDataset = [osxCount, linuxCount, windowsCount]
+ osChart = Pie3D( osDataset )
+ osChart.label('OS X','LINUX','WINDOWS')
+ osChart.color('4d89f9','c6d9fd')
+ osChart.title('Operating Systems')
+
+ ##hd chart
+ smallHd = Computer.objects.filter(school=school, hd_size='60').count()
+ mediumHd = Computer.objects.filter(school=school, hd_size='128').count()
+ largeHd = Computer.objects.filter(school=school, hd_size='250').count()
+
+ hdDataset = [smallHd, mediumHd, largeHd]
+ hdChart = Pie3D( hdDataset )
+ hdChart.label('60 GB','128 GB','250GB')
+ hdChart.color('4d89f9','c6d9fd')
+ hdChart.title('Memory (Hard Drives)')
+
+ ##ram chart
+ oneGb = Computer.objects.filter(school=school, ram='1').count()
+ twoGb = Computer.objects.filter(school=school, ram='2').count()
+ fourGb = Computer.objects.filter(school=school, ram='4').count()
+ eightGb = Computer.objects.filter(school=school, ram='8').count()
+
+ ramDataset = [oneGb, twoGb, fourGb, eightGb]
+ ramChart = Pie3D( ramDataset )
+ ramChart.label('1 GB','2 GB','4 GB', '8 GB')
+ ramChart.color('4d89f9','c6d9fd')
+ ramChart.title('Memory (RAM)')
+
return render_to_response('schoolDetail.html', {'school':school,
'computers':computers,
'computerCount':computerCount,
'osxCount':osxCount,
'linuxCount':linuxCount,
'windowsCount':windowsCount,
- 'form':form})
+ 'form':form,
+ 'osChart':osChart,
+ 'hdChart':hdChart,
+ 'ramChart':ramChart,
+ })
except School.DoesNotExist:
return HttpResponseNotFound('School not found')
@@ -84,7 +123,21 @@ def districtReporting(request):
districtUserProfile = DistrictUserProfile.objects.filter(user=request.user)
userDistrict = District.objects.get(pk=districtUserProfile)
districtAssets = userDistrict.districtasset_set
- return render_to_response('districtReporting.html', {'userDistrict': userDistrict, 'districtAssets': districtAssets})
+
+ ###retrieve the district that the current user is assigned to
+ districtUserProfile = DistrictUserProfile.objects.filter(user=request.user)
+ userDistrict = District.objects.get(pk=districtUserProfile)
+
+ ###retrieve all of the schools in the user's district
+ schools = School.objects.filter(district=userDistrict)
+ schoolCount = School.objects.filter(district=userDistrict).count()
+
+ return render_to_response('districtReporting.html', {
+ 'userDistrict': userDistrict,
+ 'districtAssets': districtAssets,
+ 'schools': schools,
+ 'schoolCount': schoolCount,
+ })
@login_required(login_url='/login/')
def districts(request):

0 comments on commit 393612f

Please sign in to comment.