Unverified Commit 794ed405 authored by seb-b's avatar seb-b Committed by GitHub
Browse files

Merge pull request #75 from jkevingutierrez/feature/format

Format some files
parents c281c46a 170268c2
......@@ -20,7 +20,6 @@ head:
lts_27:
extends: .python_test
image: python:3.7
extends: .python_test
before_script:
- pip install .['testing'] wagtail~=2.7 django~=2.2
......
......@@ -131,7 +131,6 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
if too_long > len(head) + 1:
raise SuspiciousFileOperation('File name can not be shortened to a safe length')
filename = head[:-too_long] + ext
file_path = os.path.join(folder_name, filename)
return os.path.join(folder_name, filename)
def get_usage(self):
......@@ -143,7 +142,7 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
@property
def formatted_duration(self):
if(self.duration):
if self.duration:
hours, remainder = divmod(self.duration.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return "%d:%02d:%02d" % (hours, minutes, seconds)
......@@ -327,9 +326,7 @@ class VideoTranscode(AbstractVideoTranscode):
video = models.ForeignKey(Video, related_name='transcodes', on_delete=models.CASCADE)
class Meta:
unique_together = (
('video', 'media_format')
)
unique_together = ('video', 'media_format')
class AbstractTrackListing(ClusterableModel):
......
.transcode-error {
color: red;
color: red;
}
.processing {
opacity: 0.8;
font-weight: bold;
opacity: 0.8;
font-weight: bold;
}
......@@ -14,5 +14,5 @@ section.summary > .stats > li {
@media only screen and (max-width: 50em) {
section.summary > .stats {
grid-template-columns: repeat(2, 1fr);
}
}
\ No newline at end of file
}
}
......@@ -23,8 +23,8 @@ $(function() {
add: function(e, data) {
$('.messages').empty();
var $this = $(this);
var that = $this.data('blueimp-fileupload') || $this.data('fileupload')
var li = $($('#upload-list-item').html()).addClass('upload-uploading')
var that = $this.data('blueimp-fileupload') || $this.data('fileupload');
var li = $($('#upload-list-item').html()).addClass('upload-uploading');
var options = that.options;
$('#upload-list').append(li);
......@@ -39,10 +39,12 @@ $(function() {
});
}).done(function() {
data.context.find('.start').prop('disabled', false);
if ((that._trigger('added', e, data) !== false) &&
(options.autoUpload || data.autoUpload) &&
data.autoUpload !== false) {
data.submit()
if (
that._trigger('added', e, data) !== false &&
(options.autoUpload || data.autoUpload) &&
data.autoUpload !== false
) {
data.submit();
}
}).fail(function() {
if (data.files.error) {
......@@ -68,19 +70,24 @@ $(function() {
var progress = Math.floor(data.loaded / data.total * 100);
data.context.each(function() {
$(this).find('.progress').addClass('active').attr('aria-valuenow', progress).find('.bar').css(
'width',
progress + '%'
).html(progress + '%');
$(this)
.find('.progress')
.addClass('active')
.attr('aria-valuenow', progress)
.find('.bar')
.css('width', progress + '%')
.html(progress + '%');
});
},
progressall: function(e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#overall-progress').addClass('active').attr('aria-valuenow', progress).find('.bar').css(
'width',
progress + '%'
).html(progress + '%');
$('#overall-progress')
.addClass('active')
.attr('aria-valuenow', progress)
.find('.bar')
.css('width', progress + '%')
.html(progress + '%');
if (progress >= 100) {
$('#overall-progress').removeClass('active').find('.bar').css('width', '0%');
......@@ -92,14 +99,13 @@ $(function() {
var response = $.parseJSON(data.result);
if (response.success) {
itemElement.addClass('upload-success')
itemElement.addClass('upload-success');
$('.preview', itemElement).attr('data-thumb-target', response.video_id);
$('.right', itemElement).append(response.form);
} else {
itemElement.addClass('upload-failure');
$('.right .error_messages', itemElement).append(response.error_message);
}
},
fail: function(e, data) {
......@@ -124,7 +130,9 @@ $(function() {
if (data.success) {
var statusText = $('.status-msg.update-success').text();
addMessage('success', statusText);
itemElement.slideUp(function() {$(this).remove()});
itemElement.slideUp(function() {
$(this).remove();
});
} else {
form.replaceWith(data.form);
......@@ -142,11 +150,12 @@ $(function() {
var CSRFToken = $('input[name="csrfmiddlewaretoken"]', form).val();
$.post(this.href, {csrfmiddlewaretoken: CSRFToken}, function(data) {
$.post(this.href, { csrfmiddlewaretoken: CSRFToken }, function(data) {
if (data.success) {
itemElement.slideUp(function() {$(this).remove()});
itemElement.slideUp(function() {
$(this).remove();
});
}
});
});
});
VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
'chooser': function(modal, jsonData) {
var searchUrl = $('form.video-search', modal.body).attr('action');
var VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS = {
chooser: function(modal, jsonData) {
var searchUrl = $('form.video-search', modal.body).attr('action');
/* currentTag stores the tag currently being filtered on, so that we can
preserve this when paginating */
var currentTag;
/* currentTag stores the tag currently being filtered on, so that we can
preserve this when paginating */
var currentTag;
function ajaxifyLinks (context) {
$('.listing a', context).click(function() {
modal.loadUrl(this.href);
return false;
});
function ajaxifyLinks(context) {
$('.listing a', context).click(function() {
modal.loadUrl(this.href);
return false;
});
$('.pagination a', context).click(function() {
var page = this.getAttribute("data-page");
setPage(page);
return false;
});
}
function fetchResults(requestData) {
$.ajax({
url: searchUrl,
data: requestData,
success: function(data, status) {
$('#image-results').html(data);
ajaxifyLinks($('#image-results'));
}
});
}
$('.pagination a', context).click(function() {
var page = this.getAttribute('data-page');
setPage(page);
return false;
});
}
function search() {
/* Searching causes currentTag to be cleared - otherwise there's
no way to de-select a tag */
currentTag = null;
fetchResults({
q: $('#id_q').val(),
collection_id: $('#collection_chooser_collection_id').val()
});
return false;
}
function fetchResults(requestData) {
$.ajax({
url: searchUrl,
data: requestData,
success: function(data, status) {
$('#image-results').html(data);
ajaxifyLinks($('#image-results'));
}
});
}
function setPage(page) {
params = {p: page};
if ($('#id_q').val().length){
params['q'] = $('#id_q').val();
function search() {
/* Searching causes currentTag to be cleared - otherwise there's
no way to de-select a tag */
currentTag = null;
fetchResults({
q: $('#id_q').val(),
collection_id: $('#collection_chooser_collection_id').val()
});
return false;
}
if (currentTag) {
params['tag'] = currentTag;
function setPage(page) {
var params = { p: page };
if ($('#id_q').val().length) {
params['q'] = $('#id_q').val();
}
if (currentTag) {
params['tag'] = currentTag;
}
params['collection_id'] = $('#collection_chooser_collection_id').val();
fetchResults(params);
return false;
}
params['collection_id'] = $('#collection_chooser_collection_id').val();
fetchResults(params);
return false;
}
ajaxifyLinks(modal.body);
ajaxifyLinks(modal.body);
$('form.video-upload', modal.body).submit(function() {
var formdata = new FormData(this);
$.ajax({
url: this.action,
data: formdata,
processData: false,
contentType: false,
type: 'POST',
dataType: 'text',
success: function(response){
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' +
'<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>');
}
});
$('form.video-upload', modal.body).submit(function() {
var formdata = new FormData(this);
$.ajax({
url: this.action,
data: formdata,
processData: false,
contentType: false,
type: 'POST',
dataType: 'text',
success: function(response) {
modal.loadResponseText(response);
},
error: function(response, textStatus, errorThrown) {
var message = jsonData['error_message'] + '<br />' + errorThrown + ' - ' + response.status;
$('#upload').append(
'<div class="help-block help-critical">' + '<strong>' + jsonData['error_label'] + ': </strong>' + message + '</div>'
);
}
});
return false;
});
return false;
});
$('form.video-search', modal.body).submit(search);
$('form.video-search', modal.body).submit(search);
$('#id_q').on('input', function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 200);
$(this).data('timer', wait);
});
$('#collection_chooser_collection_id').change(search);
$('a.suggested-tag').click(function() {
currentTag = $(this).text();
$('#id_q').val('');
fetchResults({
'tag': currentTag,
collection_id: $('#collection_chooser_collection_id').val()
$('#id_q').on('input', function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 200);
$(this).data('timer', wait);
});
return false;
});
/* Add tag entry interface (with autocompletion) to the tag field of the image upload form */
// $('#id_tags', modal.body).tagit({
// autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
// });
},
'video_chosen': function(modal, jsonData) {
modal.respond('videoChosen', jsonData['result']);
modal.close();
},
}
$('#collection_chooser_collection_id').change(search);
$('a.suggested-tag').click(function() {
currentTag = $(this).text();
$('#id_q').val('');
fetchResults({
tag: currentTag,
collection_id: $('#collection_chooser_collection_id').val()
});
return false;
});
/* Add tag entry interface (with autocompletion) to the tag field of the image upload form */
// $('#id_tags', modal.body).tagit({
// autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
// });
},
video_chosen: function(modal, jsonData) {
modal.respond('videoChosen', jsonData['result']);
modal.close();
}
};
......@@ -4,12 +4,12 @@ function createVideoChooser(id) {
var input = $('#' + id);
var editLink = chooserElement.find('.edit-link');
$('.action-choose', chooserElement).click(function () {
$('.action-choose', chooserElement).click(function() {
ModalWorkflow({
url: window.chooserUrls.videoChooser,
onload: VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS,
responses: {
videoChosen: function (videoData) {
videoChosen: function(videoData) {
input.val(videoData.id);
previewVideo.attr({
src: videoData.preview.url,
......@@ -22,7 +22,7 @@ function createVideoChooser(id) {
});
});
$('.action-clear', chooserElement).click(function () {
$('.action-clear', chooserElement).click(function() {
input.val('');
chooserElement.addClass('blank');
});
......
......@@ -19,9 +19,9 @@
<a class="image-choice" href="{% if will_select_format %}{% url 'wagtailvideos:chooser_select_format' video.id %}{% else %}{% url 'wagtailvideos:video_chosen' video.id %}{% endif %}">
<div class="image">
{% if video.thumbnail %}
<img src='{{video.thumbnail.url}}' width="165" height="165" class="show-transparency">
<img src="{{ video.thumbnail.url }}" width="165" height="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
{% else %}
<img width="165" height="165" class="show-transparency">
<img width="165" height="165" class="show-transparency" alt=""/>
{% endif %}
</div>
<h3>{{ video.title|ellipsistrim:60 }}</h3>
......
......@@ -8,4 +8,4 @@
<span>{{ total }}</span> Videos <span class="visuallyhidden">created in {{ site_name }}</span>
{% endblocktrans %}
</a>
</li>
\ No newline at end of file
</li>
......@@ -3,7 +3,7 @@
{% block titletag %}{% trans "Add multiple videos" %}{% endblock %}
{% block extra_css %}
{{ block.super }}
<!-- it's cheating but we're just going to use wagtailimages css since they should look identical anyways -->
<!-- it's cheating but we're just going to use wagtailimages css since they should look identical anyways -->
<link rel="stylesheet" href="{% static 'wagtailimages/css/add-multiple.css' %}" type="text/css" />
{% endblock %}
......@@ -14,7 +14,7 @@
<div class="nice-padding">
<div class="drop-zone">
<p>{% trans "Drag and drop videos into this area to upload immediately." %}</p>
<p>{{ help_text }}
<p>{{ help_text }}</p>
<form action="{% url 'wagtailvideos:add_multiple' %}" method="POST" enctype="multipart/form-data">
<div class="replace-file-input">
......@@ -84,7 +84,7 @@
max_file_size: "{{ error_max_file_size }}",
accepted_file_types: "{{ error_accepted_file_types }}"
}
}
};
window.tagit_opts = {
autocomplete: {source: "{{ autocomplete_url|addslashes }}"}
};
......
......@@ -10,18 +10,17 @@
{% endif %}
{% endfor %}
<li>
<input class='button' type="submit" value="{% trans 'Update' %}" />
<input class="button" type="submit" value="{% trans 'Update' %}" />
<a href="{% url 'wagtailvideos:delete_multiple' video.id %}" class="delete button button-secondary no">{% trans "Delete" %}</a>
</li>
</ul>
</form>
<div data-video-thumb="{{ video.id }}" class='thumb icon icon-media hasthumb'>
<div data-video-thumb="{{ video.id }}" class="thumb icon icon-media hasthumb">
{% if video.thumbnail %}
<img src="{{ video.thumbnail.url }}" />
<img src="{{ video.thumbnail.url }}" alt="{% trans 'Video thumbnail' %}" />
{% endif %}
</div>
<script>
var thumb = $("[data-video-thumb=\"" + {{ video.id }} + "\"]");
$("[data-thumb-target=\"" + {{ video.id }} + "\"]").append(thumb);
var thumb = $("[data-video-thumb=\"" + {{ video.id }} + "\"]");
$("[data-thumb-target=\"" + {{ video.id }} + "\"]").append(thumb);
</script>
......@@ -30,7 +30,7 @@
{% include "wagtailadmin/shared/field_as_li.html" with field=field %}
{% endif %}
{% endfor %}
<li><input class='button' type="submit" value="{% trans 'Save' %}" /></li>
<li><input class="button" type="submit" value="{% trans 'Save' %}" /></li>
</ul>
</form>
</div>
......
......@@ -15,7 +15,7 @@
<p>{% trans "Are you sure you want to delete this video?" %}</p>
<form action="{% url 'wagtailvideos:delete' video.id %}" method="POST">
{% csrf_token %}
<input type="submit" class='button serious' value="{% trans 'Yes, delete' %}" />
<input type="submit" class="button serious" value="{% trans 'Yes, delete' %}" />
</form>
</div>
</div>
......
......@@ -21,7 +21,7 @@
<a class="image-choice" href="{% url 'wagtailvideos:edit' video.id %}">
<div class="image">
{% if video.thumbnail %}
<img src='{{video.thumbnail.url}}' height=165 width=165 class="show-transparency" /></img>
<img src="{{ video.thumbnail.url }}" height="165" width="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
{% endif %}
</div>
<h3>{{ video.title|ellipsistrim:60 }}</h3>
......
{% extends "wagtailadmin/widgets/chooser.html" %}
{% load i18n %}
{% block chooser_class %}image-chooser{% endblock %}
{% block chosen_state_view %}
<div class="preview-image">
{% if video and video.thumbnail %}
<img src="{{video.thumbnail.url}}" width="165" height="165" class="show-transparency">
<img src="{{ video.thumbnail.url }}" width="165" height="165" class="show-transparency" alt="{% trans 'Video thumbnail' %}"/>
{% else %}
<img width="165" height="165" class="show-transparency">
<img width="165" height="165" class="show-transparency" alt=""/>
{% endif %}
</div>
{% endblock %}
......
......@@ -12,7 +12,7 @@ def video(parser, token):
extra_attrs = {}
# Everyting after video expression
if(len(template_params) > 1):
if len(template_params) > 1:
for param in template_params[1:]:
try:
name, value = param.split('=')
......
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