Permalink
Browse files

fixed Site.maps

  • Loading branch information...
1 parent aed66a1 commit 4e1122cf5cd505543a0490568b5bdb65146caa1d @evildmp committed Jan 2, 2013
Showing with 35 additions and 2 deletions.
  1. +1 −2 contacts_and_people/models.py
  2. +34 −0 contacts_and_people/tests.py
@@ -47,8 +47,7 @@ def __unicode__(self):
@property
def maps(self):
- # return self.building_set.filter(has_map = True)
- return [building for building in self.building_set.all() if building.has_map]
+ return [building for building in self.place.all() if building.has_map]
class BuildingManager(models.Manager):
def get_by_natural_key(self, slug):
@@ -2,6 +2,40 @@
from contacts_and_people.models import Site, Person, Building, Entity, Membership
+class SiteTests(TestCase):
+ def setUp(self):
+ # a geographical Site
+ self.cardiff = Site(
+ site_name="Main site",
+ post_town="Cardiff",
+ country="UK",
+ )
+ self.cardiff.save()
+
+ def test_maps(self):
+ """
+ test Site.maps property
+ """
+ # no Buildings on this site, should be an empty list
+ self.assertEquals(self.cardiff.maps, [])
+
+ # add a Building
+ self.main_building = Building(
+ name="Main Building",
+ street="St Mary's Street",
+ site=self.cardiff,
+ )
+ self.main_building.save()
+ self.assertEquals(self.cardiff.maps, [])
+
+ # give the building a map
+ self.main_building.map = True
+ self.main_building.latitude = 10
+ self.main_building.longitude = 10
+ self.main_building.zoom = 10
+ self.main_building.save()
+ self.assertEquals(self.cardiff.maps, [self.main_building])
+
class EntityManagerTests(TestCase):
def setUp(self):
pass

0 comments on commit 4e1122c

Please sign in to comment.