django-cas-ng==4.1.1
django-bootstrap4==1.1.1
django-pglocks==1.0.4
+fnp-django-pagination==2.2.4
celery[redis]==4.4.2
from django.utils.translation import gettext_lazy as _
+
class status:
- QUEUED = 1
- WAITING = 10
+ WAITING = 1
+ QUEUED = 10
ENCODING = 20
TAGGING = 30
CONVERTING_AUDIO = 40
SETTING_THUMBNAIL = 110
choices = [
- (QUEUED, _('Queued')),
(WAITING, _('Waiting')),
+ (QUEUED, _("Queued")),
(ENCODING, _('Encoding')),
(TAGGING, _('Tagging')),
(CONVERTING_AUDIO, _('Converting audio')),
--- /dev/null
+{% extends "archive/list.html" %}
+{% load i18n %}
+{% load pagination_tags %}
+
+
+{% block menu-active-audiobooks %}active{% endblock %}
+
+
+{% block file-list-title %}
+ {% trans "Audiobooks" %}
+{% endblock %}
+
+
+{% block file-list-info %}
+{% endblock %}
+
+{% block file-list-wrapper %}
+ {% autopaginate object_list 50 %}
+ {{ block.super }}
+ {% paginate %}
+{% endblock %}
+
+
+{% block file-list %}
+ <thead>
+ <tr>
+ <th>Slug</th>
+ <th>{% trans "Title" %}</th>
+ <th>{% trans "YouTube volume" %}</th>
+ <th>MP3</th>
+ <th>Ogg</th>
+ <th>YouTube</th>
+ </tr>
+ </thead>
+ {% for audiobook in object_list %}
+ <tr>
+ <td>
+ {% if audiobook.slug %}
+ <a href="{% url "book" audiobook.slug %}">{{ audiobook.slug }}</a>
+ {% endif %}
+ <td>
+ <a href='{% url "file" audiobook.id %}'>{{ audiobook }}</a>
+ </td>
+ <td>
+ {{ audiobook.youtube_volume }}
+ </td>
+ <td>
+ {% if audiobook.mp3_status %}
+ <span class="badge badge-info">
+ MP3:
+ {{ audiobook.get_mp3_status_display }}
+ </span>
+ {% endif %}
+ </td>
+ <td>
+ {% if audiobooks.ogg_status_display %}
+ <span class="badge badge-info">
+ Ogg:
+ {{ audiobook.get_ogg_status_display }}
+ </span>
+ {% endif %}
+ </td>
+ <td>
+ {% if audiobooks.youtube_status %}
+ <span class="badge badge-info">
+ YT:
+ {{ audiobook.get_youtube_status_display }}
+ </span>
+ {% endif %}
+ </td>
+ </tr>
+ {% endfor %}
+{% endblock %}
{% block repo-zones-nav %}
<ul class="nav nav-pills">
- <li class="nav-item"><a class="nav-link{% if division == "new" %} active{% endif %}" href="{% url 'list_new' %}">{% trans "New" %}</a></li>
- <li class="nav-item"><a class="nav-link{% if division == "unpublished" %} active{% endif %}" href="{% url 'list_unpublished' %}">{% trans "Unpublished" %}</a></li>
- <li class="nav-item"><a class="nav-link{% if division == "publishing" %} active{% endif %}" href="{% url 'list_publishing' %}">{% trans "Publishing" %}</a></li>
- <li class="nav-item"><a class="nav-link{% if division == "published" %} active{% endif %}" href="{% url 'list_published' %}">{% trans "Published" %}</a></li>
- <li class="nav-item"><a class="nav-link{% if division == "unmanaged" %} active{% endif %}" href="{% url 'list_unmanaged' %}">{% trans "Archive" %}</a></li>
+ <li class="nav-item"><a class="nav-link {% block menu-active-audiobooks %}{% endblock %}" href="{% url "list_managed" %}">{% trans "Audiobooks" %}</a></li>
+ <li class="nav-item"><a class="nav-link {% block menu-active-publishing %}{% endblock %}" href="{% url 'list_publishing' %}">{% trans "Publishing" %}</a></li>
+ <li class="nav-item"><a class="nav-link {% block menu-active-new %}{% endblock %}" href="{% url 'list_new' %}">{% trans "New" %}</a></li>
+ <li class="nav-item"><a class="nav-link {% block menu-active-unmanaged %}{% endblock %}" href="{% url 'list_unmanaged' %}">{% trans "Archive" %}</a></li>
</ul>
<ul class="nav">
{% extends "archive/base.html" %}
+{% load i18n %}
+{% load tags %}
+
+
+{% block menu-active-audiobooks %}active{% endblock %}
+
{% block content %}
<div class="card mt-4">
<div class="card-header">
- <h2>Audiobooki</h2>
+ <h2>{{ object_list.0.book.title }}</h2>
</div>
<div class="card-body">
<table class="table">
<thead>
<tr>
- <th>?x</th>
+ <th>{% trans "Index" %}</th>
+ <th>{% trans "Title" %}</th>
+ <th>MP3</th>
+ <th>Ogg</th>
+ <th colspan="3">YouTube</th>
</tr>
</thead>
<tbody>
- {% for audiobook in object_list %}
- <tr>
- <td>{{ audiobook.index }}</td>
- <td>
- <a href="{% url 'file' audiobook.id %}">
- {{ audiobook.title }}
- </a>
- </td>
- </tr>
- {% endfor %}
+ {% with volumes=object_list.0.youtube_volume_count %}
+ {% for audiobook in object_list %}
+ <tr>
+ <td>{{ audiobook.index }}</td>
+ <td>
+ <a href="{% url 'file' audiobook.id %}">
+ {% if audiobook.part_name %}
+ {{ audiobook.part_name }}
+ {% else %}
+ <em class="text-warning" title="ddd">
+ ({{ audiobook }})
+ </em>
+ {% endif %}
+ </a>
+ </td>
+ <td>{% status audiobook "mp3" %}</td>
+ <td>{% status audiobook "ogg" %}</td>
+ {% ifchanged audiobook.youtube_volume_index %}
+ <td>
+ {{ audiobook.youtube_volume_index }}/{{ volumes }}
+ </td>
+ <td>
+ {{ audiobook.youtube_volume }}
+ </td>
+ <td>
+ {% status audiobook "youtube" %}
+ </td>
+ {% else %}
+ <td>
+ –
+ </td>
+ <td>
+ <span class="text-secondary">
+ {{ audiobook.youtube_volume }}
+ </span>
+ </td>
+ <td>
+ </td>
+ {% endifchanged %}
+ </tr>
+ {% endfor %}
+ {% endwith %}
</tbody>
</table>
</div>
{% load tags %}
{% load bootstrap4 %}
-{% block content %}
+{% block menu-active-audiobooks %}active{% endblock %}
+
+
+{% block content %}
{% for alert in alerts %}
{% extends "archive/base.html" %}
{% load i18n tags bootstrap4 %}
+
+{% block menu-active-new %}active{% endblock %}
+
+
{% block content %}
<div class="card mt-4">
{% load i18n %}
{% load tags %}
+
+{% block menu-active-unmanaged %}active{% endblock %}
+
+
{% block messages %}
{% if err_exists %}
<p>{% trans "File with same name already exists!" %}</p>
{% block file-list-info %}{% endblock %}
</div>
{% block file-list-wrapper %}
- <table class="table">
- {% block file-list %}{% endblock %}
- </table>
+ <table class="table">
+ {% block file-list %}{% endblock %}
+ </table>
{% endblock %}
</div>
</div>
{% load i18n %}
+{% block menu-active-new %}active{% endblock %}
+
+
+
{% block file-list-title %}
{% trans "New audiobooks" %}
{% endblock %}
+++ /dev/null
-{% extends "archive/list.html" %}
-{% load i18n %}
-
-
-{% block file-list-title %}
- {% trans "Published audiobooks" %}
-{% endblock %}
-
-
-{% block file-list-info %}
-{% endblock %}
-
-
-{% block file-list %}
- {% for file in objects %}
- <tr>
- <td>
- <a href='{% url "file" file.id %}'>{{ file }}</a>
- </td>
- </tr>
- {% endfor %}
-{% endblock %}
{% load i18n %}
+{% block menu-active-publishing %}active{% endblock %}
+
+
{% block file-list-title %}
{% trans "Audiobooks being published" %}
{% endblock %}
{% extends "archive/list.html" %}
{% load i18n %}
+
+{% block menu-active-unmanaged %}active{% endblock %}
+
+
{% block file-list-title %}
{% trans "Unmanaged archive" %}
{% endblock %}
+++ /dev/null
-{% extends "archive/list.html" %}
-{% load i18n %}
-
-
-{% block file-list-title %}
- {% trans "Unpublished audiobooks" %}
-{% endblock %}
-
-
-{% block file-list-info %}
-{% endblock %}
-
-
-{% block file-list %}
- {% for file in objects %}
- <tr>
- <td>
- <a href='{% url "file" file.id %}'>{{ file }}</a>
- </td>
- <td>
- {% if file.mp3_published %}
- <span class="text-success" title="{{ file.mp3_published }}">MP3</span>
- {% else %}
- {% if file.mp3_status %}
- <span class="text-warning" title="{{ file.get_mp3_status_display }}">MP3</span>
- {% endif %}
- {% endif %}
- </td>
- <td>
- {% if file.ogg_published %}
- <span class="text-success" title="{{ file.ogg_published }}">Ogg</span>
- {% else %}
- {% if file.ogg_status %}
- <span class="text-warning" title="{{ file.get_ogg_status_display }}">Ogg</span>
- {% endif %}
- {% endif %}
- </td>
- </tr>
- {% endfor %}
-{% endblock %}
--- /dev/null
+{% load i18n %}
+
+{% if published %}
+ {% if link %}
+ <a href="{{ link }}" target="_blank">
+ {% endif %}
+ <span class="badge badge-success" title="{{ format }}: {% trans "Published at" %} {{ published }} %}">
+ {% trans "OK" %}
+ </span>
+ {% if link %}
+ </a>
+ {% endif %}
+{% elif status %}
+ <span class="badge badge-info">
+ {{ status }}
+ </span>
+{% else %}
+ <span class="badge badge-secondary">
+ ––
+ </span>
+{% endif %}
--- /dev/null
+{% if is_paginated %}
+{% load i18n %}
+<nav aria-label="{% trans 'Pagination' %}" class="mt-4">
+ <ul class="pagination justify-content-center">
+ {% if page_obj.has_previous %}
+ <li class="page-item">
+ <a href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}" class="page-link">
+ {% trans "previous" %}
+ </a>
+ </li>
+ {% else %}
+ <li class="page-item disabled">
+ <span class="page-link">
+ {% trans "previous" %}
+ </span>
+ </li>
+ {% endif %}
+
+ {% for page in pages %}
+ {% if page %}
+ {% if page == page_obj.number %}
+ <li class="page-item active">
+ <span class="page-link">
+ {{ page }}
+ </span>
+ </li>
+ {% else %}
+ <li class="page-item">
+ <a href="?page={{ page }}{{ getvars }}{{ hashtag }}" class="page-link">
+ {{ page }}
+ </a>
+ </li>
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+ {% if page_obj.has_next %}
+ <li class="page-item">
+ <a href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}" class="page-link">
+ {% trans "next" %}
+ </a>
+ </li>
+ {% else %}
+ <li class="page-item disabled">
+ <span class="page-link">
+ {% trans "next" %}
+ </span>
+ </li>
+ {% endif %}
+ </ul>
+</nav>
+
+{% endif %}
register = template.Library()
+
@register.inclusion_tag('archive/tags/multiple_tags_table.html')
def multiple_tags_table(tags, table=True):
new_tags = {}
if tags is None:
tags = {}
return locals()
+
+
+@register.inclusion_tag("archive/status.html")
+def status(audiobook, format):
+ if format == "youtube" and audiobook.youtube_id:
+ link = f"https://youtu.be/{audiobook.youtube_id}"
+ else:
+ link = None
+ return {
+ "published": getattr(audiobook, f"{format}_published"),
+ "status": getattr(audiobook, f"get_{format}_status_display")(),
+ "format": format,
+ "link": link,
+ }
from . import views
urlpatterns = [
- url(r'^$', RedirectView.as_view(url='new/')),
-
+ path("", views.AudiobookList.as_view(), name="list_managed"),
url(r'^new/$', views.list_new, name="list_new"),
url(r'^new/(.+)/$', views.file_new, name="file_new"),
url(r'^move_to_archive/(.+)/$', views.move_to_archive, name="move_to_archive"),
-
- url(r'^unpublished/$', views.list_unpublished, name="list_unpublished"),
url(r'^publishing/$', views.list_publishing, name="list_publishing"),
- url(r'^published/$', views.list_published, name="list_published"),
path('book/<slug:slug>/', views.BookView.as_view(), name="book"),
url(r'^file/(\d+)/$', views.file_managed, name="file"),
url(r'^publish/(\d+)/$', views.publish, name="publish"),
url(r'^download/(\d+)\.(mp3|ogg|mkv)$', views.download, name="download"),
url(r'^cancel/(\d+)/$', views.cancel_publishing, name="cancel_publishing"),
url(r'^remove_to_archive/(\d+)/$', views.remove_to_archive, name="remove_to_archive"),
-
url(r'^unmanaged/$', views.list_unmanaged, name="list_unmanaged"),
url(r'^unmanaged/(.+)/$', views.file_unmanaged, name="file_unmanaged"),
url(r'^move_to_new/(.+)/$', views.move_to_new, name="move_to_new"),
def list_new(request):
- division = 'new'
-
path = settings.NEW_PATH
objects = sorted(all_files(path))
return render(request, "archive/list_new.html", locals())
@permission_required('archive.change_audiobook')
def file_new(request, filename):
- division = 'new'
-
filepath = filename
root_filepath = os.path.join(settings.NEW_PATH, filename)
if request.POST:
return response
-def list_unpublished(request):
- division = 'unpublished'
-
- objects = models.Audiobook.objects.filter(Q(mp3_published=None) | Q(ogg_published=None))
- return render(request, "archive/list_unpublished.html", locals())
-
-
def list_publishing(request):
- division = 'publishing'
-
objects = models.Audiobook.objects.exclude(
mp3_status=None, ogg_status=None, youtube_status=None
).order_by("youtube_queued", "title")
return render(request, "archive/list_publishing.html", locals())
-def list_published(request):
- division = 'published'
-
- objects = models.Audiobook.objects.exclude(Q(mp3_published=None) | Q(ogg_published=None))
- return render(request, "archive/list_published.html", locals())
+class AudiobookList(ListView):
+ queryset = models.Audiobook.objects.all()
@permission_required('archive.change_audiobook')
except IOError:
raise Http404
- division = 'published' if audiobook.published() else 'unpublished'
path = audiobook.source_file.path[len(settings.FILES_PATH):].lstrip('/')
# for tags update
def list_unmanaged(request):
- division = 'unmanaged'
-
objects = sorted(all_files(settings.UNMANAGED_PATH))
return render(request, "archive/list_unmanaged.html", locals())
def file_unmanaged(request, filename):
- division = 'unmanaged'
-
tags = mutagen.File(os.path.join(settings.UNMANAGED_PATH, filename.encode('utf-8')))
if not tags:
tags = {}
template_name = 'archive/book.html'
def get_queryset(self):
- return models.Audiobook.objects.filter(slug=self.kwargs['slug'])
+ return models.Audiobook.objects.filter(slug=self.kwargs["slug"]).order_by(
+ "index"
+ )
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_cas_ng.middleware.CASMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
+ "fnp_django_pagination.middleware.PaginationMiddleware",
)
AUTHENTICATION_BACKENDS = (
# 'django.contrib.admindocs',
'bootstrap4',
'django_cas_ng',
-
'apiclient',
'archive',
'youtube',
+ "fnp_django_pagination",
)
# A sample logging configuration. The only tangible logging