front all medias pagination. #26
--- a/.settings/org.eclipse.core.resources.prefs Wed Aug 08 01:43:06 2012 +0200
+++ b/.settings/org.eclipse.core.resources.prefs Wed Aug 08 17:20:37 2012 +0200
@@ -1,3 +1,4 @@
+#Wed Aug 08 16:49:32 CEST 2012
eclipse.preferences.version=1
encoding//src/ldt/ldt/core/migrations/0001_initial.py=utf-8
encoding//src/ldt/ldt/core/migrations/0002_auto__del_owner.py=utf-8
@@ -22,6 +23,7 @@
encoding//src/ldt/ldt/ldt_utils/migrations/0019_recalculate_media_hash_src.py=utf-8
encoding//src/ldt/ldt/ldt_utils/migrations/0020_auto__add_field_segment_id_hash__chg_field_segment_iri_id__chg_field_s.py=utf-8
encoding//src/ldt/ldt/ldt_utils/migrations/0021_recalculate_segment_id_hash_script.py=utf-8
+encoding//src/ldt/ldt/ldt_utils/migrations/0022_auto__add_unique_media_src_hash__chg_field_segment_cutting_id__chg_fie.py=utf-8
encoding//src/ldt/ldt/ldt_utils/views/json.py=utf-8
encoding//src/ldt/ldt/management/utils.py=utf-8
encoding//src/ldt/ldt/test/test_runner.py=utf-8
--- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Wed Aug 08 01:43:06 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Wed Aug 08 17:20:37 2012 +0200
@@ -59,7 +59,37 @@
<span style="font-size:{{t.font_size|add:"12"}}px;">{{t.name}}</span></a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
{% endif %}
</li>
- {% for content in content_list %}
+ <!-- Pagination -->
+ <li id="result_pagination" class="li_h2">
+ <p>
+ {% if results.has_previous %}
+ <a class="blue under" href="{% url ldt.ldt_utils.views.front.all_contents %}?page={{ results.previous_page_number }}{% if tag_label %}&tag={{tag_label}}{% endif %}" title="{% trans 'previous' %}">{% trans "previous" %}</a>
+ {% endif %}
+ {% if results.paginator.num_pages > 1 %}
+ <span class="current">
+ {% for i in results.paginator.num_pages|get_range %}
+ <span class="current">
+ {% if i|add:'1' == results.number %}
+ <span class="pink">{{i|add:'1'}}</span>
+ {% else %}
+ <a class="blue under" href="{% url ldt.ldt_utils.views.front.all_contents %}?page={{i|add:'1'}}{% if tag_label %}&tag={{tag_label}}{% endif %}">{{i|add:'1'}}</a>
+ {% endif %}
+ {% if i|add:'1' < results.paginator.num_pages and 1 < results.paginator.num_pages %}
+ {% endif %}
+ </span>
+ {% endfor %}
+ </span>
+ {% endif %}
+ {% if results.has_next %}
+ <a class="blue under" href="{% url ldt.ldt_utils.views.front.all_contents %}?page={{ results.next_page_number }}{% if tag_label %}&tag={{tag_label}}{% endif %}" title="{% trans 'next' %}">{% trans "next" %}</a>
+ {% endif %}
+ {% if results.paginator.num_pages > 1 %}
+ . <a class="blue under" href="{% url ldt.ldt_utils.views.front.all_contents %}?page=x{% if tag_label %}&tag={{tag_label}}{% endif %}"">({% trans 'All' %})</a>
+ {% endif %}
+ </p>
+ </li>
+ <!-- Fin Pagination -->
+ {% for content in results.object_list %}
<li class="li_media">
<div class="img_and_overlay">
<a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">
--- a/src/ldt/ldt/ldt_utils/views/front.py Wed Aug 08 01:43:06 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/views/front.py Wed Aug 08 17:20:37 2012 +0200
@@ -1,6 +1,7 @@
from django.conf import settings
from django.contrib.auth.models import Group, User
from django.http import HttpResponseRedirect
+from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
from django.template import RequestContext
@@ -54,6 +55,8 @@
def all_contents(request):
+ # Get the page number parameter if possible
+ page = request.GET.get("page") or 1
# Get the tag parameter if possible
tag_label = request.GET.get("tag")
# Get all the public contents group
@@ -61,6 +64,17 @@
content_list = Content.objects.all()
else :
content_list = TaggedItem.objects.get_by_model(Content.objects.all(), '"'+tag_label+'"')
+
+ nb = settings.LDT_FRONT_MEDIA_PER_PAGE
+ if page=="x":
+ nb = content_list.count()
+
+ paginator = Paginator(content_list, nb)
+ try:
+ results = paginator.page(page)
+ except (EmptyPage, InvalidPage):
+ results = paginator.page(paginator.num_pages)
+
# Get the main tag list
front_tags = settings.FRONT_TAG_LIST
# Get the all tags list
@@ -69,7 +83,7 @@
is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
return render_to_response("front/front_all_contents.html",
- {'content_list':content_list, 'tag_label':tag_label, 'front_tags':front_tags, 'tag_cloud':tag_cloud,
+ {'results':results, 'tag_label':tag_label, 'front_tags':front_tags, 'tag_cloud':tag_cloud,
'is_gecko': is_gecko},
context_instance=RequestContext(request))
--- a/src/ldt/ldt/settings.py Wed Aug 08 01:43:06 2012 +0200
+++ b/src/ldt/ldt/settings.py Wed Aug 08 17:20:37 2012 +0200
@@ -85,6 +85,7 @@
LDT_JSON_DEFAULT_INDENT = 2
LDT_MAX_CONTENTS_PER_PAGE = 10
LDT_MAX_PROJECTS_PER_PAGE = 10
+LDT_FRONT_MEDIA_PER_PAGE = 9
AUTO_INDEX_AFTER_SAVE = getattr(settings, 'AUTO_INDEX_AFTER_SAVE', True)
--- a/src/ldt/ldt/static/ldt/css/front_home.css Wed Aug 08 01:43:06 2012 +0200
+++ b/src/ldt/ldt/static/ldt/css/front_home.css Wed Aug 08 17:20:37 2012 +0200
@@ -18,6 +18,11 @@
width: 300px;
}
+#result_pagination{
+ margin: 5px 0;
+ border: 0 none;
+}
+
/* Communs */
.title_ul {
list-style: none;
--- a/web/ldtplatform/config.py.tmpl Wed Aug 08 01:43:06 2012 +0200
+++ b/web/ldtplatform/config.py.tmpl Wed Aug 08 17:20:37 2012 +0200
@@ -89,6 +89,7 @@
LDT_JSON_DEFAULT_INDENT = 0
LDT_MAX_CONTENTS_PER_PAGE = 5
LDT_MAX_PROJECTS_PER_PAGE = 5
+LDT_FRONT_MEDIA_PER_PAGE = 9
EMPTY_MEDIA_EXTERNALID = None
--- a/web/ldtplatform/settings.py Wed Aug 08 01:43:06 2012 +0200
+++ b/web/ldtplatform/settings.py Wed Aug 08 17:20:37 2012 +0200
@@ -185,6 +185,7 @@
LDT_RESULTS_PER_PAGE = 10
LDT_MAX_CONTENTS_PER_PAGE = 10
LDT_MAX_PROJECTS_PER_PAGE = 10
+LDT_FRONT_MEDIA_PER_PAGE = 9
OAUTH_PROVIDER_KEY_SIZE = 32
OAUTH_PROVIDER_SECRET_SIZE = 32