From c175a7540d20336179dfd453183bfe69e6f5827e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 11 Jul 2012 15:53:46 +0200 Subject: [PATCH] fixes #2136: allow converting without publication --- apps/archive/constants.py | 0 apps/archive/forms.py | 0 apps/archive/locale/pl/LC_MESSAGES/django.mo | Bin 2652 -> 3268 bytes apps/archive/locale/pl/LC_MESSAGES/django.po | 52 +++++++++++++++--- apps/archive/settings.py | 0 apps/archive/tasks.py | 12 ++-- .../templates/archive/file_managed.html | 50 ++++++++++++----- apps/archive/urls.py | 1 + apps/archive/utils.py | 0 apps/archive/views.py | 6 +- requirements.txt | 2 +- 11 files changed, 93 insertions(+), 30 deletions(-) mode change 100755 => 100644 apps/archive/constants.py mode change 100755 => 100644 apps/archive/forms.py mode change 100755 => 100644 apps/archive/settings.py mode change 100755 => 100644 apps/archive/tasks.py mode change 100755 => 100644 apps/archive/utils.py diff --git a/apps/archive/constants.py b/apps/archive/constants.py old mode 100755 new mode 100644 diff --git a/apps/archive/forms.py b/apps/archive/forms.py old mode 100755 new mode 100644 diff --git a/apps/archive/locale/pl/LC_MESSAGES/django.mo b/apps/archive/locale/pl/LC_MESSAGES/django.mo index b2b15bdd955320bd900f0fad190e358a07baa84a..319973adffc38969c8ba1073c19a61900b2e158a 100644 GIT binary patch delta 1624 zcma)*O=whC6vyv$#+Vr6M`E?nwq9e=8k?yzX{=3aDSnVHOiU0(#1dwbXXYj0y)yG+ zOrQ=FK~YLer|qJUZrtfIih?c_D&o>*Km<{!sGx3??)?4V+%z={@$%05-Fx17=j+~k zXT{&m<-3ik-woq4)?K<#QWhQ;+rU*kP4Ke(@>dCK?S@7<=~d%ZKt1s_2?hNmGGro zFTq&$t9hX^El`0s!9}ngDzUGnC%)-oLf1^6GdKWwOpccfeW*Z1NRj3^l%o^yI@|R# zY+&6-6xsK~4p@LH!fVck?u|K(^m3I*(ei{U}I3VKkL{Q&vboPpZA zKcE7ghjM(=eV=iB0F}^FxC}19sq9xmC6tAVw`1`@b&vKq#XhJ&-$4Z~z_?PVipoxZ z0;(gwy6=BN1v(40=NFv*3QSbiC7a6cpjBvDeS+w|eT3);E4A5SnKaEV9F?ld#FAs-+bA65~!LDP?sRce;{wXSk8In}i@432um$d3C_AsmbB_hb1{zf|yp zA+swS4@Se>pzZE$w@3U@FFmK)J2YeugvGpHs(z{TrM}wi%*?F4E#ykU#>nP9FR(*i z;1zR`H)tokC|x;|+S=U{{uj@w%{;&J*KhK8EwwG_4R%gHOXU*{*|sg8w`DRm)6v})LS(#op zv4QW|$*>gVZv1G6z0%~sq-Vz`;@ZRUTriQYoUQ$KUk_Gc-02Z%X>9CZ&inlJTljrc R`$favIiF$YbW2@l;uXan^aTI_ delta 1036 zcmZA0F-#Lt9LMqhXw_TzVqV>n=T6Pxim4qyoLSdP!J4M#AD1$X@|R&r`Z4m5Bc znbVd~2|uAGSV1M;z%Xv167ORKkFXj~umLN{qWL;e(i`>!|VDsQdO%i4Ks>ezVg&$GAe3J(9%8Z)=RwfKBYh zUDQgd2qrLzT45eF!AsPGjk)WuQHf`q^H|IIdu+rns0ZCaN^X0|W{2zwn&=M)*YF?K zW0as0wV_JgjhZNjD($Gd{>nLtN;rj8xPZEU36*dI*=(1cDtqA055v@7iT)CZp-%K< z6{sh!N5z{^D@?lUX;h*tYQkqOK7>^Eta^F?RZaJ4t{Qp=T}|JYzO{RL|8*R+(zUWA zT}`XLLDyfQid=5(1nyi4ws77_*E`oAp^Dz7vo>p{YXMq}Dy2V7-^ATV>~7KB-^S7T zJC`b*npUV^NR|2DSg4sl5m@ktgIRwy*y9g|`bzIY!(J@am3q*X&LmRlhrJp9S6SnQ bNMEV8{HNzXj%54~k*EHXXn$!sI^dlG;44\n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -127,24 +127,62 @@ msgstr "Czeka na publikację" msgid "Cancel publishing" msgstr "Anuluj publikację" -#: templates/archive/file_managed.html:50 +#: templates/archive/file_managed.html:51 msgid "Publish" msgstr "Opublikuj" -#: templates/archive/file_managed.html:79 +#: templates/archive/file_managed.html:57 +msgid "Convert without publishing" +msgstr "Konwertuj bez publikacji" + +#: templates/archive/file_managed.html:67 +msgid "MP3 file" +msgstr "Plik MP3" + +#: templates/archive/file_managed.html:68 +msgid "Download MP3 file." +msgstr "Pobierz plik MP3." + +#: templates/archive/file_managed.html:70 +#: templates/archive/file_managed.html:84 +msgid "Published:" +msgstr "Opublikowano:" + +#: templates/archive/file_managed.html:73 +#: templates/archive/file_managed.html:87 +msgid "Not published yet." +msgstr "Nie opublikowane." + +#: templates/archive/file_managed.html:76 +msgid "MP3 file hasn't been generated yet." +msgstr "Plik MP3 nie został jeszcze wygenerowany." + +#: templates/archive/file_managed.html:81 +msgid "Ogg Vorbis file" +msgstr "Plik Ogg Vorbis" + +#: templates/archive/file_managed.html:82 +msgid "Download Ogg Vorbis file." +msgstr "Pobierz plik Ogg Vorbis." + +#: templates/archive/file_managed.html:90 +msgid "Ogg Vorbis file hasn't been generated yet." +msgstr "Plik Ogg Vorbis nie został jeszcze wygenerowany." + +#: templates/archive/file_managed.html:101 msgid "Update tags" msgstr "Uaktualnij tagi" -#: templates/archive/file_managed.html:91 +#: templates/archive/file_managed.html:113 #: templates/archive/file_new.html:19 msgid "Commit" msgstr "Zatwierdź" -#: templates/archive/file_managed.html:102 +#: templates/archive/file_managed.html:124 msgid "Are you sure you want to move this audiobook to archive?" msgstr "Czy na pewno chcesz przenieść ten plik to archiwum?" -#: templates/archive/file_managed.html:104 +#: templates/archive/file_managed.html:126 msgid "Remove to archive" msgstr "Usuń do archiwum" diff --git a/apps/archive/settings.py b/apps/archive/settings.py old mode 100755 new mode 100644 diff --git a/apps/archive/tasks.py b/apps/archive/tasks.py old mode 100755 new mode 100644 index bbabe6c..ae73930 --- a/apps/archive/tasks.py +++ b/apps/archive/tasks.py @@ -91,7 +91,7 @@ class AudioFormatTask(Task): except SystemExit, e: raise cls.RemoteOperationError - def run(self, aid): + def run(self, aid, publish=True): aid = int(aid) audiobook = Audiobook.objects.get(id=aid) self.set_status(aid, status.ENCODING) @@ -110,11 +110,13 @@ class AudioFormatTask(Task): self.set_status(aid, status.TAGGING) self.set_tags(audiobook, out_file.name) self.set_status(aid, status.SENDING) - - self.put(audiobook, out_file.name) - self.save(audiobook, out_file.name) - self.published(aid) + + if publish: + self.put(audiobook, out_file.name) + self.published(aid) + else: + self.set_status(aid, None) def on_failure(self, exc, task_id, args, kwargs, einfo): aid = (args[0], kwargs.get('aid'))[0] diff --git a/apps/archive/templates/archive/file_managed.html b/apps/archive/templates/archive/file_managed.html index db8e4f6..5a54adb 100755 --- a/apps/archive/templates/archive/file_managed.html +++ b/apps/archive/templates/archive/file_managed.html @@ -42,30 +42,52 @@ {% else %} -
{% tags_table audiobook.new_publish_tags 0 %} + + + {% csrf_token %} + + + + {% if not audiobook.mp3_published or not audiobook.ogg_published %} + + {% csrf_token %} + + + {% endif %} + +
- {% csrf_token %} -
- {% endif %}
-{% if audiobook.mp3_published %} -

