summaryrefslogtreecommitdiff
path: root/chimere/main/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/main/models.py')
-rw-r--r--chimere/main/models.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/chimere/main/models.py b/chimere/main/models.py
index 5c4151c..4ef4c0d 100644
--- a/chimere/main/models.py
+++ b/chimere/main/models.py
@@ -163,8 +163,12 @@ class SubCategory(models.Model):
subcategories = subcategories.filter(item_type__in=item_types)
if area_name:
area = Area.objects.get(urn=area_name)
+ # if there some restrictions with categories limit them
if area.subcategories.count():
sub_ids = [sub.id for sub in area.subcategories.all()]
+ # if no area is defined for a category don't filter it
+ sub_ids += [sub.id for sub in subcategories
+ if not sub.areas.count()]
subcategories = subcategories.filter(id__in=sub_ids)
for sub_category in subcategories:
if sub_category.category not in sub_categories: