Skip to content

Commit

Permalink
Merge pull request #187 from EsupPortail/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
ptitloup authored Dec 2, 2019
2 parents 0162f92 + 98206b2 commit 3e3e2c2
Show file tree
Hide file tree
Showing 33 changed files with 1,268 additions and 252 deletions.
9 changes: 8 additions & 1 deletion pod/authentication/populatedCASbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"mail": "mail",
"last_name": "sn",
"first_name": "givenname",
"primaryAffiliation": "eduPersonPrimaryAffiliation",
"affiliation": "eduPersonAffiliation"
})

Expand Down Expand Up @@ -198,6 +199,13 @@ def populate_user_from_tree(user, owner, tree):
last_name_element.text if last_name_element is not None else ""
)
user.save()
# PrimaryAffiliation
primary_affiliation_element = tree.find(
'.//{http://www.yale.edu/tp/cas}%s' % (
USER_CAS_MAPPING_ATTRIBUTES["primaryAffiliation"])
)
owner.affiliation = primary_affiliation_element.text if (
primary_affiliation_element is not None) else AFFILIATION[0][0]
# affiliation
affiliation_element = tree.findall(
'.//{http://www.yale.edu/tp/cas}%s' % (
Expand All @@ -211,5 +219,4 @@ def populate_user_from_tree(user, owner, tree):
name=affiliation.text)
user.groups.add(group)
user.save()
owner.affiliation = affiliation_element[0].text
owner.save()
2 changes: 1 addition & 1 deletion pod/chapter/templates/video_chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</div>
{% endblock page_content %}
{% block page_aside %}
{% if video.owner == request.user or request.user.is_superuser %}
{% if video.owner == request.user or request.user.is_superuser or request.user in video.additional_owners.all %}
<div class="card card-body p-2 mt-1" id="card-managevideo">
<h5 class="card-title pl-2"><i data-feather="settings"></i>&nbsp;{% trans "Manage video"%}</h5>
<div class="card-text text-center">
Expand Down
6 changes: 4 additions & 2 deletions pod/chapter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
@login_required(redirect_field_name='referrer')
def video_chapter(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot chapter this video.'))
return HttpResponseForbidden(u'Only the owner can add chapter.')
return HttpResponseForbidden(u'Only the owner and additional owners '
'can add chapter.')

list_chapter = video.chapter_set.all()

Expand Down
2 changes: 1 addition & 1 deletion pod/completion/templates/video_completion.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
{% endblock page_content %}

{% block page_aside %}
{% if video.owner == request.user or request.user.is_superuser %}
{% if video.owner == request.user or request.user.is_superuser or request.user in video.additional_owners.all %}
<div class="card card-body p-2 mt-1" id="card-managevideo">
<h5 class="card-title pl-2"><i data-feather="settings"></i>&nbsp;{% trans "Manage video"%}</h5>
<div class="card-text text-center">
Expand Down
18 changes: 12 additions & 6 deletions pod/completion/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def video_caption_maker(request, slug):
user_home_folder = get_object_or_404(
UserFolder, name="home", owner=request.user)
action = None
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot complement this video.'))
raise PermissionDenied
Expand Down Expand Up @@ -85,7 +86,8 @@ def video_caption_maker_save(request, video):
@login_required(redirect_field_name='referrer')
def video_completion(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot complement this video.'))
raise PermissionDenied
Expand Down Expand Up @@ -118,7 +120,8 @@ def video_completion(request, slug):
@login_required(redirect_field_name='referrer')
def video_completion_contributor(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot complement this video.'))
raise PermissionDenied
Expand Down Expand Up @@ -297,7 +300,8 @@ def video_completion_contributor_delete(request, video):
@staff_member_required(redirect_field_name='referrer')
def video_completion_document(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot complement this video.'))
raise PermissionDenied
Expand Down Expand Up @@ -473,7 +477,8 @@ def video_completion_document_delete(request, video):
@staff_member_required(redirect_field_name='referrer')
def video_completion_track(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot complement this video.'))
raise PermissionDenied
Expand Down Expand Up @@ -690,7 +695,8 @@ def get_simple_url(overlay):
@staff_member_required(redirect_field_name='referrer')
def video_completion_overlay(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot complement this video.'))
raise PermissionDenied
Expand Down
14 changes: 9 additions & 5 deletions pod/enrichment/templates/enrichment/edit_enrichment.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
{% block page_title %}{% trans 'Enrichment of the video' %} "{{video.title}}" {% endblock page_title %}

{% block page_extra_head %}

{{ block.super }}

<link rel="stylesheet" href="{% static 'css/enrichment.css' %}"/>
<script src="{% static 'js/enrichment.js' %}"></script>

<!-- form.media -->
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>

Expand Down Expand Up @@ -35,11 +38,11 @@
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
{% if video.enrichmentvtt.src %}
<track kind="metadata" src="{{video.enrichmentvtt.src.file.url}}">
{% endif %}

<track kind="metadata" src="{{video.enrichmentvtt.src.file.url}}?{% now "U" %}" label="enrichment">

{% for track in video.track_set.all%}
<track id= "track_{{ track.id }}" kind="{{ track.kind }}" src="{{ track.src.url }}" srclang="{{ track.lang }}" label="{{track.get_label_lang}}">
<track id= "track_{{ track.id }}" kind="{{ track.kind }}" src="{{ track.src.url }}?{% now "U" %}" srclang="{{ track.lang }}" label="{{track.get_label_lang}}">
{%endfor%}
</video>
<hr/>
Expand Down Expand Up @@ -71,13 +74,14 @@
</div>
</div>
{% endblock video-element %}

{% block page_aside %}
<div class="card card-body p-2 mt-1" id="card-enrichmenteditinformations">
<h5 class="card-title pl-2">
<i data-feather="info"></i>&nbsp;{% trans 'Informations' %}
</h5>
<div class="card-text small">
{% if video.owner == request.user or request.user.is_superuser %}
{% if video.owner == request.user or request.user.is_superuser or request.user in video.additional_owners.all %}
<p><a href="{% url 'enrichment:group_enrichment' slug=video.slug %}" title="{% trans 'You can specify the group(s) of users who can access this page' %}"><i data-feather="users"></i>&nbsp;{% trans 'You can specify the group(s) of users who can access this page' %}</a></p>
{% endif %}
<p>{% trans 'The title field is required and must contains from 2 to 100 characters.' %}</p>
Expand Down
2 changes: 1 addition & 1 deletion pod/enrichment/templates/enrichment/group_enrichment.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3>{% trans "Editing group for the enrichment of the video" %} "{{video.title}}
{% endblock page_content %}

{% block page_aside %}
{% if video.owner == request.user or request.user.is_superuser %}
{% if video.owner == request.user or request.user.is_superuser or request.user in video.additional_owners.all %}
<div class="card card-body p-2 mt-1" id="card-managevideo">
<h5 class="card-title pl-2"><i data-feather="settings"></i>&nbsp;{% trans "Manage video"%}</h5>
<div class="card-text text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
<track kind="metadata" src="{{video.enrichmentvtt.src.file.url}}" label="enrichment">
<track kind="metadata" src="{{video.enrichmentvtt.src.file.url}}?{% now "U" %}" label="enrichment">

{% for track in video.track_set.all%}
<track id= "track_{{ track.id }}" kind="{{ track.kind }}" src="{{ track.src.url }}" srclang="{{ track.lang }}" label="{{track.get_label_lang}}">
<track id= "track_{{ track.id }}" kind="{{ track.kind }}" src="{{ track.src.url }}?{% now "U" %}" srclang="{{ track.lang }}" label="{{track.get_label_lang}}">
{%endfor%}
</video>

Expand Down
12 changes: 8 additions & 4 deletions pod/enrichment/templates/enrichment/video_enrichment.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
<track kind="metadata" src="{{video.enrichmentvtt.src.file.url}}" label="enrichment">
<track kind="metadata" src="{{video.enrichmentvtt.src.file.url}}?{% now "U" %}" label="enrichment">

{% for track in video.track_set.all%}
<track id= "track_{{ track.id }}" kind="{{ track.kind }}" src="{{ track.src.url }}" srclang="{{ track.lang }}" label="{{track.get_label_lang}}">
<track id= "track_{{ track.id }}" kind="{{ track.kind }}" src="{{ track.src.url }}?{% now "U" %}" srclang="{{ track.lang }}" label="{{track.get_label_lang}}">
{%endfor%}
</video>

Expand Down Expand Up @@ -165,7 +165,9 @@ <h5 class="card-title pl-2">
{% endblock page_aside %}

{% block more_script %}

{{block.super}}

{% if video.enrichment_set.all %}
<script>
{% if not video.is_video %}
Expand Down Expand Up @@ -193,9 +195,10 @@ <h5 class="card-title pl-2">
}
});
} else {
//console.log(metadataTrack.cues.length);
for (i = 0; i < metadataTrack.cues.length; i++) {
data = JSON.parse(metadataTrack.cues[i].text);
console.log('Parsed '+data.title)
//console.log('Parsed '+data.title)
slide.push({
title: data.title,
url: data.url,
Expand All @@ -207,7 +210,7 @@ <h5 class="card-title pl-2">
}
}
if (typeof player.slides === "function") {
console.log('Call player.slides');
//console.log('Call player.slides');
player.slides(slide);
}

Expand All @@ -218,4 +221,5 @@ <h5 class="card-title pl-2">
});
</script>
{% endif %}

{% endblock more_script %}
6 changes: 4 additions & 2 deletions pod/enrichment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def group_enrichment(request, slug):
video = get_object_or_404(Video, slug=slug)
enrichmentGroup, created = EnrichmentGroup.objects.get_or_create(
video=video)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR, _(u'You cannot enrich this video.'))
raise PermissionDenied
Expand Down Expand Up @@ -62,7 +63,8 @@ def check_enrichment_group(request, video):
@staff_member_required(redirect_field_name='referrer')
def edit_enrichment(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
if not check_enrichment_group(request, video):
messages.add_message(
request, messages.ERROR, _(u'You cannot enrich this video.'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h5 class="card-title pl-2">
</p>
</div>
</div>
{% if video.owner == request.user or request.user.is_superuser %}
{% if video.owner == request.user or request.user.is_superuser or request.user in video.additional_owners.all %}
<div class="card card-body p-2 mt-1" id="card-managevideo">
<h5 class="card-title pl-2"><i data-feather="settings"></i>&nbsp;{% trans "Manage video"%}</h5>
<div class="card-text text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3>{% trans "Editing group for the interactivity of the video" %} "{{video.titl
{% endblock page_content %}

{% block page_aside %}
{% if video.owner == request.user or request.user.is_superuser %}
{% if video.owner == request.user or request.user.is_superuser or request.user in video.additional_owners.all %}
<div class="card card-body p-2 mt-1" id="card-managevideo">
<h5 class="card-title pl-2"><i data-feather="settings"></i>&nbsp;{% trans "Manage video"%}</h5>
<div class="card-text text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h5><i data-feather="star"></i>&nbsp;{% trans 'Scoreboard' %}</h5>
<i>{% trans 'Click below to refresh the information.' %}</i>
<button type="submit" class="btn btn-info btn-sm" id="refresh-score" ><i data-feather="refresh-cw"></i></button>
<br>
{% if more_data.score and request.user == video.owner or request.user.is_superuser %}
{% if more_data.score and request.user == video.owner or request.user.is_superuser or request.user in video.additional_owners.all %}
<i>{% trans 'The scoreboard displays the users who viewed your interactive video and their results.' %}</i>
<table class="table">
<thead>
Expand Down
9 changes: 6 additions & 3 deletions pod/interactive/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def group_interactive(request, slug):
video = get_object_or_404(Video, slug=slug)
interactiveGroup, created = InteractiveGroup.objects.get_or_create(
video=video)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
messages.add_message(
request, messages.ERROR,
_('You cannot add interactivity to this video.')
Expand Down Expand Up @@ -61,7 +62,8 @@ def check_interactive_group(request, video):
@staff_member_required(redirect_field_name='referrer')
def edit_interactive(request, slug):
video = get_object_or_404(Video, slug=slug)
if request.user != video.owner and not request.user.is_superuser:
if request.user != video.owner and not request.user.is_superuser and (
request.user not in video.additional_owners.all()):
if not check_interactive_group(request, video):
messages.add_message(
request, messages.ERROR,
Expand Down Expand Up @@ -106,7 +108,8 @@ def video_interactive(request, slug, slug_c=None,
if h5p is None:
raise Http404("Interactive video does not exist")
score = getUserScore(h5p.content_id) if (
request.user == video.owner or request.user.is_superuser
request.user == video.owner or request.user.is_superuser or (
request.user in video.additional_owners.all())
) else getUserScore(h5p.content_id, request.user)

try:
Expand Down
Binary file modified pod/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 3e3e2c2

Please sign in to comment.