--- a/src/metadatacomposer/templates/metadatacomposer_project_list.html Wed Jun 05 12:05:53 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_project_list.html Thu Jun 06 12:42:03 2013 +0200
@@ -38,16 +38,12 @@
<td>{% with c=p.contents.all|first %}<a href="{% url 'embediframe_page' %}?content_id={{ c.iri_id }}" data-type-media="video" data-title="{{ c.title }}" class="open-modal" data-hide-add-new data-iframe>{{ c.title }}</a>{% endwith %}</td>
<td>{{ p.modification_date|date:"Y/m/d" }}</td>
<td>
- <form action="#">
- <input class="input-small in-table" id="url_{{ p.ldt_id }}" type="text" value="{% absurl 'composer_player' branding=branding ldt_id=p.ldt_id %}" readonly="readonly">
- <a href="#" class="btn clipboard" data-clipboard-target="url_{{ p.ldt_id }}"><i class="icon-link"></i></a>
- </form>
+ <input class="input-small in-table" id="url_{{ p.ldt_id }}" type="text" value="{% absurl 'composer_preview_player' branding=branding ldt_id=p.ldt_id %}" readonly="readonly">
+ <a href="#" class="btn clipboard" data-clipboard-target="url_{{ p.ldt_id }}"><i class="icon-link"></i></a>
</td>
<td>
- <form action="#">
- <input class="input-small in-table" id="embed_{{ p.ldt_id }}" type="text" value="<iframe src='{% absurl 'composer_player' branding=branding ldt_id=p.ldt_id %}' width='1000' height='700' frameborder='0'></iframe>" readonly="readonly">
- <a href="#" class="btn clipboard" data-clipboard-target="embed_{{ p.ldt_id }}"><i class="icon-link"></i></a>
- </form>
+ <input class="input-small in-table" id="embed_{{ p.ldt_id }}" type="text" value="<iframe src='{% absurl 'composer_player' branding=branding ldt_id=p.ldt_id %}' width='1000' height='700' frameborder='0'></iframe>" readonly="readonly">
+ <a href="#" class="btn clipboard" data-clipboard-target="embed_{{ p.ldt_id }}"><i class="icon-link"></i></a>
</td>
<td class="actions">
<table>
@@ -57,7 +53,7 @@
</tr>
<tr>
<td><a class="btn" href="{% url 'composer_preview_player' branding=branding ldt_id=p.ldt_id %}" target="_blank"><i class="icon-eye-open"></i></a></td>
- <td><a class="btn" href="#"><i class="icon-copy"></i></a></td>
+ <td><a class="btn" href="{% url 'composer_duplicate_project' branding=branding %}?ldt_id={{ p.ldt_id }}"><i class="icon-copy"></i></a></td>
</tr>
</table>
</td>
--- a/src/metadatacomposer/urls.py Wed Jun 05 12:05:53 2013 +0200
+++ b/src/metadatacomposer/urls.py Thu Jun 06 12:42:03 2013 +0200
@@ -7,7 +7,7 @@
MetadataComposerRemoveProject, MetadataComposerImage,\
MetadataComposerModalContentLibrary, MetadataComposerPlayer,\
MetadataComposerPreviewPlayer, MetadataComposerEdit,\
- MetadataComposerNewProject
+ MetadataComposerNewProject, MetadataComposerDuplicateProject
urlpatterns = patterns('',
url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog', name='jsi18n'),
@@ -23,6 +23,7 @@
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>.*)/duplicateproject/$', MetadataComposerDuplicateProject.as_view(), name="composer_duplicate_project"),
url(r'^(?P<branding>.*)/image/(?P<image_pk>[\w-]+)/$', MetadataComposerImage.as_view(), name="composer_image"),
url(r'^(?P<branding>.*)/player/(?P<ldt_id>[\w-]+)/$', MetadataComposerPlayer.as_view(), name="composer_player"),
url(r'^(?P<branding>.*)/previewplayer/(?P<ldt_id>[\w-]+)/$', MetadataComposerPreviewPlayer.as_view(), name="composer_preview_player"),
--- a/src/metadatacomposer/views.py Wed Jun 05 12:05:53 2013 +0200
+++ b/src/metadatacomposer/views.py Thu Jun 06 12:42:03 2013 +0200
@@ -558,11 +558,37 @@
assign('view_project', u, project)
assign('change_project', u, project)
# Since the project is published by default, we assign permission for the everyone group
- everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
- assign('ldt_utils.view_project', everyone, project)
+ assign('ldt_utils.view_project', Group.objects.get(name=settings.PUBLIC_GROUP_NAME), project)
# Redirect to project edition in composer interface
return redirect('composer_edit', branding=branding, ldt_id=project.ldt_id)
+class MetadataComposerDuplicateProject(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)
+ u = request.user
+ # Create project
+ newproj = Project.create_project(title="Copy of " + proj.title,
+ user=u, contents=proj.contents.all(),
+ description=proj.description,
+ set_icon=False)
+ # Save ldt content and set project state to "published" and save
+ newproj.ldt = proj.ldt
+ newproj.state = 2
+ newproj.save()
+ assign('view_project', u, newproj)
+ assign('change_project', u, newproj)
+ # Since the project is published by default, we assign permission for the everyone group
+ assign('ldt_utils.view_project', Group.objects.get(name=settings.PUBLIC_GROUP_NAME), newproj)
+
+ return redirect("composer_project_list", branding=branding)
+
+
+