Skip to content

Commit

Permalink
[DONE] Fix bugs for 3.8.2 version (#1217)
Browse files Browse the repository at this point in the history
Fix some bugs :

- Fix BBB meeting deletion link (issue #1216)
- Addition of a toolbar in the theme description editor of a chain. (issue #1185)
- Correction enabling channels and themes to be assigned to a set of videos (issue 1106)
- No crop on thumbnail
- Manage restricted video acces right in playlist
  • Loading branch information
LoicBonavent authored Oct 24, 2024
1 parent d12a563 commit 392c09a
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 14 deletions.
5 changes: 5 additions & 0 deletions pod/main/static/css/pod.css
Original file line number Diff line number Diff line change
Expand Up @@ -1866,3 +1866,8 @@ body[data-admin-utc-offset]
#link-video-modal .modal-dialog {
font-size: 1.7em;
}

/* No crop on thumbnail */
img.pod-thumbnail {
width: 100%;
}
6 changes: 6 additions & 0 deletions pod/main/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,12 @@ function show_form_theme(data) {
top: parseInt(document.getElementById("div_form_theme").offsetTop, 10),
behavior: "smooth",
});
// Add CKEditor when edit a theme
// For all descriptions, except description help
const theme_descriptions = document.querySelectorAll("textarea[id^='id_description']")
theme_descriptions.forEach((theme_description) => {
CKEDITOR.replace(theme_description.id);
});
}
/**
* [show_list_theme description]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{% if not meeting.is_personal %}
<li><hr class="dropdown-divider"></li>
<li>
<a href="{% url 'meeting:internal_recordings' meeting.meeting_id %}"
<a href="{% url 'meeting:delete' meeting.meeting_id %}"
title="{% trans 'Delete the meeting'%} — {{ meeting.name }}"
class="dropdown-item"
data-bs-toggle="tooltip"
Expand Down
4 changes: 2 additions & 2 deletions pod/playlist/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def user_can_see_playlist_video(
request: WSGIRequest, video: Video, playlist: Playlist
) -> bool:
"""
Check if the authenticated can see the playlist video.
Check if the authenticated user can see the playlist video.
Args:
request (WSGIRequest): The WSGIRequest
Expand All @@ -331,7 +331,7 @@ def user_can_see_playlist_video(
bool: True if the user can see the playlist video. False otherwise
"""
is_password_protected = video.password is not None and video.password != ""
if is_password_protected or video.is_draft:
if is_password_protected or video.is_restricted or video.is_draft:
if not request.user.is_authenticated:
return False
return (
Expand Down
2 changes: 1 addition & 1 deletion pod/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
##
# Version of the project
#
VERSION = "3.8.1"
VERSION = "3.8.2"

##
# Installed applications list
Expand Down
8 changes: 8 additions & 0 deletions pod/video/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,20 @@ class FrontThemeForm(ThemeForm):
"""Form class for Theme editing in front."""

def __init__(self, *args, **kwargs) -> None:
"""Initialize a new FrontThemeForm instance."""
self.THEME_FORM_FIELDS_HELP_TEXT = THEME_FORM_FIELDS_HELP_TEXT

super(FrontThemeForm, self).__init__(*args, **kwargs)

self.fields["channel"].widget = forms.HiddenInput()
# self.fields["parentId"].label = _('Theme parent')
# Add CKEditor when edit a theme
self.fields["description"].widget = CKEditorWidget(config_name="complete")
for key, _value in settings.LANGUAGES:
self.fields["description_%s" % key.replace("-", "_")].widget = (
CKEditorWidget(config_name="complete")
)

if "channel" in self.initial.keys():
themes_queryset = Theme.objects.filter(channel=self.initial["channel"])
self.fields["parentId"].queryset = themes_queryset
Expand Down
117 changes: 114 additions & 3 deletions pod/video/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ async function bulkUpdate() {
".form-control, .form-check-input, .form-select, input[name='thumbnail']",
);
if (element.hasAttribute("multiple")) {
formData.append(element.getAttribute("name"), element.value);
// Get multiple values for channel or theme
var options = element.selectedOptions;
for (var i=0, iLen=options.length; i<iLen; i++) {
formData.append(element.getAttribute("name"), options[i].value.toString());
}
} else {
switch (element.type) {
case "checkbox":
Expand All @@ -153,9 +157,9 @@ async function bulkUpdate() {
});
}

// Remove unecessaries fields.
if (updateFields.includes("channel") && updateFields.includes("theme")) {
if (formData.get("channel") != "" && formData.get("theme") == "") {
// Remove unecessaries fields.
if (formData.get("channel") != null && formData.get("theme") == null) {
updateFields.pop("theme");
formData.delete("theme");
}
Expand All @@ -178,6 +182,7 @@ async function bulkUpdate() {
},
body: formData,
});

let result = await response.text();

// Parse result
Expand Down Expand Up @@ -264,3 +269,109 @@ function showDashboardFormError(element, message, alertClass) {
'"></button></div>';
element.insertAdjacentHTML("beforebegin", html);
}

/** Channel **/
// Manage themes initially and when another channel is selected by the user
let id_channel = document.getElementById("id_channel");
if (id_channel) {
let tab_initial = new Array();
let id_theme = document.getElementById("id_theme");

// Save all themes in tab_initial array, then remove all themes options from selection list
const update_theme = function () {
tab_initial = [];
if (id_theme) {
for (let i = 0; i < id_theme.options.length; i++) {
if (id_theme.options[i].selected) {
tab_initial.push(id_theme.options[i].value);
}
}
// Remove all options
for (option in id_theme.options) {
id_theme.options.remove(0);
}
}
};
update_theme();
// Callback function to execute when mutations are observed
const id_channel_callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type === "childList") {
update_theme();
var new_themes = [];
var channels = id_channel.parentElement.querySelectorAll(
".select2-selection__choice",
);
for (let i = 0; i < channels.length; i++) {
for (let j = 0; j < id_channel.options.length; j++) {
if (channels[i].title === id_channel.options[j].text) {
if (listTheme["channel_" + id_channel.options[j].value]) {
new_themes.push(
get_list(
listTheme["channel_" + id_channel.options[j].value],
0,
tab_initial,
(tag_type = "option"),
(li_class = ""),
(attrs = ""),
(add_link = false),
(current = ""),
(channel = id_channel.options[j].text + ": "),
),
);
}
}
}
}
id_theme.innerHTML = new_themes.join("\n");
flashing(id_theme, 1000);
}
}
};
// Create an observer instance linked to the callback function
const id_channel_config = {
attributes: false,
childList: true,
subtree: false,
};
const id_channel_observer = new MutationObserver(id_channel_callback);
var select_channel_observer = new MutationObserver(function (mutations) {
if (
id_channel.parentElement.querySelector(".select2-selection__rendered")
) {
id_channel_observer.observe(
id_channel.parentElement.querySelector(
".select2-selection__rendered",
),
id_channel_config,
);
select_channel_observer.disconnect();
}
});
select_channel_observer.observe(id_channel.parentElement, {
//document.body is node target to observe
childList: true, //This is a must have for the observer with subtree
subtree: true, //Set to true if changes must also be observed in descendants.
});

