Skip to content

Commit

Permalink
Merge pull request #554 from EsupPortail/dev
Browse files Browse the repository at this point in the history
Dev - fixbug with added video to playlist
  • Loading branch information
ptitloup authored Nov 23, 2021
2 parents 21105c4 + 8f13475 commit f942181
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 19 deletions.
9 changes: 9 additions & 0 deletions pod/live/templates/live/live.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ <h2>{% trans 'Send message' %}</h2>

{% block page_aside %}

{% if request.user.is_superuser %}
<div class="card mt-1" id="card-managevideo">
<h5 class="card-header card-title pl-2"><i data-feather="settings"></i>&nbsp;{% trans "Manage live"%}</h5>
<div class="card-body card-text text-center">
<a href="{% url 'admin:live_broadcaster_change' broadcaster.id %}" title="{% trans "Edit the live"%}" class="btn btn-light btn-sm p-0 pb-1 m-0 ml-1">
<i data-feather="edit"></i></a>
</div>
</div>
{% endif %}

<div class="card card-body p-2 mt-1" id="card-livebuilding">
<h5 class="card-title pl-2">
Expand Down
Binary file modified pod/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion pod/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ msgstr "sous-titres"

#: pod/completion/models.py:44
msgid "captions"
msgstr "sous titres"
msgstr "légendes"

#: pod/completion/models.py:59
msgid "lastname / firstname"
Expand Down
Binary file modified pod/locale/fr/LC_MESSAGES/djangojs.mo
Binary file not shown.
Binary file modified pod/locale/nl/LC_MESSAGES/django.mo
Binary file not shown.
Binary file modified pod/locale/nl/LC_MESSAGES/djangojs.mo
Binary file not shown.
27 changes: 20 additions & 7 deletions pod/playlist/static/js/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,34 @@ $(window).ready(function () {
}
});

