Skip to content

Commit

Permalink
[DONE] Fanfounet / webtv speaker app (#1145)
Browse files Browse the repository at this point in the history
* add speaker app and admin files

* add in progress speaker management

* recopie après pb guardian

* recopie sauvegarde

* add init migrations file

* add use speaker in test settings

* change lang

* update fix

---------

Co-authored-by: Charneau Franck <[email protected]>
  • Loading branch information
fanfounet and Charneau Franck authored Jul 10, 2024
1 parent e9515aa commit c331882
Show file tree
Hide file tree
Showing 42 changed files with 1,779 additions and 177 deletions.
13 changes: 11 additions & 2 deletions CONFIGURATION_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ Set `USE_AI_ENHANCEMENT` to True to activate this application.<br>
* `AI_ENHANCEMENT_CGU_URL`
> default value: ``
>> URL for General Terms and Conditions for API uses for the AI video enhancement.<br>
>> Example: 'https://aristote.univ.fr/cgu'<br>
>> Project Link: https://www.demainestingenieurs.centralesupelec.fr/aristote/<br>
>> Example: '<https://aristote.univ.fr/cgu>'<br>
>> Project Link: <https://www.demainestingenieurs.centralesupelec.fr/aristote/><br>
* `AI_ENHANCEMENT_CLIENT_ID`
> default value: `mocked_id`
>> The video enhancement AI client ID.<br>
Expand Down Expand Up @@ -622,6 +622,15 @@ Set `USE_DRESSING` to True to activate this application.<br>
###


### Seaker application configuration

Speaker application to add speakers to video.<br>
Set `USE_SPEAKER` to True to activate this application.<br>

* `USE_SPEAKER`
> default value: `False`
>> Activation of the Speaker application<br>
### Video import application configuration

Import_video app to import external videos into Pod.<br>
Expand Down
9 changes: 9 additions & 0 deletions CONFIGURATION_FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,15 @@ Mettre `USE_DRESSING` à True pour activer cette application.<br>
### Configuration de l’application enrichment
### Configuration de l’application Intervenant
Application Intervenant permettant d'ajouter des intervenants à la vidéo.<br>
Mettre `USE_SPEAKER` à True pour activer cette application.<br>
* `USE_SPEAKER`
> valeur par défaut : `False`
>> Activation de l’application Intervenant<br>
### Configuration de l’application d’import vidéo
Application Import_video permettant d’importer des vidéos externes dans Pod.<br>
Expand Down
2 changes: 1 addition & 1 deletion pod/completion/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Contributor(models.Model):

video = models.ForeignKey(Video, verbose_name=_("video"), on_delete=models.CASCADE)
name = models.CharField(
verbose_name=_("lastname / firstname"), max_length=200, default=""
verbose_name=_("last name / first name"), max_length=200, default=""
)
email_address = models.EmailField(
verbose_name=_("mail"), null=True, blank=True, default=""
Expand Down
5 changes: 5 additions & 0 deletions pod/completion/static/js/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var ajaxfail = function (data, form) {
document.addEventListener("submit", (e) => {
if (
e.target.id !== "form_new_contributor" &&
e.target.id !== "form_new_speaker" &&
e.target.id !== "form_new_document" &&
e.target.id !== "form_new_track" &&
e.target.id !== "form_new_overlay" &&
Expand Down Expand Up @@ -219,6 +220,10 @@ var sendAndGetForm = async function (elt, action, name, form, list) {
deleteConfirm = confirm(
gettext("Are you sure you want to delete this contributor?"),
);
} else if (name === "speaker") {
deleteConfirm = confirm(
gettext("Are you sure you want to delete this speaker?"),
);
} else if (name === "document") {
deleteConfirm = confirm(
gettext("Are you sure you want to delete this document?"),
Expand Down
2 changes: 1 addition & 1 deletion pod/completion/templates/contributor/list_contributor.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<caption>{% trans 'List of contributors' %}&nbsp;({{list_contributor|length}})</caption>
<thead>
<tr>
<th scope="col" class="contributor-name">{% trans 'Lastname / Firstname' %}</th>
<th scope="col" class="contributor-name">{% trans 'Last name / First name' %}</th>
<th scope="col">{% trans 'Mail' %}</th>
<th scope="col">{% trans 'Role' %}</th>
<th scope="col">{% trans 'Web link' %}</th>
Expand Down
40 changes: 40 additions & 0 deletions pod/completion/templates/video_completion.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ <h2 class="accordion-header">
</div>

{% if request.user.is_staff %}
{% if USE_SPEAKER %}
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#compSpeakers" aria-expanded="false" aria-controls="compSpeakers">
{% trans 'Speaker(s)' %}
</button>
</h2>
<div id="compSpeakers" class="accordion-collapse collapse">
<div class="accordion-body">
{% include 'speaker/list_speaker.html' %}
<span id="form_speaker">
{% if form_speaker %}
{% include 'speaker/form_speaker.html' with form_speaker=form_speaker %}
{% endif %}
</span>
<form class="form_new completion" id="form_new_speaker" action="{% url 'video:completion:video_completion_speaker' slug=video.slug %}" method="POST">
{% csrf_token %}
<input type="hidden" name="action" value="new">
<input type="submit" value="{% trans 'Add a new speaker' %}" class="new_speaker btn btn-primary">
</form>
</div>
</div>
</div>
{% endif %}


<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#compSubtitles" aria-expanded="false" aria-controls="compSubtitles">
Expand Down Expand Up @@ -175,6 +201,18 @@ <h2 class="card-header card-title pod-card__title h4">{% trans "Help"%}</h2>
<p>{% trans 'A contributor must at least have a name and a role. You can also join the email of this contributor as well as a link (professional website for example).' %}</p>
</div>
</div>
<!-- Speaker -->
{% if USE_SPEAKER %}
<div id="speaker-info">
<button class="btn btn-link rounded-0 pod-btn" id="heading-5" data-bs-toggle="collapse" data-bs-target="#collapse-speaker" aria-expanded="false" aria-controls="collapse-speaker">
{% trans 'Speaker(s)' %}
</button>
<div id="collapse-speaker" class="collapse card-text small">
<p>{% trans 'List of speakers related to this video.' %}</p>
<p>{% trans "You can add speakers to this video by searching by their last name, first name or job. If you can't find the speaker, contact a super admin." %}</p>
</div>
</div>
{% endif %}
<div id="track-info">
<button class="btn btn-link rounded-0 pod-btn" id="heading-2" data-bs-toggle="collapse" data-bs-target="#collapse-track" aria-expanded="false" aria-controls="collapse-track">
{% trans 'Subtitle(s) and Caption(s)' %}
Expand Down Expand Up @@ -240,5 +278,7 @@ <h2 class="card-header card-title pod-card__title h4">{% trans "Help"%}</h2>
{% endblock page_aside %}

{% block more_script %}
<script src="{% static 'admin/js/vendor/select2/select2.full.min.js' %}?ver={{VERSION}}"></script>
<script src="{% static 'django_select2/django_select2.js' %}?ver={{VERSION}}"></script>
<script src="{% static 'js/completion.js' %}?ver={{VERSION}}"></script>
{% endblock more_script %}
6 changes: 6 additions & 0 deletions pod/completion/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .views import video_completion
from .views import video_caption_maker
from .views import video_completion_contributor
from .views import video_completion_speaker
from .views import video_completion_document
from .views import video_completion_track
from .views import video_completion_overlay
Expand All @@ -21,6 +22,11 @@
video_completion_contributor,
name="video_completion_contributor",
),
url(
r"^speaker/(?P<slug>[\-\d\w]+)/$",
video_completion_speaker,
name="video_completion_speaker",
),
url(
r"^document/(?P<slug>[\-\d\w]+)/$",
video_completion_document,
Expand Down
9 changes: 8 additions & 1 deletion pod/completion/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""Esup-Pod completion app utilities."""

from django.utils.translation import ugettext as _
from pod.speaker.utils import get_video_speakers


def get_video_completion_context(
video,
list_contributor=None,
list_speaker=None,
list_document=None,
list_track=None,
list_overlay=None,
form_contributor=None,
form_speaker=None,
form_document=None,
form_track=None,
form_overlay=None,
Expand All @@ -18,11 +21,13 @@ def get_video_completion_context(
Return a dictionary containing information extracted from the video.
and its associated objects
(video, list of contributors, list of documents, track and overlay,
(video, list of contributors, list of speakers, list of documents, track and overlay,
as well as forms for creating or updating these objects)
"""
if list_contributor is None:
list_contributor = video.contributor_set.all()
if list_speaker is None:
list_speaker = get_video_speakers(video)
if list_document is None:
list_document = video.document_set.all()
if list_track is None:
Expand All @@ -33,10 +38,12 @@ def get_video_completion_context(
context = {
"video": video,
"list_contributor": list_contributor,
"list_speaker": list_speaker,
"list_document": list_document,
"list_track": list_track,
"list_overlay": list_overlay,
"form_contributor": form_contributor,
"form_speaker": form_speaker,
"form_document": form_document,
"form_track": form_track,
"form_overlay": form_overlay,
Expand Down
Loading

0 comments on commit c331882

Please sign in to comment.