Skip to content

Commit afcf1be

Browse files
Merge pull request #109 from CodeForAfrica/feature/upgrade_all_apps
Release v0.1.0
2 parents 637e301 + 835764f commit afcf1be

File tree

109 files changed

+49288
-69991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+49288
-69991
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2019-01-15
9+
10+
### Added
11+
- Update all apps to use data sets & releases
12+
- Improve Docker support
13+
- Added HURUmap-land app
14+
- Added Afrobarometer Round 7 survey for Uganda and Zambia
15+
- Added CHANGELOG
16+
17+
### Changed
18+
- Hide Empty sections on the profile page

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM codeforafrica/hurumap:0.0.12
1+
FROM codeforafrica/hurumap:0.1.1
22

33
# Set env variables used in this Dockerfile
44
# HURUmap App and Django settings

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ compilescss:
1616
dumpdata:
1717
$(COMPOSE) exec web python manage.py dumpdata wazimap hurumap ${HURUMAP_APP} -o ${HURUMAP_APP}/fixtures/${HURUMAP_APP}.json
1818

19+
migrate:
20+
$(COMPOSE) exec web python manage.py migrate
21+
1922
makemigrations:
2023
$(COMPOSE) exec web python manage.py makemigrations
2124

2225
createdb:
2326
$(COMPOSE) exec db createdb ${HURUMAP_APP}
2427