$("#info-video").on("click", ".playlist-item", function () {
const vmslug = window.location.href.match(/video\/(\d{4}\-[^/?]*)/);
if (!vmslug) {
$("#info-video").on("click", ".playlist-item", function (e) {
e.preventDefault();
const url = window.location.href;
const regex = new RegExp('(.*)/video/(\\d+-(.*))/');
const checkslug = regex.test(url);
const foundslug = url.match(regex);
if (!checkslug) {
showalert(
gettext("The video can not be added from this page."),
"alert-danger"
);
return;
}
const slug = $(this).attr("data-slug"),
jqxhr = $.ajax({
if (!foundslug[2]) {
showalert(
gettext("The video slug not found."),
"alert-danger"
);
return;
}
const slug = $(this).attr("data-slug");
const link = $(this);
const jqxhr = $.ajax({
method: "POST",
url: "/playlist/edit/" + slug + "/",
data: {
action: "add",
video: vmslug[1],
video: foundslug[2],
csrfmiddlewaretoken: $(this)
.parents(".dropdown-menu")
.find("input")
Expand All @@ -195,7 +207,8 @@ $(window).ready(function () {
} else {
if (response.success) {
showalert(response.success, "alert-success");
window.location.reload();
//window.location.reload(); //hide link playlist
link.addClass("disabled").removeClass("playlist-item").append('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check align-bottom"><polyline points="20 6 9 17 4 12"></polyline></svg>')
} else {
showalert(response.fail, "alert-danger");
}
Expand Down
2 changes: 1 addition & 1 deletion pod/playlist/templates/playlist/playlist_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h6 class="card-subtitle mb-2 text-muted">{% blocktrans count counter=playlist.v
<div class="btn-group">
<a href="{% url 'playlist_edit' slug=playlist.slug %}" class="btn btn-sm btn-primary">{% trans 'Edit' %}</a>
&nbsp;
{% if playlist.first.video.slug %}
{% if playlist.videos %}
<a href="{% url 'playlist' slug=playlist.slug %}" class="btn btn-sm btn-primary">{% trans 'Launch' %}</a>
{% endif %}
</div>
Expand Down
18 changes: 11 additions & 7 deletions pod/video/templates/channel/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h1>
{% if theme %}
<a href="{% url 'video_stats_view' slug=channel.slug slug_t=theme.slug %}?from=theme" title="{% trans 'Show view statistics for all videos in this theme' %}" target="_blank" class="btn btn-outline-primary btn-sm">{% trans 'Statistics views' %}</a>
{% else %}
<a href="{% url 'video_stats_view' slug=channel.slug %} %}?from=theme" title="{% trans 'Show view statistics for all videos in this theme' %}" target="_blank" class="btn btn-outline-primary btn-sm">{% trans 'Statistics views' %}</a>
<a href="{% url 'video_stats_view' slug=channel.slug %}" title="{% trans 'Show view statistics for all videos in this theme' %}" target="_blank" class="btn btn-outline-primary btn-sm">{% trans 'Statistics views' %}</a>
{% endif %}
{% endif %}
{% if theme %}
Expand Down Expand Up @@ -109,12 +109,16 @@ <h2>{{title}}</h2>
{% endif %}
</section>
<section class="video-section">
<p class="video-count">{% blocktrans count counter=videos|length %}{{ counter }} video found{% plural %}{{ counter }} videos found{% endblocktrans %}</p>
{% include "videos/video_list.html" %}
{% if has_more_videos %}
<div class="float-right">
<button class="btn btn-primary" id="load-more-videos" type="button">{% trans "Load more videos" %}</button>
</div>
{% if videos %}
<p class="video-count">
{% blocktrans count counter=count_videos %}{{ counter }} video found{% plural %}{{ counter }} videos found{% endblocktrans %}
</p>
{% include "videos/video_list.html" %}
{% if has_more_videos %}
<div class="float-right">
<button class="btn btn-primary" id="load-more-videos" type="button">{% trans "Load more videos" %}</button>
</div>
{% endif %}
{% endif %}
</section>
</div>
Expand Down
8 changes: 5 additions & 3 deletions pod/video/templates/videos/video-all-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ <h1 class="pt-2">
<ul class="list-group">
{% for playlist in request.user.playlist_set.all %}
{% if video in playlist.videos %}
<li class="dropdown-item disabled py-0" data-slug="{{playlist.slug}}">{{playlist.title}}
<i data-feather="check"></i>
<li class="dropdown-item py-0" >
<a href="#" data-slug="{{playlist.slug}}" class="btn disabled p-0 m-0">{{playlist.title}}<i data-feather="check"></i></a>
</li>
{% else %}
<li class="dropdown-item playlist-item py-0" data-slug="{{playlist.slug}}">{{playlist.title}}</li>
<li class="dropdown-item py-0" >
<a href="#" data-slug="{{playlist.slug}}" class="btn playlist-item p-0 m-0">{{playlist.title}}</a>
</li>
{% endif %}
{% endfor %}
</ul>
Expand Down
3 changes: 3 additions & 0 deletions pod/video/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def test_regroup_videos_by_theme(self):
"has_more_themes": False,
"has_more_videos": False,
"videos": [self.v],
"count_videos": 1,
"count_themes": 1,
"theme": None,
"channel": self.c,
Expand Down Expand Up @@ -126,6 +127,7 @@ def test_regroup_videos_by_theme(self):
)
expected.pop("next_videos", None)
expected.pop("has_more_videos", None)
expected.pop("count_videos", None)
self.assertEqual(response.status_code, HTTPStatus.OK)
self.assertCountEqual(expected, response.json())

Expand All @@ -138,6 +140,7 @@ def test_regroup_videos_by_theme(self):
)
expected["next_videos"] = None
expected["has_more_videos"] = False
expected["count_videos"] = 1

expected.pop("next", None)
expected.pop("previous", None)
Expand Down
1 change: 1 addition & 0 deletions pod/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def _regroup_videos_by_theme(request, videos, channel, theme=None):
response = {
**response,
"videos": list(videos),
"count_videos": count,
"has_more_videos": (offset + limit) < count,
}

Expand Down

0 comments on commit f942181

Please sign in to comment.