summaryrefslogtreecommitdiff
path: root/chimere/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-03-10 17:29:26 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-03-10 17:29:26 +0100
commitb0c9592c77a964b1177451894195090389305633 (patch)
tree8683b328f6aa6ade7af92b9feed728cad645a686 /chimere/models.py
parente6e4991cf36c62b12e9efa935bf22e4739eea04e (diff)
downloadChimère-b0c9592c77a964b1177451894195090389305633.tar.bz2
Chimère-b0c9592c77a964b1177451894195090389305633.zip
Admin: area filter take into account categories limitation
Diffstat (limited to 'chimere/models.py')
-rw-r--r--chimere/models.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/chimere/models.py b/chimere/models.py
index c1b47d3..d00d0b6 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -2057,19 +2057,28 @@ class Area(models.Model, SimpleArea):
"""
Get the sql statement for the test if the point is included in the area
"""
- return Q(point__contained=self.getWkt())
+ q = Q(point__contained=self.getWkt())
+ if self.subcategories.count():
+ q = q & Q(categories__in=self.subcategories.all())
+ return q
def getIncludeRoute(self):
"""
Get the sql statement for the test if the route is included in the area
"""
- return Q(route__contained=self.getWkt())
+ q = Q(route__contained=self.getWkt())
+ if self.subcategories.count():
+ q = q & Q(categories__in=self.subcategories.all())
+ return q
def getIncludePolygon(self):
"""
Get the sql statement for the test if the route is included in the area
"""
- return Q(polygon__contained=self.getWkt())
+ q = Q(polygon__contained=self.getWkt())
+ if self.subcategories.count():
+ q = q & Q(categories__in=self.subcategories.all())
+ return q
pre_save_area_values = {}