class AudiobookAdmin(admin.ModelAdmin):
- list_display = ["title", "slug", "index", "part_name", "license", "youtube_volume"]
+ list_display = ["title", "slug", "index", "part_name", "duration", "license", "youtube_volume"]
list_filter = ["license"]
search_fields = ["title", "slug", "part_name", "youtube_volume"]
list_editable = ["youtube_volume"]
+ readonly_fields = ['duration']
admin.site.register(Audiobook, AudiobookAdmin)
--- /dev/null
+# Generated by Django 3.1.2 on 2021-01-21 12:49
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archive', '0018_auto_20200703_1718'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='audiobook',
+ name='duration',
+ field=models.FloatField(editable=False, null=True),
+ ),
+ migrations.AlterField(
+ model_name='audiobook',
+ name='mp3_status',
+ field=models.SmallIntegerField(choices=[(5, 'Queued'), (10, 'Waiting'), (20, 'Encoding'), (30, 'Tagging'), (40, 'Converting audio'), (50, 'Converting video'), (60, 'Assembling audio'), (70, 'Assembling video'), (80, 'Joining audio and video'), (100, 'Sending'), (110, 'Setting thumbnail')], editable=False, null=True),
+ ),
+ migrations.AlterField(
+ model_name='audiobook',
+ name='ogg_status',
+ field=models.SmallIntegerField(choices=[(5, 'Queued'), (10, 'Waiting'), (20, 'Encoding'), (30, 'Tagging'), (40, 'Converting audio'), (50, 'Converting video'), (60, 'Assembling audio'), (70, 'Assembling video'), (80, 'Joining audio and video'), (100, 'Sending'), (110, 'Setting thumbnail')], editable=False, null=True),
+ ),
+ migrations.AlterField(
+ model_name='audiobook',
+ name='youtube_status',
+ field=models.SmallIntegerField(choices=[(5, 'Queued'), (10, 'Waiting'), (20, 'Encoding'), (30, 'Tagging'), (40, 'Converting audio'), (50, 'Converting video'), (60, 'Assembling audio'), (70, 'Assembling video'), (80, 'Joining audio and video'), (100, 'Sending'), (110, 'Setting thumbnail')], editable=False, null=True),
+ ),
+ ]
source_file = models.FileField(upload_to=source_upload_to, max_length=255,
verbose_name=_('source file'), editable=False)
source_sha1 = models.CharField(max_length=40, editable=False)
+ duration = models.FloatField(null=True, editable=False)
title = models.CharField(max_length=255, verbose_name=_('title'))
part_name = models.CharField(max_length=255, verbose_name=_('part name'), help_text=_('eg. chapter in a novel'),
<div class="col-xl-7">
<div class="card mt-4">
<div class="card-header">
- <h2><a href="{% url 'book' audiobook.slug %}" %}">{{ audiobook.title }}</a></h2>
+ <h2>{% if audiobook.slug %}<a href="{% url 'book' audiobook.slug %}" %}">{% endif %}{{ audiobook.title }}{% if audiobook.slug %}</a>{% endif %}</h2>
</div>
<div class="card-body">
<form method='post' action='.'>
</div>
<div class="card-body">
<p>Last modified: {{ audiobook.modified }}</p>
- <p>Plik źródłowy: <a href='{% url "download" audiobook.id %}'>{{ path }}</a>
+ <p>Plik źródłowy: <a href='{{ audiobook.source_file.url }}'>{{ path }}</a>
(sha1: <tt>{{ audiobook.source_sha1 }}</tt>).
</p>
{% multiple_tags_table tags %}