--- a/.settings/org.eclipse.core.resources.prefs Sat Aug 11 01:25:05 2012 +0200
+++ b/.settings/org.eclipse.core.resources.prefs Sat Aug 11 01:27:51 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/api/ldt/handlers.py Sat Aug 11 01:25:05 2012 +0200
+++ b/src/ldt/ldt/api/ldt/handlers.py Sat Aug 11 01:27:51 2012 +0200
@@ -231,7 +231,7 @@
class ContentHandler(BaseHandler):
- allowed_methods = ('GET', )
+ allowed_methods = ('GET', 'PUT')
model = Content
exclude = (
("media_obj"),
@@ -241,7 +241,23 @@
"""
returns a single content
"""
- return Content.objects.get(iri_id=iri_id)
+ return Content.objects.get(iri_id=iri_id)
+
+ @require_extended
+ def update(self, request, iri_id):
+ """
+ Receives a json exactly like AnnotationHandler, but without any project indicated.
+ We get or set the current content front project, and add the annotation
+ """
+ try:
+ content = Content.objects.get(iri_id=iri_id)
+ except Content.DoesNotExist:
+ return rc.NOT_HERE
+ proj = content.get_or_create_front_project()
+ ah = AnnotationHandler()
+ updated_data = ah.update(request, proj.ldt_id)
+
+ return updated_data
class SegmentHandler(BaseHandler):
--- a/src/ldt/ldt/ldt_utils/models.py Sat Aug 11 01:25:05 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/models.py Sat Aug 11 01:27:51 2012 +0200
@@ -366,6 +366,21 @@
self.front_project.publish(allow_write=True)
self.save()
set_current_user(old_user)
+
+
+ def get_or_create_front_project(self):
+ front_proj = self.front_project
+ if front_proj:
+ proj = front_proj
+ else:
+ # The main project for the content
+ proj = Project.safe_objects.filter(contents__in=[self], state=2)
+ if not proj:
+ self.create_front_project()
+ proj = self.front_project
+ else:
+ proj = proj[0]
+ return proj
# Tag management
--- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Sat Aug 11 01:25:05 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Sat Aug 11 01:27:51 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 Sat Aug 11 01:25:05 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/views/front.py Sat Aug 11 01:27:51 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))
@@ -87,17 +101,7 @@
# If project id is not set, we get the default project for the content
if project_id is None or project_id == "_":
- front_proj = content.front_project
- if front_proj:
- proj = front_proj
- else:
- # The main project for the content
- proj = Project.safe_objects.filter(contents__in=[content], state=2)
- if not proj:
- content.create_front_project()
- proj = content.front_project
- else:
- proj = proj[0]
+ proj = content.get_or_create_front_project()
else:
proj = Project.safe_objects.get(ldt_id=project_id)
--- a/src/ldt/ldt/settings.py Sat Aug 11 01:25:05 2012 +0200
+++ b/src/ldt/ldt/settings.py Sat Aug 11 01:27:51 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 Sat Aug 11 01:25:05 2012 +0200
+++ b/src/ldt/ldt/static/ldt/css/front_home.css Sat Aug 11 01:27:51 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 Sat Aug 11 01:25:05 2012 +0200
+++ b/web/ldtplatform/config.py.tmpl Sat Aug 11 01:27:51 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 Sat Aug 11 01:25:05 2012 +0200
+++ b/web/ldtplatform/settings.py Sat Aug 11 01:27:51 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