diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-05-26 00:07:19 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-05-26 00:07:19 +0200 |
commit | 2270d2b21c2b928c9a6c90afbd0069bd126656ad (patch) | |
tree | 5fca84c12663d3f78a5493fe061a46afad7e8049 /chimere/forms.py | |
parent | eb49d9126ef91d39f238fe9fa19ee21490d5ef42 (diff) | |
download | Chimère-2270d2b21c2b928c9a6c90afbd0069bd126656ad.tar.bz2 Chimère-2270d2b21c2b928c9a6c90afbd0069bd126656ad.zip |
Property models are now filtered by area in getDetail
Diffstat (limited to 'chimere/forms.py')
-rw-r--r-- | chimere/forms.py | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index 0d866a7..580fb09 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -25,7 +25,7 @@ from django import forms from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import reverse -from django.db.models import Q, Count +from django.db.models import Q from django.forms.formsets import formset_factory from django.utils.translation import ugettext as _ from django.contrib.auth.models import User, Permission, ContentType @@ -273,13 +273,7 @@ class MarkerAdminFormBase(forms.ModelForm): area_name = None if 'area_name' in keys: area_name = keys.pop('area_name') - q = PropertyModel.objects.filter(available=True) - if area_name: - # areas__count__gt=0 necessary to prevent Django bug - q = q.annotate(Count('areas'))\ - .filter( - (Q(areas__urn=area_name) & Q(areas__count__gt=0)) | - Q(areas__count=0)) + q = PropertyModel.getAvailable(area_name=area_name) self.pms = [pm for pm in q.all()] if 'instance' in keys and keys['instance']: instance = keys['instance'] @@ -432,13 +426,7 @@ class RouteAdminForm(forms.ModelForm): area_name = None if 'area_name' in keys: area_name = keys.pop('area_name') - q = PropertyModel.objects.filter(available=True) - if area_name: - # areas__count__gt=0 necessary to prevent Django bug - q = q.annotate(Count('areas'))\ - .filter( - (Q(areas__urn=area_name) & Q(areas__count__gt=0)) | - Q(areas__count=0)) + q = PropertyModel.getAvailable(area_name=area_name) self.pms = [pm for pm in q.all()] if 'instance' in keys and keys['instance']: instance = keys['instance'] |