Skip to content

Commit

Permalink
[DONE] Fix bugfixes for 3.6.0 (#1117)
Browse files Browse the repository at this point in the history
* Fix notification error & improve upload file form

* Improve video tokens page (messages & titles)

* Fix some h1 titles in completion page

* Improve video infos

* Make some improvements

* Improve dashboard (remove required action, improve reset button)

* Show different message when dashboard action is "delete"

* Fix duplicate ID in dashboard table view

* Reset dashboard action when submit changes

* Fix navbar splitting in 2 lines when there's profile picture

* Add some improvements

* PR requests & fix unit tests

* Improve cards & aside collapse

* Fix video time display in video controlbar

* Fix JS problems & improve podfile

* Add video_dreessing help informations

* Change page_title in video completion page

* Add translations & reformat files

* Remove dressings permissions & improve QoC

* Update translations

* Add some views tests for dressings
  • Loading branch information
AymericJak authored Apr 29, 2024
1 parent be56029 commit 924af8a
Show file tree
Hide file tree
Showing 47 changed files with 1,141 additions and 792 deletions.
1 change: 1 addition & 0 deletions pod/chapter/templates/video_chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</div>
</div>
{% endblock page_content %}

{% block page_aside %}
{% if video.owner == request.user or request.user.is_superuser or perms.chapter.add_chapter or request.user in video.additional_owners.all %}
<div class="card" id="card-manage-video">
Expand Down
4 changes: 2 additions & 2 deletions pod/completion/templates/contributor/list_contributor.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ <h2 class="card-title pod-card__title">{% trans 'List of contributors' %}&nbsp;(
{% csrf_token %}
<input type="hidden" name="action" value="modify">
<input type="hidden" name="id" value="{{contributor.id}}">
<input type="submit" title="{% blocktrans with contributor_name=contributor.name %}Modify the contributor “{{ contributor_name }}”{% endblocktrans %}" value="{% trans 'Modify' %}" class="edt_contributor btn btn-secondary btn-sm">
<input type="submit" title="{% blocktrans with contributor_name=contributor.name %}Modify the contributor “{{ contributor_name }}”{% endblocktrans %}" data-bs-toggle="tooltip" data-bs-placement="right" value="{% trans 'Modify' %}" class="edt_contributor btn btn-secondary btn-sm">
</form>
<form class="form_delete completion d-inline-block" action="{% url 'video:completion:video_completion_contributor' slug=video.slug %}" method="POST">
{% csrf_token %}
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="{{contributor.id}}">
<input type="submit" title="{% blocktrans with contributor_name=contributor.name %}Delete the contributor “{{ contributor_name }}”{% endblocktrans %}" value="{% trans 'Delete' %}" class="edt_contributor btn btn-danger btn-sm">
<input type="submit" title="{% blocktrans with contributor_name=contributor.name %}Delete the contributor “{{ contributor_name }}”{% endblocktrans %}" data-bs-toggle="tooltip" data-bs-placement="right" value="{% trans 'Delete' %}" class="edt_contributor btn btn-danger btn-sm">
</form>
</td>
</tr>
Expand Down
3 changes: 1 addition & 2 deletions pod/completion/templates/video_completion.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{% extends 'base.html' %}
{% load i18n %}
{% load static %}
{% block page_title %}{% trans 'Video additions' %} "{{video.title}}"{% endblock page_title %}

{% block page_extra_head %}
<!-- media -->
Expand Down Expand Up @@ -36,7 +35,7 @@
&nbsp;
<span id="form_contributor">
{% if form_contributor %}
{% include 'contributor/form_contributor.html' with form_contributor=form_contributor %}
{% include 'contributor/form_contributor.html' with form_contributor=form_contributor %}
{% endif %}
</span>
<form class="form_new completion" id="form_new_contributor" action="{% url 'video:completion:video_completion_contributor' slug=video.slug %}" method="POST">
Expand Down
70 changes: 55 additions & 15 deletions pod/completion/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.admin.views.decorators import staff_member_required
from django.core.exceptions import PermissionDenied
from django.core.handlers.wsgi import WSGIRequest
from pod.video.models import Video
from .models import Contributor
from .forms import ContributorForm
Expand Down Expand Up @@ -47,6 +48,11 @@
}


def get_completion_home_page_title(video: Video):
"""Get page title."""
return _("Additions for the video “%s”") % video.title


@csrf_protect
@staff_member_required(redirect_field_name="referrer")
def video_caption_maker(request, slug):
Expand Down Expand Up @@ -169,9 +175,10 @@ def video_caption_maker_save(request, video):

@csrf_protect
@login_required(redirect_field_name="referrer")
def video_completion(request, slug):
def video_completion(request: WSGIRequest, slug: str):
"""Video Completion view."""
video = get_object_or_404(Video, slug=slug, sites=get_current_site(request))
page_title = get_completion_home_page_title(video)
if (
request.user != video.owner
and not (
Expand Down Expand Up @@ -202,31 +209,32 @@ def video_completion(request, slug):
request,
"video_completion.html",
{
"page_title": page_title,
"video": video,
"list_contributor": list_contributor,
"list_track": list_track,
"list_document": list_document,
"list_overlay": list_overlay,
"page_title": _("Video additions"),
},
)
else:
return render(
request,
"video_completion.html",
{
"page_title": page_title,
"video": video,
"list_contributor": list_contributor,
"page_title": _("Video additions"),
},
)


@csrf_protect
@login_required(redirect_field_name="referrer")
def video_completion_contributor(request, slug):
def video_completion_contributor(request: WSGIRequest, slug: str):
"""View to manage contributors of a video."""
video = get_object_or_404(Video, slug=slug, sites=get_current_site(request))
page_title = get_completion_home_page_title(video)
if request.user != video.owner and not (
request.user.is_superuser
or request.user.has_perm("completion.add_contributor")
Expand Down Expand Up @@ -256,35 +264,40 @@ def video_completion_contributor(request, slug):
request,
"video_completion.html",
{
"page_title": page_title,
"video": video,
"list_contributor": list_contributor,
"list_track": list_track,
"list_document": list_document,
"list_overlay": list_overlay,
"page_title": _("Video additions"),
},
)
else:
return render(
request,
"video_completion.html",
{
"page_title": page_title,
"video": video,
"list_contributor": list_contributor,
"page_title": _("Video additions"),
},
)


def video_completion_contributor_new(request, video):
def video_completion_contributor_new(request: WSGIRequest, video: Video):
"""View to add new contributor to a video."""
form_contributor = ContributorForm(initial={"video": video})
context = get_video_completion_context(video, form_contributor=form_contributor)
context["page_title"] = _("Add a new contributor to the video “%s”") % video.title
if request.is_ajax():
return render(
request,
"contributor/form_contributor.html",
{"form_contributor": form_contributor, "video": video},
{
"page_title": context["page_title"],
"form_contributor": form_contributor,
"video": video,
},
)
else:
return render(
Expand All @@ -294,7 +307,7 @@ def video_completion_contributor_new(request, video):
)


def video_completion_contributor_save(request, video):
def video_completion_contributor_save(request: WSGIRequest, video: Video):
"""View to save contributors of a video."""
form_contributor = None
if request.POST.get("contributor_id") and request.POST["contributor_id"] != "None":
Expand All @@ -309,7 +322,12 @@ def video_completion_contributor_save(request, video):
some_data_to_dump = {
"list_data": render_to_string(
"contributor/list_contributor.html",
{"list_contributor": list_contributor, "video": video},
{
"page_title": _("Add a new contributor to the video “%s”")
% video.title,
"list_contributor": list_contributor,
"video": video,
},
request=request,
),
}
Expand All @@ -319,6 +337,10 @@ def video_completion_contributor_save(request, video):
context = get_video_completion_context(
video, list_contributor=list_contributor
)
context["page_title"] = get_completion_home_page_title(video)
messages.add_message(
request, messages.SUCCESS, _("The contributor has been saved.")
)
return render(
request,
"video_completion.html",
Expand All @@ -330,54 +352,72 @@ def video_completion_contributor_save(request, video):
"errors": "{0}".format(_("Please correct errors")),
"form": render_to_string(
"contributor/form_contributor.html",
{"video": video, "form_contributor": form_contributor},
{
"page_title": _("Add a new contributor to the video “%s”")
% video.title,
"video": video,
"form_contributor": form_contributor,
},
request=request,
),
}
data = json.dumps(some_data_to_dump)
return HttpResponse(data, content_type="application/json")
context = get_video_completion_context(video, form_contributor=form_contributor)
context["page_title"] = get_completion_home_page_title(video)
return render(
request,
"video_completion.html",
context,
)


def video_completion_contributor_modify(request, video):
def video_completion_contributor_modify(request: WSGIRequest, video: Video):
"""View to modify a video contributor."""
contributor = get_object_or_404(Contributor, id=request.POST["id"])
form_contributor = ContributorForm(instance=contributor)
page_title = _("Edit the contributor “%s”") % contributor.name
if request.is_ajax():
return render(
request,
"contributor/form_contributor.html",
{"form_contributor": form_contributor, "video": video},
{
"page_title": page_title,
"form_contributor": form_contributor,
"video": video,
},
)
context = get_video_completion_context(video, form_contributor=form_contributor)
context["page_title"] = page_title
return render(
request,
"video_completion.html",
context,
)


def video_completion_contributor_delete(request, video):
def video_completion_contributor_delete(request: WSGIRequest, video: Video):
"""View to delete a video contributor."""
contributor = get_object_or_404(Contributor, id=request.POST["id"])
contributor.delete()
page_title = get_completion_home_page_title(video)
list_contributor = video.contributor_set.all()
if request.is_ajax():
some_data_to_dump = {
"list_data": render_to_string(
"contributor/list_contributor.html",
{"list_contributor": list_contributor, "video": video},
{
"page_title": page_title,
"list_contributor": list_contributor,
"video": video,
},
request=request,
)
}
data = json.dumps(some_data_to_dump)
return HttpResponse(data, content_type="application/json")
context = get_video_completion_context(video)
context["page_title"] = page_title
return render(
request,
"video_completion.html",
Expand Down
2 changes: 1 addition & 1 deletion pod/cut/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def cut_video(request, slug): # noqa: C901

start_encode(video.id)

messages.add_message(request, messages.INFO, _("The cut was made."))
messages.add_message(request, messages.SUCCESS, _("The cut was made."))
return redirect(reverse("video:dashboard"))

else:
Expand Down
8 changes: 6 additions & 2 deletions pod/dressing/templates/dressing_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

{% block breadcrumbs %}
{{ block.super }}
<li class="breadcrumb-item"><a href="{% url 'dressing:my_dressings' %}">{% trans 'My dressings' %}</a></li>
<li class="breadcrumb-item active" aria-current="page">{{page_title}}</li>
<li class="breadcrumb-item">
<a href="{% url 'dressing:my_dressings' %}">
{% trans 'My dressings' %}
</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{ page_title }}</li>
{% endblock %}

{% block page_content %}
Expand Down
66 changes: 32 additions & 34 deletions pod/dressing/templates/dressing_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@

{% endblock page_extra_head %}

{% block breadcrumbs %}{{ block.super }}
<li class="breadcrumb-item">
<a href="{% url 'dressing:my_dressings' %}">
{% trans 'My dressings' %}
</a>
</li>
{% block breadcrumbs %}
{{ block.super }}
<li class="breadcrumb-item">
<a href="{% url 'dressing:my_dressings' %}">
{% trans 'My dressings' %}
</a>
</li>

<li class="breadcrumb-item active" aria-current="page">
{% if form.instance.title %}{% trans "Editing the dressing" %} "{{form.instance.title}}"
{% else %}
{% trans "Create a new dressing" %}
{% endif %}
</li>
<li class="breadcrumb-item active" aria-current="page">
{{ page_title }}
</li>
{% endblock %}

{% block page_content %}
<form method="POST" accept-charset="utf-8" enctype="multipart/form-data">
<form method="POST" accept-charset="utf-8" enctype="multipart/form-data">
{% csrf_token %}
<div class="list-group">
<h2 class="accordion-header">
Expand All @@ -33,30 +31,30 @@ <h2 class="accordion-header">
<p class="text-danger">{% trans "One or more errors have been found in the form." %}</p>
{% endif %}
{% for field_hidden in form.hidden_fields %}
{{field_hidden}}
{{ field_hidden }}
{% endfor %}
{% for field in form.visible_fields %}
{% spaceless %}
<div class="{% if "title_" in field.name %} title{% endif %}">
<div class="list-group-item p-2 mb-2">
<div class="{% if field.name == "owners" or field.name == "users" %}form-row {% endif %}form-group {% if field.field.required %}form-group-required {% endif %}">
{{ field.errors }}
{% if "form-check-input" in field.field.widget.attrs.class %}
<div class="form-check">
{{ field }} <label for="{{ field.id_for_label }}" class="form-check-label">{{ field.label }}</label>
</div>
{% else %}
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% endif %}
{% if field.help_text %}
<small id="{{field.id_for_label}}Help" class="form-text">{{ field.help_text|safe }}</small>
{% endif %}
{% if field.field.required %}<div class="invalid-feedback">{% trans "Please provide a valid value for this field." %}</div>{% endif %}
{% spaceless %}
<div class="{% if "title_" in field.name %} title{% endif %}">
<div class="list-group-item p-2 mb-2">
<div class="{% if field.name == "owners" or field.name == "users" %}form-row {% endif %}form-group {% if field.field.required %}form-group-required {% endif %}">
{{ field.errors }}
{% if "form-check-input" in field.field.widget.attrs.class %}
<div class="form-check">
{{ field }} <label for="{{ field.id_for_label }}" class="form-check-label">{{ field.label }}</label>
</div>
{% else %}
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% endif %}
{% if field.help_text %}
<small id="{{field.id_for_label}}Help" class="form-text">{{ field.help_text|safe }}</small>
{% endif %}
{% if field.field.required %}<div class="invalid-feedback">{% trans "Please provide a valid value for this field." %}</div>{% endif %}
</div>
</div>
</div>
</div>
{% endspaceless %}
{% endspaceless %}
{% endfor %}
</div>
<div class="text-center">
Expand All @@ -74,5 +72,5 @@ <h2 class="accordion-header">
<script src="{% static 'admin/js/core.js' %}?ver={{VERSION}}"></script>
<script src="{% static 'js/video_dressing.js' %}?ver={{VERSION}}"></script>
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/widgets.css' %}?ver={{VERSION}}" />
{{form.media}}
{{ form.media }}
{% endblock more_script %}
Loading

0 comments on commit 924af8a

Please sign in to comment.