Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made DMO Dash Cleaner #779

Merged
merged 3 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions mainapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,31 +384,21 @@ def ifnonezero(val):
return val

def dmoinfo(request):
if("district" not in request.GET.keys()):return render(request ,"dmoinfo.html" )
dist = request.GET.get("district")
reqserve = Request.objects.all().filter(status = "sup" , district = dist).count()
reqtotal = Request.objects.all().filter(district = dist).count()
volcount = Volunteer.objects.all().filter(district = dist).count()
conserve = Contributor.objects.all().filter(status = "ful" , district = dist).count()
contotal = Contributor.objects.all().filter(district = dist).count()

camps = RescueCamp.objects.all().filter(district = dist)

total_people = 0 ;total_male = 0 ; total_female = 0 ; total_infant = 0 ; total_medical = 0
distmapper = {}
data = []
for i in districts:
distmapper[i[0]] = i[1]
for i in camps:

total_people += ifnonezero(i.total_people)
total_male += ifnonezero(i.total_males)
total_female += ifnonezero(i.total_females)
total_infant += ifnonezero(i.total_infants)
if(i.medical_req.strip() != ""):total_medical+=1

return render(request ,"dmoinfo.html",{"district" : distmapper[dist] , "reqserve" : reqserve , "reqtotal" : reqtotal , "volcount" : volcount , "conserve" : conserve , "contotal" : contotal ,
"total_camps" : camps.count() ,"total_people" : total_people , "total_male" : total_male , "total_female" : total_female , "total_infant" : total_infant , "total_medical" : total_medical })

req = 0 ; reqo = 0 ; reqd = 0 ; con = 0 ; cons = 0 ; vol = 0
reqquery = Request.objects.all().filter(district = i[0])
req = reqquery.count()
reqo = reqquery.filter( status = "pro" ).count()
reqd = reqquery.filter(status = "sup").count()
contquery = Contributor.objects.all().filter(district = i[0])
con = contquery.count()
cons =contquery.filter(status = "ful").count()
vol = Volunteer.objects.all().filter(district = i[0]).count()

data.append({ "district" : i[1], "req" : req , "reqo" : reqo , "reqd" : reqd , "con" : con , "cons" : cons , "vol" : vol})
return render(request ,"dmoinfo.html",{"data" : data} )
def error(request):
error_text = request.GET.get('error_text')
return render(request , "mainapp/error.html", {"error_text" : error_text})
Expand Down
84 changes: 52 additions & 32 deletions templates/dmodash.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,35 @@

{% load bootstrap3 %}

<div class="container text-center">
<h1 class="main-logo">kerala<span style="font-weight: normal;">rescue DMO Portal</span></h1>
<p style="margin-bottom:20px;margin-top:50px;">
<strong style="font-size: 40px ;">Please Select the Camps to view statistics </strong><br/>
</p>
<a href="/dmodist" class="home-button card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
View stats By district </span>
</a>
<a href="/dmotal" class="home-button card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
Views Stats By Taluk
</span>
</a>
<style>

a.new{
pointer-events: none;

padding: 0px !important;
margin: 0px !important;
border: 0px solid #333333;
color: #333333;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
text-decoration: none;
width: 150px;
height: 230px;
vertical-align: top;
display: inline-flex;
justify-content: center;
flex-direction: column;
}</style>

<div class="container text-center">

<p style="margin-bottom:20px;margin-top:50px;">
<strong style="font-size: 40px ;">Please Select the district to view request stats </strong><br/>
</p>

<a href="/dmoinfo" class="home-button card" role="button">
{% bootstrap_icon "search" %}
<span class="text">
Views Stats By District
</span>
</a>

<p style="margin-bottom:20px;margin-top:50px;">
<strong style="font-size: 40px ;">Overall Stats </strong><br/>
</p>

<a href="#" class="home-button card" role="button">
<a href="#" class="home-button new card" role="button">
{% bootstrap_icon "bed" %}
<span class="text">
{{camp}}<br>
Expand All @@ -46,39 +41,39 @@ <h1 class="main-logo">kerala<span style="font-weight: normal;">rescue DMO Porta
</span>
</a>

<a href="#" class="home-button card" role="button">
<a href="#" class="home-button new card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
{{people}}<br>
<span class="ml notranslate">People</span>

</span>
</a>
<a href="#" class="home-button card" role="button">
<a href="#" class="home-button new card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
{{male}}<br>
<span class="ml notranslate">Male</span>

</span>
</a>
<a href="#" class="home-button card" role="button">
<a href="#" class="home-button new card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
{{female}}<br>
<span class="ml notranslate">Female</span>

</span>
</a>
<a href="#" class="home-button card" role="button">
<a href="" class="home-button new card" role="button">
{% bootstrap_icon "baby-formula" %}
<span class="text">
{{infant}}<br>
<span class="ml notranslate">Infants</span>