var initial_themes = [];
for (let i = 0; i < id_channel.options.length; i++) {
if (listTheme["channel_" + id_channel.options[i].value]) {
initial_themes.push(
get_list(
listTheme["channel_" + id_channel.options[i].value],
0,
tab_initial,
(tag_type = "option"),
(li_class = ""),
(attrs = ""),
(add_link = false),
(current = ""),
(channel = id_channel.options[i].text + ": "),
),
);
}
}
id_theme.innerHTML = initial_themes.join("\n");
}
/** end channel **/
2 changes: 1 addition & 1 deletion pod/video/templates/channel/list_theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% for theme in list_theme %}
<tr id="theme_{{theme.id}}">
<td class="theme_title">{{theme.title}}</td>
<td class="theme_description">{{theme.description|truncatewords:6 }}</td>
<td class="theme_description">{{theme.description|striptags|truncatewords:6 }}</td>
<td class="theme_headband">{{theme.headband}}</td>
<td class="text-center">
<form class="get_form_theme d-inline-block" action="{% url 'channels:theme_edit' slug=channel.slug %}" method="POST">
Expand Down
3 changes: 0 additions & 3 deletions pod/video/templates/channel/theme_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,3 @@ <h2 class="h4 card-header card-title pod-card__title">{% trans "Form fields"%}</
</div>
</div>
{% endblock page_aside %}

{% block more_script %}
{% endblock more_script %}
1 change: 1 addition & 0 deletions pod/video/templates/videos/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ <h2 id="video_count" class="col-5">{% blocktrans count counter=count_videos %}{{
var nextPage = false;
var ownerFilter = {{ owner_filter|yesno:'true,false'}};
var formFieldsets = {{ fieldsets_dashboard|safe }};
var listTheme = {{listTheme | safe}};

{% if videos.has_next %}
page = parseInt("{{videos.next_page_number}}", 10);
Expand Down
5 changes: 2 additions & 3 deletions pod/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ def get_theme_children_as_list(channel: Channel, theme_children: QuerySet) -> li
return children


def _regroup_videos_by_theme(
request, videos, page, full_path, channel, theme=None
): # noqa: C901
def _regroup_videos_by_theme(request, videos, page, full_path, channel, theme=None): # noqa: C901
"""Regroup videos by theme.
Args:
Expand Down Expand Up @@ -674,6 +672,7 @@ def dashboard(request):
data_context["display_mode"] = display_mode
data_context["video_list_template"] = template
data_context["page_title"] = _("Dashboard")
data_context["listTheme"] = json.dumps(get_list_theme_in_form(form))

return render(request, "videos/dashboard.html", data_context)

Expand Down

0 comments on commit 392c09a

Please sign in to comment.