Changeset 9244
- Timestamp:
- Jun 9, 2011, 12:40:00 PM (14 years ago)
- Location:
- src/django_gheat/website
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/django_gheat/website/filters.py ¶
r9225 r9244 2 2 # 3 3 # View serving filter values. 4 #5 # Dennis Wagenaar6 # d.wagenaar@gmail.com7 4 8 5 from django.core.management import setup_environ 9 from django.db.models import Max10 6 from django.http import HttpResponse 11 from django.core import serializers12 7 from gheat.models import * 13 from gheat import gmerc14 import logging15 import pygame16 import sys17 import tempfile18 8 import simplejson 19 9 20 21 # todo: Create one single json file with all relevent info needed for filters. datum - meetrondje - gebruiker 22 def serve_filter(request, ftype): 23 filterlist = '' 24 if (ftype == 'filter_node'): 25 filterlist = get_node() 26 elif (ftype == 'filter_user'): 27 filterlist = get_user() 28 elif (ftype == 'filter_dataset'): 29 filterlist = get_dataset() 30 else: 31 print 'Invalid filter' 32 33 return HttpResponse(filterlist, content_type = 'application/javascript; charset=utf8') 34 35 36 def get_node(): 37 38 nodes = Accespoint.objects.filter(ssid__contains='WirelessLeiden').distinct() 39 nodelist = serializers.serialize('json', nodes, fields=('ssid')) 40 return nodelist 41 42 43 def get_user(): 44 45 users = Gebruiker.objects.all() 46 userlist = serializers.serialize('json', users, fields=('naam')) 47 return userlist 48 49 50 def get_dataset(): 51 52 datasets = MeetRondje.objects.all() 53 datasetlist = serializers.serialize('json', datasets, fields=('naam', 'gebruiker')) 54 return datasetlist 55 56 57 def foo_filter(request): 10 def serve_filters(request): 58 11 """Example json input for dynamic filter using multiple objects example: 59 12 http://lijst.wirelessleiden.nl/pipermail/techniek/2011-May/005516.html""" … … 73 26 { 74 27 'naam' : mr.naam, 75 'dat e' : mr.datum.strftime('%Y-%m-%d'),28 'datum' : mr.datum.strftime('%Y-%m-%d'), 76 29 'nodes' : list(wirelessleiden_ssid) 77 30 } -
TabularUnified src/django_gheat/website/nodelist.py ¶
r9201 r9244 7 7 8 8 from django.core.management import setup_environ 9 from django.db.models import Max10 9 from django.http import HttpResponse 11 10 from django.core import serializers 12 11 from gheat.models import * 13 12 from gheat import gmerc 14 import logging15 import pygame16 import sys17 import tempfile18 13 19 14 def get_bounds(zoom,lat,lon): -
TabularUnified src/django_gheat/website/static/heatmap_extensions.js ¶
r9243 r9244 5 5 content = 'Wireless Leiden nodes on mouseposition:<br /><b>'; 6 6 $.each(json, function(i,json){ 7 content += json.fields.ssid ;7 content += json.fields.ssid + '<br />'; 8 8 }); 9 content += '</b r>';9 content += '</b>'; 10 10 $("#node_list").html(content); 11 11 } … … 17 17 18 18 // Fastest?: http://stackoverflow.com/questions/170986/what-is-the-best-way-to-add-options-to-a-select-from-an-array-with-jquery 19 $.getJSON("/website/f oofilter/",19 $.getJSON("/website/filters/", 20 20 function(json) { 21 21 $.each(json, function(i,json){ -
TabularUnified src/django_gheat/website/urls.py ¶
r9224 r9244 38 38 39 39 urlpatterns += patterns('website.filters', 40 url( 41 regex = r'^filter/(?P<ftype>[a-z_]+)$', 42 view = 'serve_filter', 43 name = 'serve_filter', 44 ), 45 url(r'^foofilter/$', 'foo_filter'), 40 url(r'^filters/$', 'serve_filters'), 46 41 )
Note:
See TracChangeset
for help on using the changeset viewer.