--- a/src/metadatacomposer/templates/metadatacomposer_home.html Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_home.html Tue May 28 18:51:57 2013 +0200
@@ -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_content' branding=branding %}" data-hide-bibliotheque="">
Ajouter une vidéo <i class="icon-plus-sign"></i></a>
</div>
</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/templates/metadatacomposer_modal_content.html Tue May 28 18:51:57 2013 +0200
@@ -0,0 +1,68 @@
+{% load static %}
+{% load thumbnail %}
+{% load composer_tags %}
+<div class="row">
+ <div class="span3">
+ <ul class="modal-menu">
+ <li class="bibliotheque-link"><a data-type-media="video" data-title="Bibliothèque" class="btn open-modal" href="modal-bibliotheque-video.html"><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 video</a></li>
+ </ul>
+ </div>
+ <div class="span8 popup-content">
+
+ <form class="row" action="{% if content %}{% url 'composer_modal_content' branding=branding iri_id=content.iri_id %}{% else %}{% url 'composer_modal_content' branding=branding %}{% endif %}" enctype="multipart/form-data" method="post">
+ <h4 class="span8">Informations sur la vidéo</h4>
+ <div class="span4">
+ {% csrf_token %}
+ <label for="id_content-title">Titre :</label>
+ <input type="text" name="content-title" id="id_content-title" {% if content %}value="{{ content.title }}"{% endif %}/>
+ <label for="id_content-description">Description :</label>
+ <textarea name="content-description" id="id_content-description">{% if content %}{{ content.description }}{% endif %}</textarea>
+ <input type="hidden" name="content-duration" id="id_content-duration" {% if content %}value="{{ content.duration }}"{% endif %}/>
+ <input type="hidden" name="content-media_input_type" id="id_content-media_input_type" value="create" />
+ <input type="hidden" name="content-iri_id" id="id_content-iri_id" value="{{ iri_id }}"/>
+ <input type="checkbox" name="media-media_public" id="id_media-media_public" checked="checked" style="display:none" />
+ </div>
+ <div class="span4">
+ <label for="">Durée de la vidéo :</label>
+ <div class="select-duration">
+ <input pattern="[0-9]*" name="" type="text" id="video-hour" class="number-spin span1" value="{% if content %}{{ content.duration|to_hours }}{% else %}0{% endif %}">
+ <label for="video-hour">H</label>
+ <input pattern="[0-9]*" name="" type="text" id="video-minute" class="number-spin span1" value="{% if content %}{{ content.duration|to_minutes }}{% else %}10{% endif %}">
+ <label for="video-minute">M</label>
+ <input pattern="[0-9]*" name="" type="text" id="video-seconde" class="number-spin span1" value="{% if content %}{{ content.duration|to_seconds }}{% else %}0{% endif %}">
+ <label for="video-seconde">S</label>
+ </div>
+ <label for="">Vignette de la vidéo (jpg, png, 1Mo max) :</label>
+ <input type="file" name="image" id="id_image" accept="image/jpeg, image/png" />
+ {% if content %}
+ <p>Image actuelle :</p>
+ {% thumbnail content.image "x60" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}<img src="{% static 'metadatacomposer/img/60x60.gif' %}" width="60px" height="60px" />{% endthumbnail %}
+ {% endif %}
+ </div>
+ <div class="span8">
+ <h4>Source de la vidéo</h4>
+ <label for="">URL de la vidéo :</label>
+ <input type="text" class="input-xxlarge" placeholder="http://youtu.be" name="media-src" id="id_media-src" {% if content %}value="{{ content.media_obj.src }}"{% endif %}/>
+ <div class="control-group">
+ <div class="controls">
+ <a href="#" class="btn-cancel btn btn-inverse"><i class="icon-reply" data-dismiss="modal" aria-hidden="true"></i> Annuler</a>
+ <button type="submit" class="btn btn-success"><i class="icon-save"></i> Sauvegarder</button>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+</div>
+<script type="text/javascript">
+$('.select-duration .number-spin').spin({
+ imageBasePath :"{% static 'metadatacomposer/lib/spin/img/' %}",
+ max:60,
+ min:0
+});
+// Update time input in milliseconds
+$('.select-duration .number-spin').change(function(){
+ $("#id_content-duration").val( (parseInt($("#video-hour").val()) * 3600000) + (parseInt($("#video-minute").val()) * 60000) + (parseInt($("#video-seconde").val()) * 1000) );
+ console.log($("#id_content-duration").val());
+});
+</script>
\ No newline at end of file
--- a/src/metadatacomposer/templates/metadatacomposer_modal_video.html Tue May 28 17:42:15 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-{% load static %}
-{% load thumbnail %}
-{% load composer_tags %}
-<div class="row">
- <div class="span3">
- <ul class="modal-menu">
- <li class="bibliotheque-link"><a data-type-media="video" data-title="Bibliothèque" class="btn open-modal" href="modal-bibliotheque-video.html"><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 video</a></li>
- </ul>
- </div>
- <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>
- <div class="span4">
- {% csrf_token %}
- <label for="id_content-title">Titre :</label>
- <input type="text" name="content-title" id="id_content-title" {% if content %}value="{{ content.title }}"{% endif %}/>
- <label for="id_content-description">Description :</label>
- <textarea name="content-description" id="id_content-description">{% if content %}{{ content.description }}{% endif %}</textarea>
- <input type="hidden" name="content-duration" id="id_content-duration" {% if content %}value="{{ content.duration }}"{% endif %}/>
- <input type="hidden" name="content-media_input_type" id="id_content-media_input_type" value="create" />
- <input type="hidden" name="content-iri_id" id="id_content-iri_id" value="{{ iri_id }}"/>
- <input type="checkbox" name="media-media_public" id="id_media-media_public" checked="checked" style="display:none" />
- </div>
- <div class="span4">
- <label for="">Durée de la vidéo :</label>
- <div class="select-duration">
- <input pattern="[0-9]*" name="" type="text" id="video-hour" class="number-spin span1" value="{% if content %}{{ content.duration|to_hours }}{% else %}0{% endif %}">
- <label for="video-hour">H</label>
- <input pattern="[0-9]*" name="" type="text" id="video-minute" class="number-spin span1" value="{% if content %}{{ content.duration|to_minutes }}{% else %}10{% endif %}">
- <label for="video-minute">M</label>
- <input pattern="[0-9]*" name="" type="text" id="video-seconde" class="number-spin span1" value="{% if content %}{{ content.duration|to_seconds }}{% else %}0{% endif %}">
- <label for="video-seconde">S</label>
- </div>
- <label for="">Vignette de la vidéo (jpg, png, 1Mo max) :</label>
- <input type="file" name="image" id="id_image" accept="image/jpeg, image/png" />
- {% if content %}
- <p>Image actuelle :</p>
- {% thumbnail content.image "x60" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}<img src="{% static 'metadatacomposer/img/60x60.gif' %}" width="60px" height="60px" />{% endthumbnail %}
- {% endif %}
- </div>
- <div class="span8">
- <h4>Source de la vidéo</h4>
- <label for="">URL de la vidéo :</label>
- <input type="text" class="input-xxlarge" placeholder="http://youtu.be" name="media-src" id="id_media-src" {% if content %}value="{{ content.media_obj.src }}"{% endif %}/>
- <div class="control-group">
- <div class="controls">
- <a href="#" class="btn-cancel btn btn-inverse"><i class="icon-reply" data-dismiss="modal" aria-hidden="true"></i> Annuler</a>
- <button type="submit" class="btn btn-success"><i class="icon-save"></i> Sauvegarder</button>
- </div>
- </div>
- </div>
- </form>
- </div>
-</div>
-<script type="text/javascript">
-$('.select-duration .number-spin').spin({
- imageBasePath :"{% static 'metadatacomposer/lib/spin/img/' %}",
- max:60,
- min:0
-});
-// Update time input in milliseconds
-$('.select-duration .number-spin').change(function(){
- $("#id_content-duration").val( (parseInt($("#video-hour").val()) * 3600000) + (parseInt($("#video-minute").val()) * 60000) + (parseInt($("#video-seconde").val()) * 1000) );
- console.log($("#id_content-duration").val());
-});
-</script>
\ No newline at end of file
--- a/src/metadatacomposer/templates/metadatacomposer_project_list.html Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_project_list.html Tue May 28 18:51:57 2013 +0200
@@ -48,7 +48,7 @@
<table>
<tr>
<td><a class="btn" href="#"><i class="icon-pencil"></i></a></td>
- <td><a class="btn btn-delete" data-title="Titre du média" href="#"><i class="icon-remove"></i></a></td>
+ <td><a class="btn btn-delete" data-title="{{ p.title }}" href="{% url 'composer_remove_project' branding=branding %}?ldt_id={{ p.ldt_id }}"><i class="icon-remove"></i></a></td>
</tr>
<tr>
<td><a class="btn" href="#"><i class="icon-eye-open"></i></a></td>
--- a/src/metadatacomposer/templates/metadatacomposer_resource_list.html Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_resource_list.html Tue May 28 18:51:57 2013 +0200
@@ -35,7 +35,7 @@
<div class="row article-title">
<h3 class="span8"><i class="icon-film"></i> Liste des 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 %}">
+ <a data-type-media="video" data-title="Ajouter une vidéo" class="btn btn-success open-modal" href="{% url 'composer_modal_content' branding=branding %}">
Ajouter une vidéo <i class="icon-plus-sign"></i>
</a>
</div>
--- a/src/metadatacomposer/templates/partial/resource_content_list.html Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/templates/partial/resource_content_list.html Tue May 28 18:51:57 2013 +0200
@@ -14,7 +14,7 @@
</thead>
<tbody class="liste">
{% for res in content_results %}
- <tr id="row-list-ressources-video-id1">
+ <tr id="row-list-ressources-video-id{{ forloop.counter }}">
<td>{% thumbnail res.content.image "60x60" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}<img src="{% static 'metadatacomposer/img/60x60.gif' %}" width="60px" height="60px" />{% endthumbnail %}</td>
<td>{{ res.content.title }}</td>
<td>
@@ -26,10 +26,8 @@
</td>
<td>{{ res.content.update_date|date:"Y/m/d" }}</td>
<td>
- <a data-type-media="video" data-title="Modifier une vidéo" class="btn open-modal" href="{% url 'composer_modal_video' branding=branding iri_id=res.content.iri_id %}"><i class="icon-pencil"></i></a>
- <a class="btn btn-delete" data-title="{{ res.content.title }}" href="#">
- <i class="icon-remove"></i>
- </a>
+ <a data-type-media="video" data-title="Modifier une vidéo" class="btn open-modal" href="{% url 'composer_modal_content' branding=branding iri_id=res.content.iri_id %}"><i class="icon-pencil"></i></a>
+ <a class="btn btn-delete" data-title="{{ res.content.title }}" href="{% url 'composer_remove_content' branding=branding %}?iri_id={{ res.content.iri_id }}"><i class="icon-remove"></i></a>
</td>
</tr>
{% endfor %}
--- a/src/metadatacomposer/templates/partial/resource_image_list.html Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/templates/partial/resource_image_list.html Tue May 28 18:51:57 2013 +0200
@@ -14,7 +14,7 @@
</thead>
<tbody class="liste">
{% for res in image_results %}
- <tr id="row-list-ressources-image-id1">
+ <tr id="row-list-ressources-image-id{{ forloop.counter }}">
<td>{% thumbnail res.image_file "60x60" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}<img src="{% static 'metadatacomposer/img/60x60.gif' %}" width="60px" height="60px" />{% endthumbnail %}</td>
<td>{{ res.title }}</td>
<td>
@@ -25,7 +25,7 @@
<td>{{ res.modification_date|date:"Y/m/d" }}</td>
<td>
<a data-type-media="image" data-title="Modifier une image" class="btn open-modal" href="{% url 'composer_modal_image' branding=branding %}?image={{ res.pk }}"><i class="icon-pencil"></i></a>
- <a class="btn btn-delete" data-title="{{ res.title }}" href="#">
+ <a class="btn btn-delete" data-title="{{ res.title }}" href="{% url 'composer_remove_image' branding=branding %}?image={{ res.pk }}">
<i class="icon-remove"></i>
</a>
</td>
--- a/src/metadatacomposer/urls.py Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/urls.py Tue May 28 18:51:57 2013 +0200
@@ -1,8 +1,10 @@
from django.conf.urls.defaults import patterns, url
from metadatacomposer.views import MetadataComposerHome, MetadataComposerProjectList,\
MetadataComposerResourceList, MetadataComposerContentPagination,\
- MetadataComposerModalVideo, MetadataComposerModalImage,\
- MetadataComposerImagePagination, MetadataComposerModalImageLibrary
+ MetadataComposerModalContent, MetadataComposerModalImage,\
+ MetadataComposerImagePagination, MetadataComposerModalImageLibrary,\
+ MetadataComposerRemoveImage, MetadataComposerRemoveContent,\
+ MetadataComposerRemoveProject
urlpatterns = patterns('',
url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog', name='jsi18n'),
@@ -10,10 +12,13 @@
url(r'^(?P<branding>.*)/resourcelist/$', MetadataComposerResourceList.as_view(), name="composer_resource_list"),
url(r'^(?P<branding>.*)/imagepage/$', MetadataComposerImagePagination.as_view(), name="composer_image_page"),
url(r'^(?P<branding>.*)/contentpage/$', MetadataComposerContentPagination.as_view(), name="composer_content_page"),
- 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>.*)/modalcontent/(?P<iri_id>[\w-]+)$', MetadataComposerModalContent.as_view(), name="composer_modal_content"),
+ url(r'^(?P<branding>.*)/modalcontent/$', MetadataComposerModalContent.as_view(), name="composer_modal_content"),
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>.*)/removecontent/$', MetadataComposerRemoveContent.as_view(), name="composer_remove_content"),
+ url(r'^(?P<branding>.*)/removeimage/$', MetadataComposerRemoveImage.as_view(), name="composer_remove_image"),
+ url(r'^(?P<branding>.*)/removeproject/$', MetadataComposerRemoveProject.as_view(), name="composer_remove_project"),
url(r'^(?P<branding>.*)/$', MetadataComposerHome.as_view(), name="composer_home"),
url(r'^$', MetadataComposerHome.as_view(), name="composer_home"),
)
--- a/src/metadatacomposer/views.py Tue May 28 17:42:15 2013 +0200
+++ b/src/metadatacomposer/views.py Tue May 28 18:51:57 2013 +0200
@@ -1,13 +1,14 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, InvalidPage, EmptyPage
-from django.shortcuts import redirect
+from django.shortcuts import redirect, get_object_or_404
from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache
from django.views.generic.base import View, TemplateResponseMixin
from ldt.ldt_utils.models import Project, Content
-from ldt.ldt_utils.views.content import write_content_base
+from ldt.ldt_utils.views.content import write_content_base, delete_content
from ldt.ldt_utils.utils import generate_uuid
+from ldt.security.permissionchecker import check_object_perm_for_user
from metadatacomposer.forms import ImageUploadModelForm
from metadatacomposer.models import Image
@@ -202,15 +203,15 @@
-class MetadataComposerModalVideo(TemplateResponseMixin, MetadataComposerContextView):
+class MetadataComposerModalContent(TemplateResponseMixin, MetadataComposerContextView):
def get_template_names(self):
- return "metadatacomposer_modal_video.html"
+ return "metadatacomposer_modal_content.html"
@method_decorator(login_required)
@method_decorator(never_cache)
def dispatch(self, *args, **kwargs):
- return super(MetadataComposerModalVideo, self).dispatch(*args, **kwargs)
+ return super(MetadataComposerModalContent, self).dispatch(*args, **kwargs)
def get(self, request, branding="iri", iri_id=None, **kwargs):
self.branding = branding
@@ -302,3 +303,46 @@
+class MetadataComposerRemoveImage(View):
+
+ def get_template_names(self):
+ return "metadatacomposer_modal_image_library.html"
+
+ @method_decorator(login_required)
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+ image_pk = request.GET.get("image") or None
+ if image_pk:
+ image = get_object_or_404(Image, pk=image_pk)
+ image.delete()
+
+ return redirect(request.META['HTTP_REFERER'])
+
+
+
+class MetadataComposerRemoveContent(View):
+
+ @method_decorator(login_required)
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+ delete_content(request)
+
+ return redirect(request.META['HTTP_REFERER'])
+
+
+
+class MetadataComposerRemoveProject(View):
+
+ @method_decorator(login_required)
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+ ldt_id = request.GET.get("ldt_id") or None
+ if ldt_id:
+ proj = get_object_or_404(Project, ldt_id=ldt_id)
+ if check_object_perm_for_user(proj, "change_project", request.user):
+ proj.delete()
+
+ return redirect(request.META['HTTP_REFERER'])
+
+
+