Commit 63870110 authored by Seb's avatar Seb
Browse files

Cleanup the edit template again a bit, start on the track formset

parent 26d0a91b
......@@ -41,7 +41,6 @@ def get_video_form(model):
# cause dubious results when multiple collections exist (e.g adding the
# document to the root collection where the user may not have permission) -
# and when only one collection exists, it will get hidden anyway.
print('collection not found')
fields = list(fields) + ['collection']
return modelform_factory(
......
......@@ -334,7 +334,7 @@ class AbstractTrack(models.Model):
help_text='A user-readable title of the text track.')
language = models.CharField(
max_length=50,
choices=[(k, v) for k, v in bcp47.languages.items()],
choices=[(v, k) for k, v in bcp47.languages.items()],
default='en', blank=True, help_text='Required if type is "Subtitle"', unique=True)
@property
......
......@@ -28,7 +28,7 @@
{% include "wagtailadmin/shared/header.html" with title=editing_str subtitle=video.title icon="media" %}
<div class="row row-flush nice-padding">
<div class="col5">
<div class="col6">
<form action="{% url 'wagtailvideos:edit' video.id %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<ul class="fields">
......@@ -48,8 +48,33 @@
</ul>
</form>
</div>
<div class="col5 divider-after">
<h2 class="label no-float u-text-transform-uppercase">{% trans "Video preview" %}</h2> {% video video controls style=max-width:100% %}
<div class="col6">
<div class='row'>
<div class='col10 divider-after'>
{% video video controls style=max-width:100%;width:100%;height:auto; %}
</div>
<div class='col2'>
<dl style='margin-top: 0'>
{% if video.thumbnail %}
<dt>{% trans "Thumbnail" %}</dt>
<dd><img src="{{ video.thumbnail.url }}" /></dd>
{% endif %}
<dt>{% trans "Filesize" %}</dt>
<dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd>
{% if video.duration %}
<dt>{% trans "Duration" %}</dt>
<dd>{{ video.formatted_duration }}</dd>
{% endif %}
{% if usage_count_enabled %}
<dt>{% trans "Usage" %}</dt>
<dd>
<a href="{{ video.usage_url }}">{% blocktrans count usage_count=video.get_usage.count %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
</dd>
{% endif %}
</dl>
</div>
</div>
<div class="row" style='margin-top: 2em;'>
{% if can_transcode %}
<h3 class="label no-float u-text-transform-uppercase">Transcodes</h3>
<p>If you wish to generate HTML5 compliant transcodes use the form below. This may take a while depending on the length of the video.</p>
......@@ -83,27 +108,7 @@
<br/><br/>
<span class='transcode-error'>Ffmpeg is not found on your server. Please install if you wish to transcode videos into an HTML5 video compliant format.</span>
{% endif %}
</div>
<div class="col2 ">
<dl>
{% if video.thumbnail %}
<dt>{% trans "Thumbnail" %}</dt>
<dd><img src="{{ video.thumbnail.url }}" /></dd>
{% endif %}
<dt>{% trans "Filesize" %}</dt>
<dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd>
{% if video.duration %}
<dt>{% trans "Duration" %}</dt>
<dd>{{ video.formatted_duration }}</dd>
{% usage_count_enabled as uc_enabled %}
{% if uc_enabled %}
<dt>{% trans "Usage" %}</dt>
<dd>
<a href="{{ video.usage_url }}">{% blocktrans count usage_count=video.get_usage.count %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
</dd>
{% endif %}
{% endif %}
</dl>
</div>
</div>
</div>
{% endblock %}
......@@ -11,7 +11,7 @@ from wagtail.admin import messages
from wagtail.admin.forms.search import SearchForm
from wagtail.core.models import Collection
from wagtail.search.backends import get_search_backends
from django.forms import modelformset_factory
from wagtailvideos import ffmpeg, get_video_model
from wagtailvideos.forms import VideoTranscodeAdminForm, get_video_form
from wagtailvideos.permissions import permission_policy
......@@ -121,6 +121,9 @@ def edit(request, video_id):
messages.button(reverse('wagtailvideos:delete', args=(video.id,)), _('Delete'))
])
Track = Video.get_track_model()
TrackFormset = modelformset_factory(Track, exclude=('video',))
return render(request, "wagtailvideos/videos/edit.html", {
'video': video,
'form': form,
......@@ -128,6 +131,7 @@ def edit(request, video_id):
'can_transcode': ffmpeg.installed(),
'transcodes': video.transcodes.all(),
'transcode_form': VideoTranscodeAdminForm(video=video),
'track_formset': TrackFormset(queryset=video.tracks.all()),
'user_can_delete': permission_policy.user_has_permission_for_instance(request.user, 'delete', video)
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment