Permalink
Browse files

Better names for checks and statistics about checks

  • Loading branch information...
1 parent 24a0a3e commit d8e3c154f579ccad6a301222d2f8e350352969ad @jarus jarus committed Mar 10, 2013
Showing with 28 additions and 5 deletions.
  1. +7 −4 krprj/krunite/models.py
  2. +21 −1 krprj/worshipmap/views.py
View
@@ -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)
@@ -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)
@@ -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.
View
@@ -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
@@ -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=(

0 comments on commit d8e3c15

Please sign in to comment.