forked from 0x2620/pandora
alternativeNames, bounds
This commit is contained in:
parent
b45a750266
commit
59f7421922
2 changed files with 19 additions and 13 deletions
|
@ -40,6 +40,16 @@ def parseCondition(condition, user):
|
||||||
return q
|
return q
|
||||||
if isinstance(v, bool): #featured and public flag
|
if isinstance(v, bool): #featured and public flag
|
||||||
key = k
|
key = k
|
||||||
|
elif key in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches'):
|
||||||
|
if op == '>':
|
||||||
|
key = '%s__gt'%k
|
||||||
|
elif op == '>=':
|
||||||
|
key = '%s__gte'%k
|
||||||
|
elif op == '<':
|
||||||
|
key = '%s__lt'%k
|
||||||
|
elif op == '<=':
|
||||||
|
key = '%s__lte'%k
|
||||||
|
#default is exact match
|
||||||
else:
|
else:
|
||||||
if op == '=':
|
if op == '=':
|
||||||
key = '%s__iexact'%k
|
key = '%s__iexact'%k
|
||||||
|
|
|
@ -22,7 +22,7 @@ def addPlace(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
name: "",
|
name: "",
|
||||||
aliases: [],
|
alternativeNames: [],
|
||||||
geoname: "",
|
geoname: "",
|
||||||
countryCode: '',
|
countryCode: '',
|
||||||
south: float,
|
south: float,
|
||||||
|
@ -37,14 +37,14 @@ def addPlace(request):
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
exists = False
|
exists = False
|
||||||
names = data.pop('name')
|
names = data.pop('name')
|
||||||
for name in [names] + data.get('aliases', []):
|
for name in [names] + data.get('alternativeNames', []):
|
||||||
if models.Place.objects.filter(name_find__icontains=u'|%s|'%name).count() != 0:
|
if models.Place.objects.filter(name_find__icontains=u'|%s|'%name).count() != 0:
|
||||||
exists = True
|
exists = True
|
||||||
if not exists:
|
if not exists:
|
||||||
place = models.Place()
|
place = models.Place()
|
||||||
place.user = request.user
|
place.user = request.user
|
||||||
place.name = names
|
place.name = names
|
||||||
place.aliases = tuple(data.pop('aliases', []))
|
place.alternativeNames = tuple(data.pop('alternativeNames', []))
|
||||||
for key in data:
|
for key in data:
|
||||||
value = data[key]
|
value = data[key]
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
|
@ -75,7 +75,7 @@ def editPlace(request):
|
||||||
names = [names]
|
names = [names]
|
||||||
if place.editable(request.user):
|
if place.editable(request.user):
|
||||||
conflict = False
|
conflict = False
|
||||||
for name in names + data.get('aliases', []):
|
for name in names + data.get('alternativeNames', []):
|
||||||
if models.Place.objects.filter(name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0:
|
if models.Place.objects.filter(name_find__icontains=u'|%s|'%name).exclude(id=place.id).count() != 0:
|
||||||
conflict = True
|
conflict = True
|
||||||
if 'geoname' in data:
|
if 'geoname' in data:
|
||||||
|
@ -223,15 +223,11 @@ Positions
|
||||||
response['data']['positions'] = utils.get_positions(ids, query['ids'])
|
response['data']['positions'] = utils.get_positions(ids, query['ids'])
|
||||||
else:
|
else:
|
||||||
response['data']['items'] = qs.count()
|
response['data']['items'] = qs.count()
|
||||||
'''
|
response['data']['area'] = qs.aggregate(
|
||||||
r = qs.aggregate(
|
south=Min('south'),
|
||||||
Min('south'),
|
west=Min('west'),
|
||||||
Min('west'),
|
north=Max('north'),
|
||||||
Max('north'),
|
east=Max('east'),
|
||||||
Max('east'),
|
|
||||||
)
|
)
|
||||||
print r
|
|
||||||
'''
|
|
||||||
response['data']['area'] = {'south': -180.0, 'west': -180.0, 'north': 180.0, 'east': 180.0}
|
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(findPlaces)
|
actions.register(findPlaces)
|
||||||
|
|
Loading…
Reference in a new issue