Skip to content

Commit

Permalink
[DONE] Bugfixes & improvements - 3.5.0 (#1023)
Browse files Browse the repository at this point in the history
* Fix dashboard styles

* Fix dashboard translation

* Modify Twitter icon & improve chapter style

* Fix plural translations & z-index

* Improve accessibility

* Fix channels & some improvements

* Fix dressing form

* Fix roles optgroup

* Update Pillow & sorl-thumbnail

* Add some unit tests
  • Loading branch information
AymericJak authored Jan 26, 2024
1 parent b229dad commit 9e5068a
Show file tree
Hide file tree
Showing 35 changed files with 505 additions and 345 deletions.
2 changes: 1 addition & 1 deletion pod/bbb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Livestream(models.Model):
)
# If the user wants to download the video of this meeting after the live
download_meeting = models.BooleanField(
verbose_name=_("Save meeting in Dashboard"),
verbose_name=_("Save meeting in dashboard"),
help_text=_(
"Do you want to save the video of "
"this meeting, at the end of the live, directly in “Dashboard“?"
Expand Down
4 changes: 0 additions & 4 deletions pod/chapter/static/css/videojs-chapters.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
display: block;
}

.chapters-list h6 {
text-align: center;
}

.chapters-list.active p,
.chapters-list.inactive p {
text-align: center;
Expand Down
42 changes: 39 additions & 3 deletions pod/chapter/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Unit tests for chapters views
"""
"""Unit tests for chapters views."""

from django.conf import settings
from django.test import TestCase
Expand Down Expand Up @@ -219,3 +217,41 @@ def test_video_chapter_import(self):
self.assertEqual(result.title, "Testchapter")

print(" ---> test_video_chapter_import: OK!")

def test_video_chapter_modify(self):
video = Video.objects.get(id=1)
Chapter.objects.create(
title="Test Chapter",
video=video,
time_start=10,
)
url = reverse("video:chapter:video_chapter", kwargs={"slug": video.slug})
authenticate(username="test", password="hello")
login = self.client.login(username="test", password="hello")
self.assertTrue(login)

response_create = self.client.post(
url,
data={
"action": "save",
"video": video.id,
"title": "Test Chapter",
"time_start": 10,
},
)
self.assertEqual(response_create.status_code, 200)
created_chapter = Chapter.objects.get(title="Test Chapter")
response_modify = self.client.post(
url,
data={
"action": "modify",
"id": created_chapter.id,
},
)

self.assertEqual(response_modify.status_code, 200)
self.assertTemplateUsed(response_modify, "chapter/form_chapter.html")
form_chapter = response_modify.context["form_chapter"]
self.assertEqual(form_chapter.instance, created_chapter)

print(" ---> test_video_chapter_modify: OK!")
34 changes: 22 additions & 12 deletions pod/completion/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,28 @@
settings,
"ROLE_CHOICES",
(
("actor", _("actor")),
("author", _("author")),
("designer", _("designer")),
("consultant", _("consultant")),
("contributor", _("contributor")),
("editor", _("editor")),
("speaker", _("speaker")),
("soundman", _("soundman")),
("director", _("director")),
("writer", _("writer")),
("technician", _("technician")),
("voice-over", _("voice-over")),
(_("Acting roles"), (
("actor", _("Actor")),
("voice-over", _("Voice-over")),
)),
(_("Creative roles"), (
("author", _("Author")),
("designer", _("Designer")),
("editor", _("Editor")),
("writer", _("Writer")),
)),
(_("Consulting roles"), (
("consultant", _("Consultant")),
)),
(_("Production roles"), (
("contributor", _("Contributor")),
("director", _("Director")),
("technician", _("Technician")),
("soundman", _("Soundman")),
)),
(_("Speaking roles"), (
("speaker", _("Speaker")),
)),
),
)
KIND_CHOICES = getattr(
Expand Down
51 changes: 51 additions & 0 deletions pod/cut/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from django.test import TestCase
from pod.cut.utils import clean_database
from pod.video.models import Notes, AdvancedNotes, Type, Video
from pod.chapter.models import Chapter
from pod.completion.models import Overlay, Track
from django.contrib.auth.models import User


class CleanDatabaseTest(TestCase):
fixtures = ["initial_data.json"]

def setUp(self):
self.user = User.objects.create(username="pod", password="pod1234pod")
self.video = Video.objects.create(
title="Video1",
owner=self.user,
video="test.mp4",
is_draft=False,
type=Type.objects.get(id=1),
)
self.chapter = Chapter.objects.create(video=self.video, title="Chapter 1")
self.advanced_notes = AdvancedNotes.objects.create(
video=self.video,
user=self.user,
note="Advanced note content"
)
self.notes = Notes.objects.create(
video=self.video, user=self.user, note="Note content")
self.overlay = Overlay.objects.create(video=self.video, title="Overlay 1")
self.track = Track.objects.create(video=self.video)

def test_clean_database(self):
"""Test if clean_database works correctly."""
# Check if the models exist before cleaning
self.assertTrue(Chapter.objects.filter(video=self.video).exists())
self.assertTrue(AdvancedNotes.objects.filter(video=self.video).exists())
self.assertTrue(Notes.objects.filter(video=self.video).exists())
self.assertTrue(Overlay.objects.filter(video=self.video).exists())
self.assertTrue(Track.objects.filter(video=self.video).exists())

# Call clean_database
clean_database(self.video)

# Check if the models are deleted after cleaning
self.assertFalse(Chapter.objects.filter(video=self.video).exists())
self.assertFalse(AdvancedNotes.objects.filter(video=self.video).exists())
self.assertFalse(Notes.objects.filter(video=self.video).exists())
self.assertFalse(Overlay.objects.filter(video=self.video).exists())
self.assertFalse(Track.objects.filter(video=self.video).exists())

print(" ---> test_clean_database ok")
14 changes: 5 additions & 9 deletions pod/dressing/templates/dressing_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@
</a>
</li>

<li class="breadcrumb-item active" aria-current="page">
<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>
{% endblock %}

{% block page_title %}
{% if form.instance.title %}{% trans "Editing the dressing" %} "{{form.instance.title}}"
{% else %}
{% trans "Create a new dressing" %}
{% endif %}
{% endblock %}

{% block page_content %}
<form method="POST" accept-charset="utf-8" enctype="multipart/form-data">
{% csrf_token %}
<div class="list-group">
<h2 class="accordion-header">
{% trans "General settings" %}
</h2>
{% if form.errors %}
<p class="text-danger">{% trans "One or more errors have been found in the form." %}</p>
{% endif %}
Expand All @@ -42,7 +38,7 @@
{% for field in form.visible_fields %}
{% spaceless %}
<div class="{% if "title_" in field.name %} title{% endif %}">
<div class="list-group-item">
<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 %}
Expand Down
2 changes: 1 addition & 1 deletion pod/dressing/templates/my_dressings.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
{% endfor %}
</tbody>
</table>
<a href="{% url 'dressing:dressing_create' %}" class="btn btn-primary" title="{% trans 'Add new object' %}" data-bs-toggle="tooltip" data-bs-placement="top">{% trans 'Add new object' %}</a>
<a href="{% url 'dressing:dressing_create' %}" class="btn btn-primary" title="{% trans 'Add new dressing' %}" data-bs-toggle="tooltip" data-bs-placement="top">{% trans 'Add new dressing' %}</a>
{% endblock page_content %}

{% block collapse_page_aside %}
Expand Down
33 changes: 33 additions & 0 deletions pod/dressing/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Unit tests for Esup-Pod dressing views."""

from django.contrib.auth.models import User
from django.test import TestCase

from pod.dressing.models import Dressing

from pod.video.models import Type, Video


class VideoDressingViewTest(TestCase):
"""Dressing page test case."""

fixtures = ["initial_data.json"]

def setUp(self) -> None:
self.user = User.objects.create_user(username='user', password='password', is_staff=1)
self.first_video = Video.objects.create(
title="First video",
slug="first-video",
owner=self.user,
video="first_video.mp4",
is_draft=False,
type=Type.objects.get(id=1),
)
self.dressing = Dressing.objects.create(title='Test Dressing')
self.dressing.owners.set([self.user])
self.dressing.users.set([self.user])

def test_video_dressing_view(self):
"""Test for video_dressing view."""

print(" ---> test_video_dressing_view: OK! --- VideoDressingViewTest")
8 changes: 6 additions & 2 deletions pod/dressing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def dressing_edit(request, dressing_id):
)
form_dressing.save()
return redirect(reverse("dressing:my_dressings"))
page_title = f'{_("Editing the dressing")} {dressing_edit.title}'
page_title = f'{_("Editing the dressing")} "{dressing_edit.title}"'
return render(
request,
"dressing_edit.html",
Expand Down Expand Up @@ -137,7 +137,11 @@ def dressing_create(request):
return render(
request,
"dressing_edit.html",
{"dressing_create": dressing_create, "form": form_dressing},
{
"dressing_create": dressing_create,
"page_title": _("Create a new dressing"),
"form": form_dressing
},
)


Expand Down
2 changes: 1 addition & 1 deletion pod/live/templates/live/event-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h2 class="modal-title h5" id="shareLabel">
</li>
<li class="list-inline-item">
<a target="_blank" href="https://twitter.com/share?url={{request.build_absolute_uri|urlencode}}" class="btn pod-btn pod-btn-social m-1" title="{% trans 'Share on' %} X (Twitter)" data-bs-toggle="tooltip" data-bs-placement="bottom">
<i class="bi bi-twitter" aria-hidden="true"></i>
<i class="bi bi-twitter-x" aria-hidden="true"></i>
<span class="visually-hidden">{% trans 'Share on X (Twitter)' %}</span>
</a>
</li>
Expand Down
5 changes: 3 additions & 2 deletions pod/live/templates/live/filter_aside.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2 class="card-title pod-card__title h4">

<form action="{% url 'live:events' %}" method="get" id="filters">
<fieldset class="border-right border-bottom mt-2">
<legend class="h5"><i class="bi bi-tv" aria-hidden="true"></i> {% trans "Types" %} </legend>
<legend class="h5"><i class="bi bi-tv" aria-hidden="true"></i>&nbsp;{% trans "Types" %} </legend>
<div id="filterType">
<div class="form-group collapse" id="collapseFilterType">
{% for type in types %}
Expand All @@ -37,7 +37,8 @@ <h2 class="card-title pod-card__title h4">
href="#collapseFilterType" role="button"
aria-expanded="false" aria-controls="collapseFilterType"
title="{% trans 'Fold/Unfold “Types” filters' %}">
</a></span>
</a>
</span>
{% endif %}
</div>
</fieldset>
Expand Down
Binary file modified pod/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 9e5068a

Please sign in to comment.