Published MP3

- {{ audiobook.mp3_published }} - {% tags_table audiobook.mp3_published_tags.tags %} -{% else %}

MP3 file hasn't been published yet.

+{% if audiobook.mp3_file %} +

{% trans "MP3 file" %}

+

{% trans "Download MP3 file." %}

+ {% if audiobook.mp3_published %} +

{% trans "Published:" %} {{ audiobook.mp3_published }}

+ {% tags_table audiobook.mp3_published_tags.tags %} + {% else %} +

{% trans "Not published yet." %}

+ {% endif %} +{% else %} +

{% trans "MP3 file hasn't been generated yet." %}

{% endif %}
-{% if audiobook.ogg_published %} -

Published Ogg Vorbis

- {{ audiobook.ogg_published }} - {% tags_table audiobook.ogg_published_tags.tags %} -{% else %}Ogg Vorbis file hasn't been published yet. +{% if audiobook.ogg_file %} +

{% trans "Ogg Vorbis file" %}

+

{% trans "Download Ogg Vorbis file." %}

+ {% if audiobook.ogg_published %} +

{% trans "Published:" %} {{ audiobook.ogg_published }}

+ {% tags_table audiobook.ogg_published_tags.tags %} + {% else %} +

{% trans "Not published yet." %}

+ {% endif %} +{% else %} +

