Changeset 9244


Ignore:
Timestamp:
Jun 9, 2011, 12:40:00 PM (14 years ago)
Author:
dennisw
Message:

Renamed foo_filter to serve_filters.
Fixed display of nodes in nodelist.

Location:
src/django_gheat/website
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/django_gheat/website/filters.py

    r9225 r9244  
    22#
    33# View serving filter values.
    4 #
    5 # Dennis Wagenaar
    6 # d.wagenaar@gmail.com
    74
    85from django.core.management import setup_environ
    9 from django.db.models import Max
    106from django.http import HttpResponse
    11 from django.core import serializers
    127from gheat.models import *
    13 from gheat import gmerc
    14 import logging
    15 import pygame
    16 import sys
    17 import tempfile
    188import simplejson
    199
    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):
     10def serve_filters(request):
    5811  """Example json input for dynamic filter using multiple objects example:
    5912  http://lijst.wirelessleiden.nl/pipermail/techniek/2011-May/005516.html"""
     
    7326        {
    7427          'naam' : mr.naam,
    75           'date' : mr.datum.strftime('%Y-%m-%d'),
     28          'datum' : mr.datum.strftime('%Y-%m-%d'),
    7629          'nodes' : list(wirelessleiden_ssid)
    7730        }
  • TabularUnified src/django_gheat/website/nodelist.py

    r9201 r9244  
    77
    88from django.core.management import setup_environ
    9 from django.db.models import Max
    109from django.http import HttpResponse
    1110from django.core import serializers
    1211from gheat.models import *
    1312from gheat import gmerc
    14 import logging
    15 import pygame
    16 import sys
    17 import tempfile
    1813
    1914def get_bounds(zoom,lat,lon):
  • TabularUnified src/django_gheat/website/static/heatmap_extensions.js

    r9243 r9244  
    55      content = 'Wireless Leiden nodes on mouseposition:<br /><b>';
    66      $.each(json, function(i,json){
    7         content += json.fields.ssid;
     7        content += json.fields.ssid + '<br />';
    88      });
    9       content += '</br>';
     9      content += '</b>';
    1010      $("#node_list").html(content);
    1111    }
     
    1717
    1818  // 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/foofilter/",
     19  $.getJSON("/website/filters/",
    2020    function(json) {
    2121      $.each(json, function(i,json){
  • TabularUnified src/django_gheat/website/urls.py

    r9224 r9244  
    3838
    3939urlpatterns += 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'),
    4641  )
Note: See TracChangeset for help on using the changeset viewer.