28+
dropdb:
29+
$(COMPOSE) exec db dropdb ${HURUMAP_APP}
30+
2531
loaddata:
2632
$(COMPOSE) exec -T web ./contrib/loaddata.sh # Load the DB with data
2733

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ cat $HURUMAP_APP/sql/*.sql | docker-compose exec -T db psql $HURUMAP_APP
3333
cat $HURUMAP_APP/sql/*.sql | docker-compose exec -T -e PGPASSWORD=<pass> db psql -h <db.host.com> -U <user> $HURUMAP_APP
3434
```
3535

36+
#### `elimu_yangu` `.sql` files
37+
38+
`olevel_student_performance.sql` has been split into 2 files by year because as a single
39+
file, it surpasses the maximum file size allowed by Github
40+
3641
### Import Data into HURUmap
3742

3843
TODO: Needs to use docker-compose, test, and QA

contrib/loaddata.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
if [ -z ${HURUMAP_APP+x} ]; then HURUMAP_APP='hurumap_land'; fi
44

55
cat ${HURUMAP_APP}/sql/*.sql | psql # Load tables / data into DB (TBD)
6-
python manage.py loaddata ${HURUMAP_APP}.json # Load fixtures
6+
python manage.py loaddata ${HURUMAP_APP}/fixtures/${HURUMAP_APP}.json # Load fixtures
7+

elimu_yangu/fixtures/elimu_yangu.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

elimu_yangu/leaguetable/tables.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# Define our tables so the data API can discover them.
44
# TODO: Add comments so that we can quickly see categories/topics
55
# TODO: Rework format to a standard
6-
FieldTable(['code', 'name', 'region', 'district', 'ward', 'ownership', 'latitude', 'longitude',
7-
'pass_rate', 'change_previous_year_pass_rate', 'avg_gpa', 'chane_previous_year_gpa', 'rank',
8-
'year_of_result', 'more_than_40', 'national_rank_all', 'regional_rank_all',
9-
'district_rank_all'], id='secondary_schools')
6+
# FieldTable(['code', 'name', 'region', 'district', 'ward', 'ownership', 'latitude', 'longitude',
7+
# 'pass_rate', 'change_previous_year_pass_rate', 'avg_gpa', 'chane_previous_year_gpa', 'rank',
8+
# 'year_of_result', 'more_than_40', 'national_rank_all', 'regional_rank_all',
9+
# 'district_rank_all'], id='secondary_school', dataset="School's League", year='2017')
1010

1111

1212
FieldTable(['code', 'name', 'region', 'district', 'ward', 'ownership', 'gender', 'latitude', 'longitude',
13-
'avg_gpa', 'year_of_result', 'more_than_40', 'national_rank_all', 'regional_rank_all'], id='secondary_school')
13+
'avg_gpa', 'year_of_result', 'more_than_40', 'national_rank_all', 'regional_rank_all'], id='secondary_school', dataset="School's League", year='2017')

elimu_yangu/leaguetable/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
regex = r'^profiles/(?P<geography_id>\w+-\w+)(-(?P<slug>[\w-]+))?/$',
2323
view = cache_page(STANDARD_CACHE_TIME)(GeographyDetailView.as_view()),
2424
kwargs = {},
25-
name = 'geography_detail',
25+
name = 'league_table_geography_detail',
2626
),
2727

2828
# url for specific school page

elimu_yangu/leaguetable/views.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
from django.utils import translation
44

5-
from django.http import HttpResponse
5+
from django.http import HttpResponse, Http404
66
from django.shortcuts import render_to_response, render, redirect
77
from django.utils.module_loading import import_string
88
from django.utils.safestring import SafeString
@@ -11,11 +11,9 @@
1111
from django.conf import settings
1212

1313
from wazimap.geo import geo_data
14-
from wazimap.data.tables import get_model_from_fields, get_model_for_db_table
1514
from wazimap.profiles import enhance_api_data
1615
from wazimap.data.base import Base
17-
from wazimap.data.utils import (LocationNotFound, calculate_median, get_session, get_stat_data,
18-
merge_dicts, get_objects_by_geo, group_remainder)
16+
from wazimap.data.utils import (get_session)
1917

2018
from sqlalchemy import Column, ForeignKey, Integer, String, Table, func, or_, and_, desc, asc, cast
2119

@@ -104,7 +102,7 @@ def get_context_data(self, *args, **kwargs):
104102
self.geo_code = school.geo_code
105103
version = '2009'
106104
self.geo = geo_data.get_geography(self.geo_code, self.geo_level, version)
107-
except (ValueError, LocationNotFound):
105+
except (ValueError, Exception):
108106
raise Http404
109107
# load the profile
110108
# profile_method = settings.WAZIMAP.get('profile_builder', None)
@@ -157,7 +155,7 @@ def dispatch(self, *args, **kwargs):
157155
try:
158156
self.geo_level, self.geo_code = self.geo_id.split('-', 1)
159157
self.geo = geo_data.get_geography(self.geo_code, self.geo_level, version)
160-
except (ValueError, LocationNotFound):
158+
except (ValueError, Exception):
161159
raise Http404
162160

163161
# check slug
@@ -215,8 +213,6 @@ def get_template_names(self):
215213
return ['leaguetable/profile/profile_detail_%s.html' % self.profile_name, 'leaguetable/embed_map.html']
216214

217215

218-
219-
220216
class GeographyDetailView(BaseGeographyDetailView):
221217
adjust_slugs = True
222218
default_geo_version = None
@@ -230,7 +226,7 @@ def dispatch(self, *args, **kwargs):
230226
try:
231227
self.geo_level, self.geo_code = self.geo_id.split('-', 1)
232228
self.geo = geo_data.get_geography(self.geo_code, self.geo_level, version)
233-
except (ValueError, LocationNotFound):
229+
except (ValueError, Exception):
234230
raise Http404
235231

236232
# check slug
@@ -300,14 +296,16 @@ def get_context_data(self, geo_id1, geo_id2):
300296

301297
level, code = geo_id2.split('-', 1)
302298
page_context['geo2'] = geo_data.get_geography(code, level)
303-
except (ValueError, LocationNotFound):
299+
except (ValueError, Exception):
304300
raise Http404
305301

306302
return page_context
307303

308304
def get_overall_topschools(year, geo_level, geo_code, session):
309305
schools = {}
310306
# Choosing sorting option
307+
308+
Base.metadata.reflect()
311309
rank_column = Base.metadata.tables['secondary_school'].c.national_rank_all
312310
# Fetching schools
313311
top_schools_40_more = session.query(Base.metadata.tables['secondary_school'])\

0 commit comments

Comments
 (0)