From: Radek Czajka Date: Wed, 26 Oct 2011 10:44:41 +0000 (+0200) Subject: remove to archive, X-Git-Url: https://git.mdrn.pl/audio.git/commitdiff_plain/d4ae69daba9be2dc07e2ec064cffde51b82a9937 remove to archive, urlencode weird filenames --- diff --git a/apps/archive/locale/pl/LC_MESSAGES/django.mo b/apps/archive/locale/pl/LC_MESSAGES/django.mo index a851bda..7248dac 100644 Binary files a/apps/archive/locale/pl/LC_MESSAGES/django.mo and b/apps/archive/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/archive/locale/pl/LC_MESSAGES/django.po b/apps/archive/locale/pl/LC_MESSAGES/django.po index 0216929..3cdd29f 100644 --- a/apps/archive/locale/pl/LC_MESSAGES/django.po +++ b/apps/archive/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-20 13:19+0200\n" -"PO-Revision-Date: 2011-10-20 13:22+0100\n" +"POT-Creation-Date: 2011-10-26 12:43+0200\n" +"PO-Revision-Date: 2011-10-26 12:44+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -136,6 +136,10 @@ msgstr "Uaktualnij tagi" msgid "Commit" msgstr "Zatwierdź" +#: templates/archive/file_managed.html:103 +msgid "Remove to archive" +msgstr "Usuń do archiwum" + #: templates/archive/file_new.html:8 msgid "Move to archive" msgstr "Przenieś do archiwum" diff --git a/apps/archive/templates/archive/file_managed.html b/apps/archive/templates/archive/file_managed.html index 92ee639..d43c97e 100755 --- a/apps/archive/templates/archive/file_managed.html +++ b/apps/archive/templates/archive/file_managed.html @@ -94,5 +94,15 @@ Last modified: {{ audiobook.modified }} +
+ + + +
+ {% csrf_token %} + +
+ + {% endblock %} diff --git a/apps/archive/templates/archive/list_new.html b/apps/archive/templates/archive/list_new.html index c837cfd..459593b 100644 --- a/apps/archive/templates/archive/list_new.html +++ b/apps/archive/templates/archive/list_new.html @@ -16,7 +16,7 @@ {% block file-list %} {% for file in objects %}
  • - {{ file }} + {{ file }}
  • {% endfor %} {% endblock %} diff --git a/apps/archive/templates/archive/list_unmanaged.html b/apps/archive/templates/archive/list_unmanaged.html index 96e45d3..6b7486b 100755 --- a/apps/archive/templates/archive/list_unmanaged.html +++ b/apps/archive/templates/archive/list_unmanaged.html @@ -13,7 +13,7 @@ {% block file-list %} {% for file in objects %}
  • - {{ file }} + {{ file }}
  • {% endfor %} {% endblock %} diff --git a/apps/archive/templatetags/tags.py b/apps/archive/templatetags/tags.py index 25389ef..1067a4d 100755 --- a/apps/archive/templatetags/tags.py +++ b/apps/archive/templatetags/tags.py @@ -4,7 +4,13 @@ register = template.Library() @register.inclusion_tag('archive/tags/multiple_tags_table.html') def multiple_tags_table(tags, table=True): - return locals() + new_tags = {} + for k, v in tags.items(): + if isinstance(v, list): + new_tags[k] = v + else: + new_tags[k] = [v] + return {"tags": new_tags, "table": table} @register.inclusion_tag('archive/tags/tags_table.html') diff --git a/apps/archive/urls.py b/apps/archive/urls.py index 29552a2..3889949 100644 --- a/apps/archive/urls.py +++ b/apps/archive/urls.py @@ -13,6 +13,7 @@ urlpatterns = patterns('', url(r'^file/(\d+)/$', 'archive.views.file_managed', name="file"), url(r'^publish/(\d+)/$', 'archive.views.publish', name="publish"), url(r'^cancel/(\d+)/$', 'archive.views.cancel_publishing', name="cancel_publishing"), + url(r'^remove_to_archive/(\d+)/$', 'archive.views.remove_to_archive', name="remove_to_archive"), url(r'^unmanaged/$', 'archive.views.list_unmanaged', name="list_unmanaged"), url(r'^unmanaged/(.+)/$', 'archive.views.file_unmanaged', name="file_unmanaged"), diff --git a/apps/archive/views.py b/apps/archive/views.py index 7a22232..59239d2 100644 --- a/apps/archive/views.py +++ b/apps/archive/views.py @@ -95,6 +95,34 @@ def move_to_archive(request, filename): return redirect(list_new) +@require_POST +@permission_required('archive.change_audiobook') +def remove_to_archive(request, aid): + """ move a managed file to the unmanaged files dir """ + + audiobook = get_object_or_404(models.Audiobook, id=aid) + old_path = audiobook.source_file.path + new_path = os.path.join(settings.UNMANAGED_PATH, + str(audiobook.source_file)[len(settings.FILES_SAVE_PATH):].lstrip('/')) + new_dir = os.path.split(new_path)[0] + if not os.path.isdir(new_dir): + os.makedirs(new_dir) + + if not os.path.isfile(old_path): + raise Http404 + + try: + os.link(old_path, new_path) + except OSError: + # destination file exists, don't overwrite it + # TODO: this should probably be more informative + return redirect(file_new, filename) + else: + os.unlink(old_path) + audiobook.delete() + + return redirect(list_unmanaged) + @require_POST @permission_required('archive.change_audiobook') def move_to_new(request, filename):