# coding=utf-8
from annoying.decorators import ajax_request

from django.views.decorators.csrf import csrf_exempt

from .models import City, CityHouse

__author__ = 'alexy'


@csrf_exempt
@ajax_request
def city_map(request):
    city_id = request.POST.get('city_id') or None
    city_list = []
    house_list = []
    if city_id:
        for i in CityHouse.objects.filter(city=int(city_id)):
            house_list.append({
                'address': i.address,
                'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y),
                'image': i.image.url
            })
    else:
        for i in City.objects.all():
            city_list.append({
                'name': i.name,
                'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y),
                'count': i.cityhouse_set.count(),
                'city_url': i.get_absolute_url()
            })
    return {
        'house_list': house_list,
        'city_list': city_list
    }

fd627e6d9186902be3c8784c226a11bffe8a38ea
<mask token>

<mask token>


@csrf_exempt
@ajax_request
def city_map(request):
    city_id = request.POST.get('city_id') or None
    city_list = []
    house_list = []
    if city_id:
        for i in CityHouse.objects.filter(city=int(city_id)):
            house_list.append({'address': i.address, 'coord_x': float(i.
                coord_x), 'coord_y': float(i.coord_y), 'image': i.image.url})
    else:
        for i in City.objects.all():
            city_list.append({'name': i.name, 'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y), 'count': i.cityhouse_set.count
                (), 'city_url': i.get_absolute_url()})
    return {'house_list': house_list, 'city_list': city_list}

<mask token>
__author__ = 'alexy'


@csrf_exempt
@ajax_request
def city_map(request):
    city_id = request.POST.get('city_id') or None
    city_list = []
    house_list = []
    if city_id:
        for i in CityHouse.objects.filter(city=int(city_id)):
            house_list.append({'address': i.address, 'coord_x': float(i.
                coord_x), 'coord_y': float(i.coord_y), 'image': i.image.url})
    else:
        for i in City.objects.all():
            city_list.append({'name': i.name, 'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y), 'count': i.cityhouse_set.count
                (), 'city_url': i.get_absolute_url()})
    return {'house_list': house_list, 'city_list': city_list}

from annoying.decorators import ajax_request
from django.views.decorators.csrf import csrf_exempt
from .models import City, CityHouse
__author__ = 'alexy'


@csrf_exempt
@ajax_request
def city_map(request):
    city_id = request.POST.get('city_id') or None
    city_list = []
    house_list = []
    if city_id:
        for i in CityHouse.objects.filter(city=int(city_id)):
            house_list.append({'address': i.address, 'coord_x': float(i.
                coord_x), 'coord_y': float(i.coord_y), 'image': i.image.url})
    else:
        for i in City.objects.all():
            city_list.append({'name': i.name, 'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y), 'count': i.cityhouse_set.count
                (), 'city_url': i.get_absolute_url()})
    return {'house_list': house_list, 'city_list': city_list}

# coding=utf-8
from annoying.decorators import ajax_request

from django.views.decorators.csrf import csrf_exempt

from .models import City, CityHouse

__author__ = 'alexy'


@csrf_exempt
@ajax_request
def city_map(request):
    city_id = request.POST.get('city_id') or None
    city_list = []
    house_list = []
    if city_id:
        for i in CityHouse.objects.filter(city=int(city_id)):
            house_list.append({
                'address': i.address,
                'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y),
                'image': i.image.url
            })
    else:
        for i in City.objects.all():
            city_list.append({
                'name': i.name,
                'coord_x': float(i.coord_x),
                'coord_y': float(i.coord_y),
                'count': i.cityhouse_set.count(),
                'city_url': i.get_absolute_url()
            })
    return {
        'house_list': house_list,
        'city_list': city_list
    }
