comparison bandmap/views.py @ 838:f31168465953

Bandmap: make lat/lon editable for tweaking location markers. Don't cache band results in debug mode.
author Brian Neal <bgneal@gmail.com>
date Sat, 04 Oct 2014 16:40:17 -0500
parents 0f9c014c8adc
children 7735f8a6bd1f
comparison
equal deleted inserted replaced
837:234726f5a47a 838:f31168465953
7 from django.shortcuts import redirect, render 7 from django.shortcuts import redirect, render
8 from django.contrib import messages as django_messages 8 from django.contrib import messages as django_messages
9 from django.http import HttpResponse 9 from django.http import HttpResponse
10 from django.template.loader import render_to_string 10 from django.template.loader import render_to_string
11 from django.core.cache import cache 11 from django.core.cache import cache
12 from django.conf import settings
12 13
13 from bandmap.forms import BandForm 14 from bandmap.forms import BandForm
14 from bandmap.models import BandEntry 15 from bandmap.models import BandEntry
15 16
16 17
52 show_param = 'all' 53 show_param = 'all'
53 54
54 # Do we have the results cached already? 55 # Do we have the results cached already?
55 cache_key = 'bandmap-results-{}'.format(show_param) 56 cache_key = 'bandmap-results-{}'.format(show_param)
56 results = cache.get(cache_key) 57 results = cache.get(cache_key)
57 if results: 58 if results and not settings.DEBUG:
58 return HttpResponse(results, content_type='application/json') 59 return HttpResponse(results, content_type='application/json')
59 60
60 # Generate results 61 # Generate results
61 qs = BandEntry.objects.filter(is_approved=True) 62 qs = BandEntry.objects.filter(is_approved=True)
62 if show_param == 'active': 63 if show_param == 'active':