{% trans "Ogg Vorbis file hasn't been generated yet." %}

{% endif %} diff --git a/apps/archive/urls.py b/apps/archive/urls.py index 3889949..3f7839a 100644 --- a/apps/archive/urls.py +++ b/apps/archive/urls.py @@ -12,6 +12,7 @@ urlpatterns = patterns('', url(r'^published/$', 'archive.views.list_published', name="list_published"), url(r'^file/(\d+)/$', 'archive.views.file_managed', name="file"), url(r'^publish/(\d+)/$', 'archive.views.publish', name="publish"), + url(r'^convert/(\d+)/$', 'archive.views.publish', {'publish': False}, name="convert"), 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"), diff --git a/apps/archive/utils.py b/apps/archive/utils.py old mode 100755 new mode 100644 diff --git a/apps/archive/views.py b/apps/archive/views.py index 59239d2..369e7e4 100644 --- a/apps/archive/views.py +++ b/apps/archive/views.py @@ -151,7 +151,7 @@ def move_to_new(request, filename): @require_POST @permission_required('archive.change_audiobook') -def publish(request, aid): +def publish(request, aid, publish=True): """ mark file for publishing """ audiobook = get_object_or_404(models.Audiobook, id=aid) tags = { @@ -164,8 +164,8 @@ def publish(request, aid): audiobook.mp3_status = audiobook.ogg_status = status.WAITING audiobook.save() # isn't there a race here? - audiobook.mp3_task = tasks.Mp3Task.delay(aid).task_id - audiobook.ogg_task = tasks.OggTask.delay(aid).task_id + audiobook.mp3_task = tasks.Mp3Task.delay(aid, publish).task_id + audiobook.ogg_task = tasks.OggTask.delay(aid, publish).task_id audiobook.save() return redirect(file_managed, aid) diff --git a/requirements.txt b/requirements.txt index 034bd1a..66a8fd8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -django>=1.3 +django>=1.3,<1.4 django-jsonfield South>=0.7 django-cas -- 2.20.1