forked from rc/aircox
		
	add cache on on_air
This commit is contained in:
		@ -9,11 +9,13 @@ from django.http import HttpResponse, Http404
 | 
				
			|||||||
from django.shortcuts import render
 | 
					from django.shortcuts import render
 | 
				
			||||||
from django.utils.translation import ugettext as _, ugettext_lazy
 | 
					from django.utils.translation import ugettext as _, ugettext_lazy
 | 
				
			||||||
from django.utils import timezone as tz
 | 
					from django.utils import timezone as tz
 | 
				
			||||||
 | 
					from django.views.decorators.cache import never_cache, cache_page
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import aircox.models as models
 | 
					import aircox.models as models
 | 
				
			||||||
import aircox.settings as settings
 | 
					import aircox.settings as settings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# FIXME usefull?
 | 
				
			||||||
class Stations:
 | 
					class Stations:
 | 
				
			||||||
    stations = models.Station.objects.all()
 | 
					    stations = models.Station.objects.all()
 | 
				
			||||||
    update_timeout = None
 | 
					    update_timeout = None
 | 
				
			||||||
@ -30,6 +32,7 @@ class Stations:
 | 
				
			|||||||
stations = Stations()
 | 
					stations = Stations()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@cache_page(10)
 | 
				
			||||||
def on_air(request):
 | 
					def on_air(request):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        import aircox_cms.models as cms
 | 
					        import aircox_cms.models as cms
 | 
				
			||||||
@ -38,6 +41,7 @@ def on_air(request):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    station = request.GET.get('station');
 | 
					    station = request.GET.get('station');
 | 
				
			||||||
    if station:
 | 
					    if station:
 | 
				
			||||||
 | 
					        # FIXME: by name???
 | 
				
			||||||
        station = stations.stations.filter(name = station)
 | 
					        station = stations.stations.filter(name = station)
 | 
				
			||||||
        if not station.count():
 | 
					        if not station.count():
 | 
				
			||||||
            return HttpResponse('')
 | 
					            return HttpResponse('')
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user