Skip to content
This repository
Browse code

Better names for checks and statistics about checks

  • Loading branch information...
commit d8e3c154f579ccad6a301222d2f8e350352969ad 1 parent 24a0a3e
Christoph Heer authored March 10, 2013
11  krprj/krunite/models.py
@@ -10,7 +10,7 @@ class KircheChecks(models.Model):
10 10
     """
11 11
     """
12 12
 
13  
-    osm = models.BooleanField("OpenStreetMap place",
  13
+    osm = models.BooleanField("Place in OpenStreetMap",
14 14
                               default=False)
15 15
     osm_name = models.BooleanField("OpenStreetMap place is named",
16 16
                                    default=False)
@@ -21,7 +21,8 @@ class KircheChecks(models.Model):
21 21
     osm_address_complete = models.BooleanField("Full address in "
22 22
                                                "OpenStreetMap", default=False)
23 23
 
24  
-    wikipedia = models.BooleanField("Wikipedia article", default=False)
  24
+    wikipedia = models.BooleanField("Place has Wikipedia article",
  25
+                                    default=False)
25 26
 
26 27
     wikipedia_infobox = models.BooleanField("Wikipedia article has infobox",
27 28
                                             default=False)
@@ -61,14 +62,16 @@ def percent_reached(self):
61 62
     def pretty(self):
62 63
         checks = []
63 64
         for check in self.available:
64  
-            field = self._meta.get_field_by_name(check)[0]
65 65
             checks.append({
66 66
                 'name': check,
67  
-                'description': field.verbose_name,
  67
+                'description': self.get_check_description(check),
68 68
                 'value': getattr(self, check)
69 69
             })
70 70
         return checks
71 71
 
  72
+    def get_check_description(self, check):
  73
+        return self._meta.get_field_by_name(check)[0].verbose_name
  74
+
72 75
     def _run(self):
73 76
         """Don't run this method directly!
74 77
         Use KircheUnite.update_checks() instead.
22  krprj/worshipmap/views.py
@@ -4,7 +4,7 @@
4 4
 from django.views.generic.detail import DetailView
5 5
 from django.db.models import Count, Q
6 6
 
7  
-from krprj.krunite.models import KircheUnite
  7
+from krprj.krunite.models import KircheUnite, KircheChecks
8 8
 from krprj.osm.models import KircheOsm, Ref
9 9
 from krprj.wikipedia.models import KircheWikipedia
10 10
 
@@ -89,6 +89,26 @@ def get_context_data(self, **kwargs):
89 89
                                                 .filter(~Q(infobox="{}")) \
90 90
                                                 .count()
91 91
 
  92
+        # Checks
  93
+        context['checks'] = []
  94
+        for check in KircheChecks().available:
  95
+            filter = {check: 1}
  96
+            check = {
  97
+                'name': check,
  98
+                'reached': KircheChecks.objects.filter(**filter).count(),
  99
+                'description': KircheChecks().get_check_description(check)
  100
+            }
  101
+            check['pending'] = context['krunite_count'] - check['reached']
  102
+            check['percent_reached'] = round(
  103
+                float(check['reached']) / float(context['krunite_count']) \
  104
+                * 100,
  105
+                3
  106
+            )
  107
+            print check
  108
+            context['checks'].append(check)
  109
+
  110
+        print context['checks']
  111
+
92 112
         # date
93 113
         context['last_7days'] = KircheOsm.objects.filter(
94 114
             last_update__gt=(

0 notes on commit d8e3c15

Please sign in to comment.
Something went wrong with that request. Please try again.