</span>
</a>
<a href="#" class="home-button card" role="button">
<a href="" class="home-button new card" role="button">
{% bootstrap_icon "grain" %}
<span class="text">
{{medicine}}<br>
Expand All @@ -88,6 +83,31 @@ <h1 class="main-logo">kerala<span style="font-weight: normal;">rescue DMO Porta
</a>


<p style="margin-bottom:20px;margin-top:50px;">
</p>
<a href="/dmodist" class="home-button card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
View stats By district </span>
</a>
<a href="/dmotal" class="home-button card" role="button">
{% bootstrap_icon "user" %}
<span class="text">
Views Stats By Taluk
</span>
</a>



<a href="/dmoinfo" class="home-button card" role="button">
{% bootstrap_icon "search" %}
<span class="text">
Public data insights
</span>
</a>



</div>

{% endblock %}
2 changes: 1 addition & 1 deletion templates/dmodist.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="container text-center">
<h1 class="main-logo">kerala<span style="font-weight: normal;">rescue DMO Portal</span></h1>
<p style="margin-top:60px; margin-bottom: 30px">
<i style="font-size: 40px ;"> Request Stats per District </i><br/>
<strong style="font-size: 40px ;"> Camp Stats per District </strong><br/>
</p>

<div id="requests-table" class="table-responsive">
Expand Down
118 changes: 31 additions & 87 deletions templates/dmoinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,97 +7,41 @@
<div class="container text-center">
<h1 class="main-logo">kerala<span style="font-weight: normal;">rescue DMO Portal</span></h1>
<p style="margin-top:60px; margin-bottom: 30px">
<strong style="font-size: 40px ;"> Request Stats for your District </strong><br/>
<strong style="font-size: 40px ;"> Camp Stats per District </strong><br/>
</p>

<form method="get" action="/dmoinfo" class="simple-form">
<div class="form-group"><label class="control-label" for="id_district">Districts - ജില്ല</label><select name="district" class="form-control" title="" required id="id_district">
<option value="" selected>---------</option>
<div id="requests-table" class="table-responsive">
<table id="req-table" class="table">
<thead>
<tr>
<th>District - ജില്ല</th>
<th>Total Requests</th>
<th>Requests Completed</th>
<th>Requests Ongoing</th>
<th>Total Contributions</th>
<th>Contributions Server</th>
<th>Total Volunteers</th>

</tr>
</thead>
<tbody>
{% for d in data %}
<tr>
<td>{{ d.district }}</td>
<td>{{ d.req }}</td>
<td>{{ d.reqd }}</td>
<td>{{ d.reqo }}</td>
<td>{{ d.con }}</td>
<td>{{ d.cons }}</td>
<td>{{ d.vol }}</td>

</tr>
{% endfor %}
</tbody>
</table>
</div>

<option value="tvm">Thiruvananthapuram - തിരുവനന്തപുര</option>

<option value="ptm">Pathanamthitta - പത്തനംതിട</option>

<option value="alp">Alappuzha - ആലപ്പുഴ</option>

<option value="ktm">Kottayam - കോട്ടയം</option>

<option value="idk">Idukki - ഇടുക്കി</option>

<option value="mpm">Malappuram - മലപ്പുറം</option>

<option value="koz">Kozhikode - കോഴിക്കോട</option>

<option value="wnd">Wayanad - വയനാട്</option>

<option value="knr">Kannur - കണ്ണൂർ</option>

<option value="ksr">Kasaragod - കാസർഗോഡ്</option>

<option value="pkd">Palakkad - പാലക്കാട്</option>

<option value="tcr">Thrissur - തൃശ്ശൂർ</option>

<option value="ekm">Ernakulam - എറണാകുളം</option>

<option value="kol">Kollam - കൊല്ലം</option>



</select>
<br>
<input type="submit" class="btn btn-primary">

<br>
</form>
<div style="padding : 50px">
<strong style="font-size: 40px ; margin-top: 50px"> {{district}} </strong>
</div>
<div class="row">
<div class="col-xs-4" style="font-size: 30px">
Volunteers
<br> {{volcount}}
<br>Registered</div>
<div class="col-xs-4" style="font-size: 30px">
Contributors<br>
{{conserve}} Served
<br>
from {{contotal}}</div>
<div class="col-xs-4" style="font-size: 30px">
Requests<br>
{{reqserve}} Served
<br>
from {{reqtotal}}</div>

</div>

<br>
<br>
<strong style="font-size: 40px ;" > Camp Stats for your District </strong> <br> <a href="/dmocsv?district={{district}}" > Download as csv</a>

<div class="container" style="font-size: 30px ; padding-top: 30px">


Total Camps
{{total_camps}}
<br>
Total People
{{total_people}}
<br>
Total Male
{{total_male}}
<br>
Total Female
{{total_female}}
<br>
Total Infants
{{total_infant}}
<br>
Camps with Med Requirements
{{total_medical}}

</div>
</div>
</div>

{% endblock %}