umap/youmap/views.py

26 lines
622 B
Python
Raw Normal View History

2012-11-20 03:47:19 -06:00
from django.views.generic import TemplateView
from chickpea.models import Map
class Home(TemplateView):
template_name = "youmap/home.html"
2012-12-07 06:40:57 -06:00
list_template_name = "chickpea/map_list.html"
2012-11-20 03:47:19 -06:00
def get_context_data(self, **kwargs):
maps = Map.objects.all()[:100]
2012-11-20 03:47:19 -06:00
return {
"maps": maps
}
2012-12-07 06:40:57 -06:00
def get_template_names(self):
"""
Dispatch template according to the kind of request: ajax or normal.
"""
if self.request.is_ajax():
return [self.list_template_name]
else:
return [self.template_name]
2012-11-20 03:47:19 -06:00
home = Home.as_view()