From a3bff3a1ab98b4d4334901b906d602a5d1f0417a Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 1 Aug 2013 11:27:21 +0200 Subject: [PATCH] Disable login_required. --- apps/archive/tasks.py | 5 ++++- apps/archive/templates/404.html | 6 ++++++ apps/archive/templates/500.html | 1 + apps/archive/templates/archive/base.html | 10 ++++++++-- apps/archive/templates/archive/file_managed.html | 8 ++++++-- apps/archive/templatetags/tags.py | 2 ++ apps/archive/views.py | 8 +------- 7 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 apps/archive/templates/404.html create mode 100644 apps/archive/templates/500.html diff --git a/apps/archive/tasks.py b/apps/archive/tasks.py index ae73930..1b2be74 100644 --- a/apps/archive/tasks.py +++ b/apps/archive/tasks.py @@ -4,6 +4,7 @@ import mimetypes import os import os.path import pipes +import stat import subprocess from tempfile import NamedTemporaryFile from time import sleep @@ -58,6 +59,7 @@ class AudioFormatTask(Task): ExistingFile(file_name), save=False ) + os.chmod(getattr(audiobook, field).path, stat.S_IREAD|stat.S_IWRITE|stat.S_IRGRP|stat.S_IROTH) Audiobook.objects.filter(pk=audiobook.pk).update( **{field: getattr(audiobook, field)}) @@ -110,7 +112,6 @@ class AudioFormatTask(Task): self.set_status(aid, status.TAGGING) self.set_tags(audiobook, out_file.name) self.set_status(aid, status.SENDING) - self.save(audiobook, out_file.name) if publish: self.put(audiobook, out_file.name) @@ -118,6 +119,8 @@ class AudioFormatTask(Task): else: self.set_status(aid, None) + self.save(audiobook, out_file.name) + def on_failure(self, exc, task_id, args, kwargs, einfo): aid = (args[0], kwargs.get('aid'))[0] self.set_status(aid, None) diff --git a/apps/archive/templates/404.html b/apps/archive/templates/404.html new file mode 100644 index 0000000..467dacd --- /dev/null +++ b/apps/archive/templates/404.html @@ -0,0 +1,6 @@ +{% extends "archive/base.html" %} +{% block content %} +

Nie znaleziono strony.

+ +

Nie znaleziono żądanej strony.

+{% endblock %} diff --git a/apps/archive/templates/500.html b/apps/archive/templates/500.html new file mode 100644 index 0000000..b46280d --- /dev/null +++ b/apps/archive/templates/500.html @@ -0,0 +1 @@ +Błąd serwera. diff --git a/apps/archive/templates/archive/base.html b/apps/archive/templates/archive/base.html index 5d28312..575cf8e 100644 --- a/apps/archive/templates/archive/base.html +++ b/apps/archive/templates/archive/base.html @@ -10,10 +10,16 @@ {% if user.is_staff %} {% trans "Projects" %} {% endif %} - {% trans "Logout" %} + {% if user.is_authenticated %} + {% trans "Logout" %} + {% else %} + {% trans "Login" %} + {% endif %} {% if user.is_staff %} {% trans "Administration" %} {% endif %} - {{ user }} + {% if user.is_authenticated %} + {{ user }} + {% endif %}
{% endblock %} diff --git a/apps/archive/templates/archive/file_managed.html b/apps/archive/templates/archive/file_managed.html index 01847a6..58f45ef 100755 --- a/apps/archive/templates/archive/file_managed.html +++ b/apps/archive/templates/archive/file_managed.html @@ -68,7 +68,9 @@

{% trans "Download MP3 file." %}

{% if audiobook.mp3_published %}

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

- {% tags_table audiobook.mp3_published_tags.tags %} + {% if audiobook.mp3_published_tags.tags %} + {% tags_table audiobook.mp3_published_tags.tags %} + {% endif %} {% else %}

{% trans "Not published yet." %}

{% endif %} @@ -82,7 +84,9 @@

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

{% if audiobook.ogg_published %}

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

- {% tags_table audiobook.ogg_published_tags.tags %} + {% if audiobook.ogg_published_tags.tags %} + {% tags_table audiobook.ogg_published_tags.tags %} + {% endif %} {% else %}

{% trans "Not published yet." %}

{% endif %} diff --git a/apps/archive/templatetags/tags.py b/apps/archive/templatetags/tags.py index 479443b..8e208a6 100755 --- a/apps/archive/templatetags/tags.py +++ b/apps/archive/templatetags/tags.py @@ -16,4 +16,6 @@ def multiple_tags_table(tags, table=True): @register.inclusion_tag('archive/tags/tags_table.html') def tags_table(tags, table=True): + if tags is None: + tags = {} return locals() diff --git a/apps/archive/views.py b/apps/archive/views.py index e76da74..d40f633 100644 --- a/apps/archive/views.py +++ b/apps/archive/views.py @@ -7,7 +7,7 @@ from urllib import quote from archive import settings from django.contrib.auth import logout -from django.contrib.auth.decorators import login_required, permission_required +from django.contrib.auth.decorators import permission_required from django.core.urlresolvers import reverse from django.db.models import Q, Max from django.http import Http404, HttpResponse @@ -23,7 +23,6 @@ from archive import tasks from archive.utils import all_files -@login_required def list_new(request): division = 'new' @@ -200,7 +199,6 @@ def download(request, aid, which="source"): return response -@login_required def list_unpublished(request): division = 'unpublished' @@ -208,7 +206,6 @@ def list_unpublished(request): return render(request, "archive/list_unpublished.html", locals()) -@login_required def list_publishing(request): division = 'publishing' @@ -226,7 +223,6 @@ def list_publishing(request): return render(request, "archive/list_publishing.html", locals()) -@login_required def list_published(request): division = 'published' @@ -258,7 +254,6 @@ def file_managed(request, id): return render(request, "archive/file_managed.html", locals()) -@login_required def list_unmanaged(request): division = 'unmanaged' @@ -266,7 +261,6 @@ def list_unmanaged(request): return render(request, "archive/list_unmanaged.html", locals()) -@login_required def file_unmanaged(request, filename): division = 'unmanaged' -- 2.20.1