Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
Better names for checks and statistics about checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jarus committed Mar 10, 2013
1 parent 24a0a3e commit d8e3c15
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
11 changes: 7 additions & 4 deletions krprj/krunite/models.py
Expand Up @@ -10,7 +10,7 @@ class KircheChecks(models.Model):
"""
"""

osm = models.BooleanField("OpenStreetMap place",
osm = models.BooleanField("Place in OpenStreetMap",
default=False)
osm_name = models.BooleanField("OpenStreetMap place is named",
default=False)
Expand All @@ -21,7 +21,8 @@ class KircheChecks(models.Model):
osm_address_complete = models.BooleanField("Full address in "
"OpenStreetMap", default=False)

wikipedia = models.BooleanField("Wikipedia article", default=False)
wikipedia = models.BooleanField("Place has Wikipedia article",
default=False)

wikipedia_infobox = models.BooleanField("Wikipedia article has infobox",
default=False)
Expand Down Expand Up @@ -61,14 +62,16 @@ def percent_reached(self):
def pretty(self):
checks = []
for check in self.available:
field = self._meta.get_field_by_name(check)[0]
checks.append({
'name': check,
'description': field.verbose_name,
'description': self.get_check_description(check),
'value': getattr(self, check)
})
return checks

def get_check_description(self, check):
return self._meta.get_field_by_name(check)[0].verbose_name

def _run(self):
"""Don't run this method directly!
Use KircheUnite.update_checks() instead.
Expand Down
22 changes: 21 additions & 1 deletion krprj/worshipmap/views.py
Expand Up @@ -4,7 +4,7 @@
from django.views.generic.detail import DetailView
from django.db.models import Count, Q

from krprj.krunite.models import KircheUnite
from krprj.krunite.models import KircheUnite, KircheChecks
from krprj.osm.models import KircheOsm, Ref
from krprj.wikipedia.models import KircheWikipedia

Expand Down Expand Up @@ -89,6 +89,26 @@ def get_context_data(self, **kwargs):
.filter(~Q(infobox="{}")) \
.count()

# Checks
context['checks'] = []
for check in KircheChecks().available:
filter = {check: 1}
check = {
'name': check,
'reached': KircheChecks.objects.filter(**filter).count(),
'description': KircheChecks().get_check_description(check)
}
check['pending'] = context['krunite_count'] - check['reached']
check['percent_reached'] = round(
float(check['reached']) / float(context['krunite_count']) \
* 100,
3
)
print check
context['checks'].append(check)

print context['checks']

# date
context['last_7days'] = KircheOsm.objects.filter(
last_update__gt=(
Expand Down

0 comments on commit d8e3c15

Please sign in to comment.