Unverified Commit 5d07cbeb authored by Kevin Gutiérrez's avatar Kevin Gutiérrez Committed by GitHub
Browse files

Merge branch 'master' into patch-2

parents b0109bbf 155f7398
......@@ -24,7 +24,7 @@ class BaseVideoForm(BaseCollectionMemberForm):
self.fields['file'].required = 'file' not in self.initial or not self.initial['file']
# Callback to allow us to override the default form field for the image file field
# Callback to allow us to override the default form field for the video file field
def formfield_for_dbfield(db_field, **kwargs):
# Check if this is the file field
if db_field.name == 'file':
......@@ -75,7 +75,7 @@ class VideoTranscodeAdminForm(forms.Form):
GroupVideoPermissionFormSet = collection_member_permission_formset_factory(
Video,
[
('add_video', _("Add"), _("Add/edit images you own")),
('add_video', _("Add"), _("Add/edit videos you own")),
('change_video', _("Edit"), _("Edit any video")),
],
'wagtailvideos/permissions/includes/video_permissions_formset.html'
......
......@@ -188,6 +188,9 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
@classmethod
def get_track_listing_model(cls):
return cls.track_listing.related.related_model
def get_current_transcodes(self):
return self.transcodes.exclude(processing=True).filter(error_message__exact='')
def video_tag(self, attrs=None):
if attrs is None:
......@@ -197,7 +200,7 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
if self.thumbnail:
attrs['poster'] = self.thumbnail.url
transcodes = self.transcodes.exclude(processing=True).filter(error_message__exact='')
transcodes = self.get_current_transcodes()
sources = []
for transcode in transcodes:
sources.append("<source src='{0}' type='video/{1}' >".format(transcode.url, transcode.media_format.name))
......
......@@ -15,7 +15,7 @@
</li>
</ul>
</form>
<div data-video-thumb="{{ video.id }}" class='thumb icon icon-image hasthumb'>
<div data-video-thumb="{{ video.id }}" class='thumb icon icon-media hasthumb'>
{% if video.thumbnail %}
<img src="{{ video.thumbnail.url }}" />
{% endif %}
......
{% extends "wagtailadmin/base.html" %}
{% load i18n %}
{% block titletag %}{% trans "Add an image" %}{% endblock %}
{% block titletag %}{% trans "Add a video" %}{% endblock %}
{% block extra_js %}
{{ block.super }}
......
{% extends "wagtailadmin/base.html" %}
{% load wagtailvideos_tags %}
{% load i18n %}
{% block titletag %}{% trans "Delete image" %}{% endblock %}
{% block titletag %}{% trans "Delete video" %}{% endblock %}
{% block content %}
{% trans "Delete image" as del_str %}
{% include "wagtailadmin/shared/header.html" with title=del_str icon="image" %}
{% trans "Delete video" as del_str %}
{% include "wagtailadmin/shared/header.html" with title=del_str icon="media" %}
<div class="row row-flush nice-padding">
<div class="col6">
......
......@@ -40,10 +40,12 @@
{% else %}
{% include "wagtailadmin/shared/field_as_li.html" with li_classes="label-above label-uppercase" %}
{% endif %}
{% endfor %}
{% endfor %}
<li>
<input type="submit" class="button" value="{% trans 'Save' %}" /> {% if user_can_delete %}
<a href="{% url 'wagtailvideos:delete' video.id %}" class="button button-secondary no">{% trans "Delete video" %}</a> {% endif %}
<input type="submit" class="button" value="{% trans 'Save' %}" />
{% if user_can_delete %}
<a href="{% url 'wagtailvideos:delete' video.id %}" class="button button-secondary no">{% trans "Delete video" %}</a>
{% endif %}
</li>
</ul>
</form>
......@@ -76,51 +78,57 @@
</div>
</div>
<div class="row" style='margin-top: 2em;'>
{% if can_transcode %}
<h2 class="u-text-transform-uppercase">Transcodes</h2>
<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>
{% if transcodes %}
<h3 class="u-text-transform-uppercase">Available Transcodes</h3>
<ul>
{% for transcode in transcodes %}
<li>
{{ transcode.media_format }} ({{ transcode.quality }} quality) {% if transcode.processing %} <span class='processing'>(Processing... hold tight) </span>{% endif %} {% if transcode.error_message %}
<span class='transcode-error'>ERROR:</span>
<div class='transcode-error'>
<pre> {{ transcode.error_message }}</pre>
</div>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
<h3 class="u-text-transform-uppercase">Create transcode</h3>
<form action="{% url 'wagtailvideos:create_transcode' video.id %}" method="POST">
<ul class="fields">
{% csrf_token %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.media_format li_classes="label-above label-uppercase" %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %}
{% block transcode %}
{% if can_transcode %}
<h2 class="u-text-transform-uppercase">{% trans "Transcodes" %}</h2>
<p>{% trans "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>
{% if transcodes %}
<h3 class="u-text-transform-uppercase">{% trans "Available Transcodes" %}</h3>
<ul>
{% for transcode in transcodes %}
<li>
<input class="button" type='submit' value="Start" />
{% blocktrans with media_format=transcode.media_format quality=transcode.quality %}{% endblocktrans %}{{ media_format }} ({{ quality }} quality){% endblocktrans %}
{% if transcode.processing %}
<span class='processing'>{% trans "(Processing... hold tight)" %} </span>
{% endif %}
{% if transcode.error_message %}
<span class='transcode-error'>{% trans "ERROR:" %}</span>
<div class='transcode-error'>
<pre> {{ transcode.error_message }}</pre>
</div>
{% endif %}
</li>
{% endfor %}
</ul>
</form>
{% else %}
<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 %}
{% endif %}
<h3 class="u-text-transform-uppercase">{% trans "Create transcode" %}</h3>
<form action="{% url 'wagtailvideos:create_transcode' video.id %}" method="POST">
<ul class="fields">
{% csrf_token %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.media_format li_classes="label-above label-uppercase" %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %}
<li>
<input class="button" type='submit' value="{% trans 'Start' %}" />
</li>
</ul>
</form>
{% else %}
<br/><br/>
<span class='transcode-error'>{% trans "Ffmpeg is not found on your server. Please install if you wish to transcode videos into an HTML5 video compliant format." %}</span>
{% endif %}
{% endblock %}
{% if tracks_action_url %}
<h2 class="u-text-transform-uppercase">Tracks</h2>
<p>You can add/edit subtitles or accessibility captions for this video. For information about the filetype that should be used see the mozilla docs on <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API">WebVTT</a></p>
<h2 class="u-text-transform-uppercase">{% trans "Tracks" %}</h2>
<p>{% trans 'You can add/edit subtitles or accessibility captions for this video. For information about the filetype that should be used see the mozilla docs on <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API">WebVTT</a>' %}</p>
{% if video.track_listing %}
<ul>
{% for track in video.track_listing.tracks.all %}
<li>{{ track }}</li>
{% endfor %}
</ul>
<a class='button' href="{{ tracks_action_url }}">Edit</a>
<a class='button' href="{{ tracks_action_url }}">{% trans "Edit" %}</a>
{% else %}
<a class='button' href="{{ tracks_action_url }}">Add tracks</a>
<a class='button' href="{{ tracks_action_url }}">{% trans "Add tracks" %}</a>
{% endif %}
{% endif %}
</div>
......
......@@ -26,8 +26,8 @@ permission_checker = PermissionPolicyChecker(permission_policy)
def get_video_json(video):
"""
helper function: given an image, return the json to pass back to the
image chooser panel
helper function: given a video, return the json to pass back to the
video chooser panel
"""
return {
......
......@@ -114,7 +114,7 @@ def edit(request, video_id, callback=None):
if form.is_valid():
form.save()
# Reindex the image to make sure all tags are indexed
# Reindex the video to make sure all tags are indexed
for backend in get_search_backends():
backend.add(video)
......
......@@ -100,7 +100,7 @@ def edit(request, video_id):
video = form.save()
video.save()
# Reindex the image to make sure all tags are indexed
# Reindex the video to make sure all tags are indexed
for backend in get_search_backends():
backend.add(video)
......@@ -111,7 +111,7 @@ def edit(request, video_id):
form = VideoForm(instance=video)
if not video._meta.get_field('file').storage.exists(video.file.name):
# Give error if image file doesn't exist
# Give error if video file doesn't exist
messages.error(request, _(
"The source video file could not be found. Please change the source or delete the video."
).format(video.title), buttons=[
......
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