source: src/django_gheat/website/nodelist.py@ 9196

Last change on this file since 9196 was 9196, checked in by dennisw, 14 years ago

Having doubts about the way the query is being serialized.

File size: 1.0 KB
Line 
1#!/usr/bin/env python
2#
3# View serving available WirelessLeiden Nodes in list on mouseover.
4#
5# Dennis Wagenaar
6# d.wagenaar@gmail.com
7
8from django.core.management import setup_environ
9from django.db.models import Max
10from django.http import HttpResponse
11from django.core import serializers
12from gheat.models import *
13import logging
14import pygame
15import sys
16import tempfile
17
18def make_list(zoom,lat,lon):
19
20 maxlat = (lat + 0.01)
21 maxlon = (lon + 0.01)
22 minlat = (lat - 0.01)
23 minlon = (lon - 0.01)
24
25 filter = {}
26 filter.update({
27 'ssid__contains' : 'WirelessLeiden',
28 'meting__latitude__lt' : maxlat,
29 'meting__longitude__lt' : maxlon,
30 'meting__latitude__gt' : minlat,
31 'meting__longitude__gt' : minlon
32 })
33
34 objquery = Accespoint.objects.filter(**filter).distinct()
35 nodelist = serializers.serialize('json', objquery, fields=('fields','ssid'))
36
37 return nodelist
38
39def serve_nodelist(request,zoom,lat,lon,):
40 html = make_list(int(zoom), float(lat), float(lon))
41 return HttpResponse(html, content_type = 'application/javascript; charset=utf8')
42
Note: See TracBrowser for help on using the repository browser.