# HG changeset patch # User cavaliet # Date 1370515323 -7200 # Node ID 8e016726669b83def5bfb71ea78c5e69252367cf # Parent 9115f9cba3a5542311f88a920db07d3028f49df6# Parent 5dfa74fcec4bd0e9e725e57c6473f07dbb0c1f8c Merge with 5dfa74fcec4bd0e9e725e57c6473f07dbb0c1f8c diff -r 5dfa74fcec4b -r 8e016726669b src/metadatacomposer/templates/metadatacomposer_project_list.html --- 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 @@ {% with c=p.contents.all|first %}{{ c.title }}{% endwith %} {{ p.modification_date|date:"Y/m/d" }} -
- - -
+ + -
- - -
+ + @@ -57,7 +53,7 @@ - +
diff -r 5dfa74fcec4b -r 8e016726669b src/metadatacomposer/urls.py --- 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\S+?)/$', 'django.views.i18n.javascript_catalog', name='jsi18n'), @@ -23,6 +23,7 @@ url(r'^(?P.*)/removecontent/$', MetadataComposerRemoveContent.as_view(), name="composer_remove_content"), url(r'^(?P.*)/removeimage/$', MetadataComposerRemoveImage.as_view(), name="composer_remove_image"), url(r'^(?P.*)/removeproject/$', MetadataComposerRemoveProject.as_view(), name="composer_remove_project"), + url(r'^(?P.*)/duplicateproject/$', MetadataComposerDuplicateProject.as_view(), name="composer_duplicate_project"), url(r'^(?P.*)/image/(?P[\w-]+)/$', MetadataComposerImage.as_view(), name="composer_image"), url(r'^(?P.*)/player/(?P[\w-]+)/$', MetadataComposerPlayer.as_view(), name="composer_player"), url(r'^(?P.*)/previewplayer/(?P[\w-]+)/$', MetadataComposerPreviewPlayer.as_view(), name="composer_preview_player"), diff -r 5dfa74fcec4b -r 8e016726669b src/metadatacomposer/views.py --- 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) + + +