# (r'^admin/terms/(?P<term_id>\d+)/delete$', 'admin_term_delete'),
# (r'^admin/terms/$', 'admin_term'),
(r'^unapi/$', 'unapi'),
+
+ (r'^site/(?P<site_id>\d+)/copy_from/$', 'site_clipboard_copy_from'),
+ (r'^site/(?P<site_id>\d+)/paste_to/$', 'site_clipboard_paste_to'),
+ (r'^site/(?P<site_id>\d+)/paste_undo/$', 'site_clipboard_paste_undo'),
)
return HttpResponse(simplejson.dumps(resp),
content_type='application/json')
+
+def site_clipboard_copy_from(request, site_id):
+ site = get_object_or_404(models.Site, pk=site_id)
+ request.session['copy_source'] = site_id
+ return simple_message(_('Ready to copy.'),
+ _('This site has been marked as the copying source. Visit the new site, '
+ 'and click "Paste to Here," to copy this site\'s materials into the new site.'))
+
+def site_clipboard_paste_to(request, site_id):
+ source_id = request.session['copy_source']
+ source_site = get_object_or_404(models.Site, pk=source_id)
+ site = get_object_or_404(models.Site, pk=site_id)
+ if request.method != 'POST':
+ return g.render('site_confirm_paste.xhtml', **locals())
+
+ item_map = {}
+
+ def process_item(parent, (item, subitems)):
+ dct = dict((k,v) for k,v in item.__dict__.items() if not k.startswith('_'))
+ old_id = dct['id']
+ del dct['id']
+ dct['parent_heading_id'] = parent.id if parent else None
+ newitem = models.Item.objects.create(**dct)
+ newitem.site = site
+ newitem.save()
+ item_map[old_id] = newitem.id
+ for sub in subitems:
+ process_item(newitem, sub)
+
+ for branch in source_site.item_tree():
+ process_item(None, branch)
+ request.session['last_paste'] = (source_site.id, site.id, item_map.values())
+ return HttpResponseRedirect('../')
+
+def site_clipboard_paste_undo(request, site_id):
+ site = get_object_or_404(models.Site, pk=site_id)
+ source_id, _site_id, item_list = request.session.get('last_paste', (0,0,0))
+ if _site_id != site.id: # should never happen
+ return HttpResponseRedirect('../')
+ source_site = get_object_or_404(models.Site, pk=source_id)
+ if request.method != 'POST':
+ return g.render('site_confirm_paste_undo.xhtml', **locals())
+ for item_id in item_list:
+ site.item_set.get(pk=item_id).delete()
+ del request.session['last_paste']
+ return HttpResponseRedirect('../')
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<?python
+title = _('Paste into this site?')
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+ <xi:include href="master.xhtml"/>
+ <xi:include href="components/site.xhtml"/>
+ <head>
+ <title>${title}</title>
+ </head>
+ <body>
+ <h2>${title}</h2>
+ <p>Please confirm that you want to paste the materials into this site.</p>
+ <table class="metadata_table">
+ <tr><th>Source:</th><td><a href="${source_site.site_url()}">${source_site}</a></td></tr>
+ <tr><th>Destination:</th><td>${site}</td></tr>
+ <tr><th>Items:</th><td>
+ ${show_tree(source_site.item_tree())}
+ </td></tr>
+ </table>
+ <form action="." method="POST">
+ <p>
+ <input type="submit" value="Paste the materials"/>
+ ${go_back_link()}
+ </p>
+ </form>
+ </body>
+</html>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<?python
+title = _('Undo last paste?')
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+ <xi:include href="master.xhtml"/>
+ <xi:include href="components/site.xhtml"/>
+ <head>
+ <title>${title}</title>
+ </head>
+ <body>
+ <h2>${title}</h2>
+ <p>Please confirm that you want to <b>remove</b> the materials that you last pasted into this site.</p>
+ <table class="metadata_table">
+ <tr><th>Source:</th><td><a href="${source_site.site_url()}">${source_site}</a></td></tr>
+ <tr><th>Destination:</th><td>${site}</td></tr>
+ <tr><th>Items:</th><td>
+ <div py:for="item in sorted([site.item_set.get(pk=n) for n in item_list], key=lambda i: i.title)">
+ ${show_tree([(item, [])])}
+ </div>
+ </td></tr>
+ </table>
+ <form action="." method="POST">
+ <p>
+ <input type="submit" value="Remove the pasted materials"/>
+ ${go_back_link()}
+ </p>
+ </form>
+ </body>
+</html>
\ No newline at end of file
<div py:if="is_editor" id="feeds" class="little_action_panel">
<a href="${site.site_url()}feeds/">Feeds</a>
</div>
+ <div py:if="is_editor" id="copy_from" class="little_action_panel">
+ <a href="${site.site_url()}copy_from/">Copy from here</a>
+ </div>
+ <div py:if="is_editor and request.session.get('copy_source')" id="paste_to" class="little_action_panel">
+ <a href="${site.site_url()}paste_to/">Paste to here</a>
+ </div>
+ <div py:if="is_editor and request.session.get('last_paste', (0,0,0))[1] == site.id"
+ id="paste_undo" class="little_action_panel">
+ <a href="${site.site_url()}paste_undo/">Undo last paste</a>
+ </div>
+
</div>
<div py:if="is_editor">${add_subs()}</div>
-
-
</body>
</html>