--- a/src/metadatacomposer/templates/metadatacomposer_home.html Mon May 27 13:36:54 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_home.html Mon May 27 16:07:53 2013 +0200
@@ -64,7 +64,7 @@
<h3 class="span8"><i class="icon-picture"></i> Dernières images</h3>
<div class="span4 wrap-btn-add">
<a data-type-media="image" data-title="Ajouter une image" class="btn btn-success open-modal"
- href="{% url 'composer_modal_image' branding=branding %}" data-hide-bibliotheque>
+ href="{% url 'composer_modal_image' branding=branding %}" data-hide-bibliotheque="">
Ajouter une image <i class="icon-plus-sign"></i></a>
</div>
</div>
@@ -82,7 +82,7 @@
<h3 class="span8"><i class="icon-film"></i> Dernières vidéos</h3>
<div class="span4 wrap-btn-add">
<a data-type-media="video" data-title="Ajouter une vidéo" class="btn btn-success open-modal"
- href="{% url 'composer_modal_video' branding=branding %}" data-hide-bibliotheque>
+ href="{% url 'composer_modal_video' branding=branding %}" data-hide-bibliotheque="">
Ajouter une vidéo <i class="icon-plus-sign"></i></a>
</div>
</div>
--- a/src/metadatacomposer/templates/metadatacomposer_modal_image.html Mon May 27 13:36:54 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_modal_image.html Mon May 27 16:07:53 2013 +0200
@@ -3,11 +3,11 @@
<div class="row">
<div class="span3">
<ul class="modal-menu">
- <li class="bibliotheque-link"><a data-type-media="image" data-title="Bibliothèque" class="btn open-modal" href="modal-bibliotheque-image.html"><i class="icon-folder-open"></i> Bibliothèque</a></li>
+ <li class="bibliotheque-link"><a data-type-media="image" data-title="Bibliothèque" class="btn open-modal" href="{% url 'composer_modal_image_library' branding=branding %}"><i class="icon-folder-open"></i> Bibliothèque</a></li>
<li><a class="btn active" tabindex="-1" href="#"><i class="icon-plus-sign"></i> Ajouter une image</a></li>
</ul>
</div>
- <div class="span8 offset1 popup-content">
+ <div class="span8 popup-content">
<h4>Informations et source de l'image</h4>
<form class="form-horizontal" action="{% url 'composer_modal_image' branding=branding %}" enctype="multipart/form-data" method="post">{% csrf_token %}
{% if image_pk %}<input type="hidden" value="{{ image_pk }}" name="image_pk">{% endif %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/templates/metadatacomposer_modal_image_library.html Mon May 27 16:07:53 2013 +0200
@@ -0,0 +1,13 @@
+{% load static %}
+{% load thumbnail %}
+<div class="row">
+ <div class="span3">
+ <ul class="modal-menu">
+ <li><a class="btn active" tabindex="-1" href="#"><i class="icon-folder-open"></i> Bibliothèque</a></li>
+ <li><a class="btn open-modal" data-type-media="image" data-title="Ajouter une image" tabindex="-1" href="{% url 'composer_modal_image' branding=branding %}"><i class="icon-plus-sign"></i> Ajouter une image</a></li>
+ </ul>
+ </div>
+ <div class="span8 popup-content bibliotheque-image" id="image_list_container_library">
+ {% include 'partial/library_image_list.html' %}
+ </div>
+</div>
\ No newline at end of file
--- a/src/metadatacomposer/templates/metadatacomposer_modal_video.html Mon May 27 13:36:54 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_modal_video.html Mon May 27 16:07:53 2013 +0200
@@ -8,7 +8,7 @@
<li><a class="btn active" tabindex="-1" href="#"><i class="icon-plus-sign"></i> Ajouter une video</a></li>
</ul>
</div>
- <div class="span8 offset1 popup-content">
+ <div class="span8 popup-content">
<form class="row" action="{% if content %}{% url 'composer_modal_video' branding=branding iri_id=content.iri_id %}{% else %}{% url 'composer_modal_video' branding=branding %}{% endif %}" enctype="multipart/form-data" method="post">
<h4 class="span8">Informations sur la vidéo</h4>
--- a/src/metadatacomposer/templates/metadatacomposer_resource_list.html Mon May 27 13:36:54 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_resource_list.html Mon May 27 16:07:53 2013 +0200
@@ -19,7 +19,8 @@
<div class="row article-title">
<h3 class="span8"><i class="icon-picture"></i> Liste des images</h3>
<div class="span4 wrap-btn-add">
- <a data-type-media="image" data-title="Ajouter une image" class="btn btn-success open-modal" href="{% url 'composer_modal_image' branding=branding %}">
+ <a data-type-media="image" data-title="Ajouter une image" class="btn btn-success open-modal"
+ href="{% url 'composer_modal_image' branding=branding %}" >
Ajouter une image <i class="icon-plus-sign"></i>
</a>
</div>
@@ -107,5 +108,22 @@
}
});
});
+ $(document).on('click', 'a.image_pagination_library', function(e){
+ e.preventDefault();e.stopPropagation();
+ var url = $(this).attr('href');
+ $(this).addClass("loader");
+ $.ajax({
+ url: url,
+ cache: false,
+ type: 'GET',
+ success: function(data, status, request) {
+ $("#image_list_container_library").html(data);
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ resp = $.parseJSON(jqXHR.responseText);
+ alert(resp.message);
+ }
+ });
+ });
</script>
{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/templates/partial/library_image_list.html Mon May 27 16:07:53 2013 +0200
@@ -0,0 +1,38 @@
+{% load static %}
+{% load i18n %}
+{% load thumbnail %}
+{% load front_tags %}
+ <div class="row">
+ {% for i in image_results %}
+ <div class="span2">
+ <a href="">{% thumbnail i.image_file "140x140" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}<img src="{% static 'metadatacomposer/img/140x140.gif' %}" width="140px" height="140px" />{% endthumbnail %}
+ <h5><a href="#">{{ i.title }}</a></h5>
+ </div>
+ {% endfor %}
+ </div>
+ <div class="pagination">
+ <ul>
+ {% if image_results.has_previous %}
+ <li><a href="{% url 'composer_image_page' branding=branding %}?page={{ image_results.previous_page_number }}&mode=library" class="image_pagination_library">{% trans "Previous" %}</a></li>
+ {% else %}
+ <li class="disabled"><a>{% trans "Previous" %}</a></li>
+ {% endif %}
+ {% if image_results.paginator.num_pages > 1 %}
+ {% for i in image_results.paginator.num_pages|get_range %}
+ {% if i|add:'1' == image_results.number %}
+ <li class="active"><a href="#">{{i|add:'1'}}</a></li>
+ {% else %}
+ <li><a href="{% url 'composer_image_page' branding=branding %}?page={{i|add:'1'}}&mode=library" class="image_pagination_library">{{i|add:'1'}}</a></li>
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+ {% if image_results.has_next %}
+ <li><a href="{% url 'composer_image_page' branding=branding %}?page={{ image_results.next_page_number }}&mode=library" class="image_pagination_library">{% trans "Next" %}</a></li>
+ {% else %}
+ <li class="disabled"><a>{% trans "Next" %}</a></li>
+ {% endif %}
+ {% if image_results.paginator.num_pages > 1 %}
+ <li><a href="{% url 'composer_image_page' branding=branding %}?page=x&mode=library" class="image_pagination_library">({% trans "All" %})</a></li>
+ {% endif %}
+ </ul>
+ </div>
\ No newline at end of file
--- a/src/metadatacomposer/urls.py Mon May 27 13:36:54 2013 +0200
+++ b/src/metadatacomposer/urls.py Mon May 27 16:07:53 2013 +0200
@@ -2,7 +2,7 @@
from metadatacomposer.views import MetadataComposerHome, MetadataComposerProjectList,\
MetadataComposerResourceList, MetadataComposerContentPagination,\
MetadataComposerModalVideo, MetadataComposerModalImage,\
- MetadataComposerImagePagination
+ MetadataComposerImagePagination, MetadataComposerModalImageLibrary
urlpatterns = patterns('',
url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog', name='jsi18n'),
@@ -13,6 +13,7 @@
url(r'^(?P<branding>.*)/modalvideo/(?P<iri_id>[\w-]+)$', MetadataComposerModalVideo.as_view(), name="composer_modal_video"),
url(r'^(?P<branding>.*)/modalvideo/$', MetadataComposerModalVideo.as_view(), name="composer_modal_video"),
url(r'^(?P<branding>.*)/modalimage/$', MetadataComposerModalImage.as_view(), name="composer_modal_image"),
+ url(r'^(?P<branding>.*)/modalimagelibrary/$', MetadataComposerModalImageLibrary.as_view(), name="composer_modal_image_library"),
url(r'^(?P<branding>.*)/$', MetadataComposerHome.as_view(), name="composer_home"),
url(r'^$', MetadataComposerHome.as_view(), name="composer_home"),
)
--- a/src/metadatacomposer/views.py Mon May 27 13:36:54 2013 +0200
+++ b/src/metadatacomposer/views.py Mon May 27 16:07:53 2013 +0200
@@ -110,7 +110,10 @@
class MetadataComposerImagePagination(TemplateResponseMixin, MetadataComposerContextView):
def get_template_names(self):
- return "partial/resource_image_list.html"
+ if self.template_name and self.template_name!="":
+ return self.template_name
+ else:
+ return "partial/resource_image_list.html"
@method_decorator(login_required)
@method_decorator(never_cache)
@@ -120,9 +123,13 @@
def get(self, request, branding="iri", **kwargs):
self.branding = branding
page = request.GET.get("page") or 1
+ mode = request.GET.get("mode") or "resource"
# Get current contents page and theirs projects
image_results = get_images(page)
+ if mode=="library":
+ self.template_name = "partial/library_image_list.html"
+
context = self.get_context_dict(request)
context.update({"image_results":image_results})
return self.render_to_response(context)
@@ -276,3 +283,22 @@
+class MetadataComposerModalImageLibrary(TemplateResponseMixin, MetadataComposerContextView):
+
+ def get_template_names(self):
+ return "metadatacomposer_modal_image_library.html"
+
+ @method_decorator(login_required)
+ @method_decorator(never_cache)
+ def dispatch(self, *args, **kwargs):
+ return super(MetadataComposerModalImageLibrary, self).dispatch(*args, **kwargs)
+
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+
+ context = self.get_context_dict(request)
+ context.update({"image_results":get_images(1)})
+ return self.render_to_response(context)
+
+
+