# HG changeset patch # User ymh # Date 1344641271 -7200 # Node ID 45ddd94e130255ca8782e20bc51de019996e8633 # Parent 7e3d483e1ba3caa438f8845b5d71d12b2f8b99f8# Parent 45d81451195884fd5e087f5517461cb777e19117 Merge with 45d81451195884fd5e087f5517461cb777e19117 diff -r 7e3d483e1ba3 -r 45ddd94e1302 .settings/org.eclipse.core.resources.prefs --- 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 diff -r 7e3d483e1ba3 -r 45ddd94e1302 src/ldt/ldt/api/ldt/handlers.py --- 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): diff -r 7e3d483e1ba3 -r 45ddd94e1302 src/ldt/ldt/ldt_utils/models.py --- 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 diff -r 7e3d483e1ba3 -r 45ddd94e1302 src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html --- 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 @@ {{t.name}}{% if not forloop.last %}, {% endif %}{% endfor %}

{% endif %} - {% for content in content_list %} + +
  • +

    + {% if results.has_previous %} + {% trans "previous" %} + {% endif %} + {% if results.paginator.num_pages > 1 %} + + {% for i in results.paginator.num_pages|get_range %} + + {% if i|add:'1' == results.number %} + {{i|add:'1'}} + {% else %} + {{i|add:'1'}} + {% endif %} + {% if i|add:'1' < results.paginator.num_pages and 1 < results.paginator.num_pages %} + {% endif %} + + {% endfor %} + + {% endif %} + {% if results.has_next %} + {% trans "next" %} + {% endif %} + {% if results.paginator.num_pages > 1 %} + . ({% trans 'All' %}) + {% endif %} +

    +
  • + + {% for content in results.object_list %}
  • diff -r 7e3d483e1ba3 -r 45ddd94e1302 src/ldt/ldt/ldt_utils/views/front.py --- 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) diff -r 7e3d483e1ba3 -r 45ddd94e1302 src/ldt/ldt/settings.py --- 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) diff -r 7e3d483e1ba3 -r 45ddd94e1302 src/ldt/ldt/static/ldt/css/front_home.css --- 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; diff -r 7e3d483e1ba3 -r 45ddd94e1302 web/ldtplatform/config.py.tmpl --- 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 diff -r 7e3d483e1ba3 -r 45ddd94e1302 web/ldtplatform/settings.py --- 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