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): ...@@ -24,7 +24,7 @@ class BaseVideoForm(BaseCollectionMemberForm):
self.fields['file'].required = 'file' not in self.initial or not self.initial['file'] 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): def formfield_for_dbfield(db_field, **kwargs):
# Check if this is the file field # Check if this is the file field
if db_field.name == 'file': if db_field.name == 'file':
...@@ -75,7 +75,7 @@ class VideoTranscodeAdminForm(forms.Form): ...@@ -75,7 +75,7 @@ class VideoTranscodeAdminForm(forms.Form):
GroupVideoPermissionFormSet = collection_member_permission_formset_factory( GroupVideoPermissionFormSet = collection_member_permission_formset_factory(
Video, Video,
[ [
('add_video', _("Add"), _("Add/edit images you own")), ('add_video', _("Add"), _("Add/edit videos you own")),
('change_video', _("Edit"), _("Edit any video")), ('change_video', _("Edit"), _("Edit any video")),
], ],
'wagtailvideos/permissions/includes/video_permissions_formset.html' 'wagtailvideos/permissions/includes/video_permissions_formset.html'
......
...@@ -189,6 +189,9 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model): ...@@ -189,6 +189,9 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
def get_track_listing_model(cls): def get_track_listing_model(cls):
return cls.track_listing.related.related_model 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): def video_tag(self, attrs=None):
if attrs is None: if attrs is None:
attrs = {} attrs = {}
...@@ -197,7 +200,7 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model): ...@@ -197,7 +200,7 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
if self.thumbnail: if self.thumbnail:
attrs['poster'] = self.thumbnail.url attrs['poster'] = self.thumbnail.url
transcodes = self.transcodes.exclude(processing=True).filter(error_message__exact='') transcodes = self.get_current_transcodes()
sources = [] sources = []
for transcode in transcodes: for transcode in transcodes:
sources.append("<source src='{0}' type='video/{1}' >".format(transcode.url, transcode.media_format.name)) sources.append("<source src='{0}' type='video/{1}' >".format(transcode.url, transcode.media_format.name))
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</li> </li>
</ul> </ul>
</form> </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 %} {% if video.thumbnail %}
<img src="{{ video.thumbnail.url }}" /> <img src="{{ video.thumbnail.url }}" />
{% endif %} {% endif %}
......
{% extends "wagtailadmin/base.html" %} {% extends "wagtailadmin/base.html" %}
{% load i18n %} {% load i18n %}
{% block titletag %}{% trans "Add an image" %}{% endblock %} {% block titletag %}{% trans "Add a video" %}{% endblock %}
{% block extra_js %} {% block extra_js %}
{{ block.super }} {{ block.super }}
......
{% extends "wagtailadmin/base.html" %} {% extends "wagtailadmin/base.html" %}
{% load wagtailvideos_tags %} {% load wagtailvideos_tags %}
{% load i18n %} {% load i18n %}
{% block titletag %}{% trans "Delete image" %}{% endblock %} {% block titletag %}{% trans "Delete video" %}{% endblock %}
{% block content %} {% block content %}
{% trans "Delete image" as del_str %} {% trans "Delete video" as del_str %}
{% include "wagtailadmin/shared/header.html" with title=del_str icon="image" %} {% include "wagtailadmin/shared/header.html" with title=del_str icon="media" %}
<div class="row row-flush nice-padding"> <div class="row row-flush nice-padding">
<div class="col6"> <div class="col6">
......
...@@ -42,8 +42,10 @@ ...@@ -42,8 +42,10 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<li> <li>
<input type="submit" class="button" value="{% trans 'Save' %}" /> {% if user_can_delete %} <input type="submit" class="button" value="{% trans 'Save' %}" />
<a href="{% url 'wagtailvideos:delete' video.id %}" class="button button-secondary no">{% trans "Delete video" %}</a> {% endif %} {% if user_can_delete %}
<a href="{% url 'wagtailvideos:delete' video.id %}" class="button button-secondary no">{% trans "Delete video" %}</a>
{% endif %}
</li> </li>
</ul> </ul>
</form> </form>
...@@ -76,16 +78,21 @@ ...@@ -76,16 +78,21 @@
</div> </div>
</div> </div>
<div class="row" style='margin-top: 2em;'> <div class="row" style='margin-top: 2em;'>
{% block transcode %}
{% if can_transcode %} {% if can_transcode %}
<h2 class="u-text-transform-uppercase">Transcodes</h2> <h2 class="u-text-transform-uppercase">{% trans "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> <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 %} {% if transcodes %}
<h3 class="u-text-transform-uppercase">Available Transcodes</h3> <h3 class="u-text-transform-uppercase">{% trans "Available Transcodes" %}</h3>
<ul> <ul>
{% for transcode in transcodes %} {% for transcode in transcodes %}
<li> <li>
{{ transcode.media_format }} ({{ transcode.quality }} quality) {% if transcode.processing %} <span class='processing'>(Processing... hold tight) </span>{% endif %} {% if transcode.error_message %} {% blocktrans with media_format=transcode.media_format quality=transcode.quality %}{% endblocktrans %}{{ media_format }} ({{ quality }} quality){% endblocktrans %}
<span class='transcode-error'>ERROR:</span> {% 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'> <div class='transcode-error'>
<pre> {{ transcode.error_message }}</pre> <pre> {{ transcode.error_message }}</pre>
</div> </div>
...@@ -94,33 +101,34 @@ ...@@ -94,33 +101,34 @@
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
<h3 class="u-text-transform-uppercase">Create transcode</h3> <h3 class="u-text-transform-uppercase">{% trans "Create transcode" %}</h3>
<form action="{% url 'wagtailvideos:create_transcode' video.id %}" method="POST"> <form action="{% url 'wagtailvideos:create_transcode' video.id %}" method="POST">
<ul class="fields"> <ul class="fields">
{% csrf_token %} {% 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.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" %} {% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %}
<li> <li>
<input class="button" type='submit' value="Start" /> <input class="button" type='submit' value="{% trans 'Start' %}" />
</li> </li>
</ul> </ul>
</form> </form>
{% else %} {% else %}
<br/><br/> <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> <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 %} {% endif %}
{% endblock %}
{% if tracks_action_url %} {% if tracks_action_url %}
<h2 class="u-text-transform-uppercase">Tracks</h2> <h2 class="u-text-transform-uppercase">{% trans "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> <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 %} {% if video.track_listing %}
<ul> <ul>
{% for track in video.track_listing.tracks.all %} {% for track in video.track_listing.tracks.all %}
<li>{{ track }}</li> <li>{{ track }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
<a class='button' href="{{ tracks_action_url }}">Edit</a> <a class='button' href="{{ tracks_action_url }}">{% trans "Edit" %}</a>
{% else %} {% else %}
<a class='button' href="{{ tracks_action_url }}">Add tracks</a> <a class='button' href="{{ tracks_action_url }}">{% trans "Add tracks" %}</a>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
......
...@@ -26,8 +26,8 @@ permission_checker = PermissionPolicyChecker(permission_policy) ...@@ -26,8 +26,8 @@ permission_checker = PermissionPolicyChecker(permission_policy)
def get_video_json(video): def get_video_json(video):
""" """
helper function: given an image, return the json to pass back to the helper function: given a video, return the json to pass back to the
image chooser panel video chooser panel
""" """
return { return {
......
...@@ -114,7 +114,7 @@ def edit(request, video_id, callback=None): ...@@ -114,7 +114,7 @@ def edit(request, video_id, callback=None):
if form.is_valid(): if form.is_valid():
form.save() 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(): for backend in get_search_backends():
backend.add(video) backend.add(video)
......
...@@ -100,7 +100,7 @@ def edit(request, video_id): ...@@ -100,7 +100,7 @@ def edit(request, video_id):
video = form.save() video = form.save()
video.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(): for backend in get_search_backends():
backend.add(video) backend.add(video)
...@@ -111,7 +111,7 @@ def edit(request, video_id): ...@@ -111,7 +111,7 @@ def edit(request, video_id):
form = VideoForm(instance=video) form = VideoForm(instance=video)
if not video._meta.get_field('file').storage.exists(video.file.name): 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, _( messages.error(request, _(
"The source video file could not be found. Please change the source or delete the video." "The source video file could not be found. Please change the source or delete the video."
).format(video.title), buttons=[ ).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