Skip to content

Commit

Permalink
Merge pull request #223 from cliftonmcintosh/meat-and-livestock
Browse files Browse the repository at this point in the history
Thanks, @cliftonmcintosh. Sorry about the delay.
  • Loading branch information
ravinepal authored Dec 2, 2017
2 parents 7bda5c3 + 8477f3b commit 59e0f13
Show file tree
Hide file tree
Showing 8 changed files with 734 additions and 94 deletions.
586 changes: 586 additions & 0 deletions sql/agriculture_livestock.sql

Large diffs are not rendered by default.

82 changes: 3 additions & 79 deletions sql/agriculture_meat.sql

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions wazimap_np/agriculture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from collections import OrderedDict

from wazimap.data.utils import get_stat_data

MEAT_RECODES = OrderedDict([
('BUFF', 'Water Buffalo'),
('CHEVON', 'Goat'),
('CHICKEN', 'Chicken'),
('DUCK', 'Duck'),
('MUTTON', 'Mutton'),
('PORK', 'Pork')
])

LIVESTOCK_RECODES = OrderedDict([
('BUFFALOES', 'Water Buffalo'),
('CATTLE', 'Cattle'),
('DUCKS', 'Ducks'),
('FOWL', 'Fowl'),
('GOATS', 'Goats'),
('PIGS', 'Pigs'),
('SHEEP', 'Sheep')
])


def get_agriculture_profile(geo_code, geo_level, session):
agriculture_data = {'area_has_data': False}

if geo_level != 'vdc':

meat_dist, total_meat = get_stat_data(
'meat type', geo_level, geo_code, session,
recode=dict(MEAT_RECODES),
percent=False,
order_by='-total')

livestock_dist, total_livestock = get_stat_data(
'livestock type', geo_level, geo_code, session,
recode=dict(LIVESTOCK_RECODES),
percent=False,
order_by='-total')

agriculture_data = dict(
is_vdc=False,
area_has_data=True,
meat_distribution=meat_dist,
total_meat={
'name': 'Metric tons of meat produced',
'values': {'this': total_meat}
},
livestock_distribution=livestock_dist,
total_livestock={
'name': 'Number of livestock',
'values': {'this': total_livestock}
},
)

return agriculture_data
16 changes: 11 additions & 5 deletions wazimap_np/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from wazimap.geo import geo_data

from wazimap_np import (
agriculture,
business,
demographics,
development,
Expand All @@ -17,15 +18,16 @@
# ensure tables are loaded

PROFILE_SECTIONS = (
'agriculture',
'business',
'demographics',
'development',
'disasters',
'education',
'elections',
'forests',
'health',
'households',
'education',
'business',
'disasters',
'development'
'households'
)


Expand Down Expand Up @@ -58,6 +60,10 @@ def get_census_profile(geo_code, geo_level, profile_name=None):
return data


def get_agriculture_profile(geo_code, geo_level, session):
return agriculture.get_agriculture_profile(geo_code, geo_level, session)


def get_business_profile(geo_code, geo_level, session):
return business.get_business_profile(geo_code, geo_level, session)

Expand Down
19 changes: 19 additions & 0 deletions wazimap_np/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,25 @@
year='2017',
table_per_level=False)

# agriculture
# meat production
FieldTable(['meat type'],
id='agriculture_meat',
universe='Meat',
description='Meat production',
dataset='Statistical Information on Nepalese Agriculture',
year='2016',
table_per_level=False)

# livestock
FieldTable(['livestock type'],
id='agriculture_livestock',
universe='Livestock',
description='Number of livestock',
dataset='Statistical Information on Nepalese Agriculture',
year='2016',
table_per_level=False)

# Simple Tables
SimpleTable(
id='lifeexpectancy',
Expand Down
19 changes: 10 additions & 9 deletions wazimap_np/templates/profile/profile_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
{% endblock %}

{% block profile_detail %}
{% include 'profile/sections/demographics.html' %}
{% include 'profile/sections/elections.html' %}
{% include 'profile/sections/education.html' %}
{% include 'profile/sections/health.html' %}
{% include 'profile/sections/households.html' %}
{% include 'profile/sections/business.html' %}
{% include 'profile/sections/forests.html' %}
{% include 'profile/sections/disasters.html' %}
{% include 'profile/sections/development.html' %}
{% include 'profile/sections/demographics.html' %}
{% include 'profile/sections/elections.html' %}
{% include 'profile/sections/education.html' %}
{% include 'profile/sections/health.html' %}
{% include 'profile/sections/households.html' %}
{% include 'profile/sections/business.html' %}
{% include 'profile/sections/agriculture.html' %}
{% include 'profile/sections/forests.html' %}
{% include 'profile/sections/disasters.html' %}
{% include 'profile/sections/development.html' %}
{% endblock %}
47 changes: 47 additions & 0 deletions wazimap_np/templates/profile/sections/agriculture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<article id="agriculture" class="clearfix">
{% if agriculture.area_has_data == True %}
<header class="section-contents">
<h1>Agriculture</h1>
</header>
<div class="section-container">
<section class="clearfix stat-row">
<h2><a class="permalink" href="#agriculture-total-livestock"
id="agriculture-total-livestock">Livestock
<i class="fa fa-link"></i></a></h2>
<div class="column-third">
{% include 'profile/_blocks/_stat_list.html' with stat=agriculture.total_livestock stat_type='number' %}
</div>
<div class="column-two-thirds"
id="chart-histogram-agriculture-livestock_distribution"
data-stat-type="number"
data-chart-title="Livestock"></div>
<small>Source: <br>
<a target="_blank"
href="http://moad.gov.np/public/uploads/1142453195-STATISTIC%20AGRICULTURE%20BOOK_2016.pdf">Ministry
of Agricultural Development Statistical Information on
Nepalese Agriculture 2072/73</a> (PDF)
<br>
</small>
</section>
<section class="clearfix stat-row">
<h2><a class="permalink" href="#agriculture-total-meat"
id="agriculture-total-meat">Meat Production
<i class="fa fa-link"></i></a></h2>
<div class="column-third">
{% include 'profile/_blocks/_stat_list.html' with stat=agriculture.total_meat stat_type='number' %}
</div>
<div class="column-two-thirds"
id="chart-histogram-agriculture-meat_distribution"
data-stat-type="number"
data-chart-title="Metric tons of meat produced"></div>
<small>Source: <br>
<a target="_blank"
href="http://moad.gov.np/public/uploads/1142453195-STATISTIC%20AGRICULTURE%20BOOK_2016.pdf">Ministry
of Agricultural Development Statistical Information on
Nepalese Agriculture 2072/73</a> (PDF)
<br>
</small>
</section>
</div>
{% endif %}
</article>
2 changes: 1 addition & 1 deletion wazimap_np/templates/profile/sections/forests.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<article id="elections" class="clearfix">
<article id="forests" class="clearfix">
{% if forests.area_has_data == True %}
<header class="section-contents">
<h1>Forests and Land Use</h1>
Expand Down

0 comments on commit 59e0f13

Please sign in to comment.