Add endless_pagination on home page

This commit is contained in:
Yohan Boniface 2012-12-07 13:40:57 +01:00
parent bad2a9db9e
commit cacbbc416f
6 changed files with 34 additions and 8 deletions

View file

@ -7,4 +7,5 @@
django==1.4.2
#south==0.7.6
git+git://github.com/petry/django-foundation.git
git+git://github.com/yohanboniface/django-chickpea.git
git+git://github.com/yohanboniface/django-chickpea.git
git+git://github.com/frankban/django-endless-pagination.git

View file

@ -28,6 +28,7 @@ INSTALLED_APPS = (
# 'youmap.apps.',
'chickpea',
'foundation',
'endless_pagination',
#'south',
@ -102,6 +103,7 @@ TEMPLATE_DIRS = (
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
)
#==============================================================================

View file

@ -37,6 +37,7 @@
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.accordion.js"></script>
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.placeholder.js"></script>
<script src="{{ STATIC_URL }}foundation/javascripts/jquery.foundation.alerts.js"></script>
<script src="{{ STATIC_URL }}endless_pagination/js/endless-pagination.js"></script>
{% block bottom_js %}
<script type="text/javascript">
$(document).foundationAlerts();

View file

@ -0,0 +1,12 @@
{% load chickpea_tags endless %}
{% paginate 5 maps %}
{% for map_inst in maps %}
<div class="twelve mobile-six columns">
{% map_fragment map_inst %}
<div class="panel"><strong>{{ map_inst.name }}</strong> — {{ map_inst.description }} <a href="{{ map_inst.get_absolute_url }}">See this map!</a></div>
</div>
{% endfor %}
{% show_more %}

View file

@ -108,12 +108,7 @@
<div class="row">
<div class="twelve columns">
<div class="row map_list">
{% for map_inst in maps %}
<div class="twelve mobile-six columns">
{% map_fragment map_inst %}
<div class="panel"><strong>{{ map_inst.name }}</strong> — {{ map_inst.description }} <a href="{{ map_inst.get_absolute_url }}">See this map!</a></div>
</div>
{% endfor %}
{% include "chickpea/map_list.html" %}
</div>
</div>
</div>
@ -144,4 +139,9 @@
<!-- End Footer -->
<!-- Included JS Files -->
{% endblock content %}
{% endblock content %}
{% block bottom_js %}
{{ block.super }}
<script>$.endlessPaginate({paginateOnScroll: true});</script>
{% endblock bottom_js %}

View file

@ -5,6 +5,7 @@ from chickpea.models import Map
class Home(TemplateView):
template_name = "youmap/home.html"
list_template_name = "chickpea/map_list.html"
def get_context_data(self, **kwargs):
maps = Map.objects.all()[:20]
@ -12,4 +13,13 @@ class Home(TemplateView):
"maps": maps
}
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]
home = Home.as_view()