Skip to content

Commit

Permalink
Merge pull request #88 from EsupPortail/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ptitloup authored Sep 6, 2018
2 parents b7760ae + b76df23 commit 9014acb
Show file tree
Hide file tree
Showing 26 changed files with 1,381 additions and 1,092 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
{% block page_title %}{%if channel %}{{channel.title}} - {%endif%}{%if theme %}{{theme.title}} - {%endif%}({% trans 'Enriched' %}) {{video.title}}{% endblock %}

{% block video-element %}

{% if form %}
{% include 'videos/video-form.html' %}
{% else %}
<video id="podvideoplayer" class="video-js vjs-default-skin vjs-big-play-centered" preload="auto" height="360"
poster="{{video.get_thumbnail_url}}" data-setup='{}' {% if request.GET.nocontrol and request.GET.nocontrol == 'false' %} autoplay {%else%} controls {% if request.GET.autoplay and request.GET.autoplay == 'true' %} autoplay{%endif%}{%endif%} {% if request.GET.loop and request.GET.loop == 'true' %} loop{%endif%}>
<p class="vjs-no-js">
Expand All @@ -28,7 +30,7 @@
<form method="post" action="{% url 'video_count' id=video.id %}" id="video_count_form">
{% csrf_token %}
</form>

{% endif %}
{% endblock video-element %}


Expand Down
61 changes: 4 additions & 57 deletions pod/enrichment/views.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
from django.core.exceptions import PermissionDenied
from django.core.exceptions import SuspiciousOperation
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.shortcuts import render
from django.shortcuts import get_object_or_404
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import csrf_protect

from pod.video.models import Video, Channel, Theme
from pod.video.views import get_note_form, get_video_access
from pod.video.forms import VideoPasswordForm
from pod.video.models import Video
from pod.video.views import render_video

from .models import Enrichment, EnrichmentGroup
from .forms import EnrichmentForm, EnrichmentGroupForm
Expand Down Expand Up @@ -212,61 +208,12 @@ def edit_enrichment_cancel(request, video):
@csrf_protect
def video_enrichment(request, slug, slug_c=None,
slug_t=None, slug_private=None):
try:
id = int(slug[:slug.find("-")])
except ValueError:
raise SuspiciousOperation('Invalid video id')
video = get_object_or_404(Video, id=id)
notesForm = get_note_form(request, video)
channel = get_object_or_404(Channel, slug=slug_c) if slug_c else None
theme = get_object_or_404(Theme, slug=slug_t) if slug_t else None
playlist = None

template_video = 'enrichment/video_enrichment-iframe.html' if (
request.GET.get('is_iframe')) else 'enrichment/video_enrichment.html'

is_password_protected = (
video.password is not None and video.password != '')

show_page = get_video_access(request, video, slug_private)

if show_page:
return render(
request, template_video, {
'channel': channel,
'video': video,
'theme': theme,
'notesForm': notesForm,
'playlist': playlist
}
)
else:
if is_password_protected:
form = VideoPasswordForm(
request.POST) if request.POST else VideoPasswordForm()
return render(
request, 'enrichment/video_enrichment.html', {
'channel': channel,
'video': video,
'theme': theme,
'form': form,
'notesForm': notesForm
}
)
elif request.user.is_authenticated():
messages.add_message(
request, messages.ERROR,
_(u'You cannot watch this video.'))
raise PermissionDenied
else:
iframe_param = 'is_iframe=true&' if (
request.GET.get('is_iframe')) else ''
return redirect(
'%s?%sreferrer=%s' % (
settings.LOGIN_URL,
iframe_param,
request.get_full_path())
)
return render_video(request, slug, slug_c, slug_t, slug_private,
template_video, None)


"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends 'videos/video-iframe.html' %}
{% load i18n %}
{% load staticfiles %}

{% block page_extra_head %}
<style>
#h5pcontent {
margin: auto;
text-align: center;
background-color: black;
width: 100%;
height: 480px;
}
#icontent {
display: block;
margin: 0 auto;
width: 100%;
height: 100%;
background-color: black;
}
</style>
{% endblock page_extra_head %}

{% block page_title %}{%if channel %}{{channel.title}} - {%endif%}{%if theme %}{{theme.title}} - {%endif%}({% trans 'Interactive video' %}) {{video.title}}{% endblock %}

{% block video-element %}
{% if form %}
{% include 'videos/video-form.html' %}
{% else %}
<div id="h5pcontent">
<iframe id="icontent" src="{% url 'h5pp:h5pcontent' %}?contentId={{more_data.h5p.content_id}}&is_iframe=true" style="display:none;" frameBorder="0" allowfullscreen="allowfullscreen" scrolling="no"></iframe>
</div>
<form method="post" action="{% url 'video_count' id=video.id %}" id="video_count_form">
{% csrf_token %}
</form>
{% endif %}
{% endblock video-element %}


{% block more_script %}
{{block.super}}
<script>
var video_height = 0;
$('#icontent').on('load',function() {
$('#icontent').fadeIn('slow', function(){
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
$("#h5pcontent").height(video_height);
});
$('#icontent').contents().find("body").attr("style", "background-color:black");
});

</script>
{% endblock more_script %}
22 changes: 11 additions & 11 deletions pod/interactive/templates/interactive/video_interactive.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

{% else %}
<div id="h5pcontent">
<iframe id="icontent" src="{% url 'h5pp:h5pcontent' %}?contentId={{interactive.h5p.content_id}}&is_iframe=true" style="display:none;" frameBorder="0" allowfullscreen="allowfullscreen" scrolling="no"></iframe>
<iframe id="icontent" src="{% url 'h5pp:h5pcontent' %}?contentId={{more_data.h5p.content_id}}&is_iframe=true" style="display:none;" frameBorder="0" allowfullscreen="allowfullscreen" scrolling="no"></iframe>
</div>

<form method="post" action="{% url 'video_count' id=video.id %}" id="video_count_form">
Expand Down Expand Up @@ -76,7 +76,7 @@ <h3>{% trans 'Scoreboard' %}</h3>
<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 interactive.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 %}
<i>{% trans 'The scoreboard displays the users who viewed your interactive video and their results.' %}</i>
<table class="table">
<thead>
Expand All @@ -88,7 +88,7 @@ <h3>{% trans 'Scoreboard' %}</h3>
</tr>
</thead>
<tbody id="user-score">
{% for user in interactive.score %}
{% for user in more_data.score %}
{% if user.max_points and user.max_points != ".." %}
<tr>
<td>{{user.user}}</td>
Expand All @@ -108,8 +108,8 @@ <h3>{% trans 'Scoreboard' %}</h3>
</table>
{% elif request.user.is_authenticated %}
<div id="personnal-score">
{% if interactive.score %}
{% with interactive.score|first as userscore %}
{% if more_data.score %}
{% with more_data.score|first as userscore %}
{% trans 'You got the following score on this video' %}: {{userscore.points}} / {{userscore.max_points}}
{% endwith %}
{% else %}
Expand All @@ -119,8 +119,8 @@ <h3>{% trans 'Scoreboard' %}</h3>
{% else %}
<div id="personnal-score">
<p>{% trans 'You are watching this video as anonymous user'%}</p>
{% if interactive.score %}
{% with interactive.score|first as userscore %}
{% if more_data.score %}
{% with more_data.score|first as userscore %}
{% trans 'You got the following score on this video' %}: {{userscore.points}} / {{userscore.max_points}}
{% endwith %}
{% else %}
Expand All @@ -145,25 +145,25 @@ <h3>{% trans 'Scoreboard' %}</h3>
var video_height = 0;
$('#icontent').on('load',function() {
$('#icontent').fadeIn('slow', function(){
video_height = $('#icontent').contents().find("#h5p-iframe-{{interactive.h5p.content_id}}").height();
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
$("#h5pcontent").height(video_height);
});
});
$("#collapseAside").on('shown.bs.collapse', function () {
setTimeout(function (){
video_height = $('#icontent').contents().find("#h5p-iframe-{{interactive.h5p.content_id}}").height();
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
$("#h5pcontent").height(video_height);
}, 500);
});
$("#collapseAside").on('hidden.bs.collapse', function () {
setTimeout(function (){
video_height = $('#icontent').contents().find("#h5p-iframe-{{interactive.h5p.content_id}}").height();
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
$("#h5pcontent").height(video_height);
}, 500);
});
$(document).on('click', '#refresh-score', function() {
$.ajax({
url: '{% url "h5pp:h5pajax" %}?user-scores={{interactive.h5p.content_id}}',
url: '{% url "h5pp:h5pajax" %}?user-scores={{more_data.h5p.content_id}}',
type: 'GET',
success: function(list) {
var table = $('#user-score');
Expand Down
64 changes: 7 additions & 57 deletions pod/interactive/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from django.shortcuts import render
from django.conf import settings
from django.contrib import messages
from django.contrib.admin.views.decorators import staff_member_required
from django.core.exceptions import PermissionDenied
from django.core.exceptions import SuspiciousOperation
from django.shortcuts import get_object_or_404
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import csrf_protect

from pod.video.models import Video, Channel, Theme
from pod.video.views import get_note_form, get_video_access
from pod.video.forms import VideoPasswordForm
from pod.video.models import Video
from pod.video.views import render_video
from .models import Interactive, InteractiveGroup
from .forms import InteractiveGroupForm
from h5pp.models import h5p_contents, h5p_libraries
Expand Down Expand Up @@ -96,10 +93,9 @@ def video_interactive(request, slug, slug_c=None,
except ValueError:
raise SuspiciousOperation('Invalid video id')
video = get_object_or_404(Video, id=id)
notesForm = get_note_form(request, video)
channel = get_object_or_404(Channel, slug=slug_c) if slug_c else None
theme = get_object_or_404(Theme, slug=slug_t) if slug_t else None
playlist = None

template_video = 'interactive/video_interactive-iframe.html' if (
request.GET.get('is_iframe')) else 'interactive/video_interactive.html'

interactiveVideo, created = Interactive.objects.get_or_create(
video=video)
Expand All @@ -111,51 +107,5 @@ def video_interactive(request, slug, slug_c=None,
request.user == video.owner or request.user.is_superuser
) else getUserScore(h5p.content_id, request.user)

interactive = {'h5p': h5p, 'score': score}

template_video = 'interactive/video_interactive-iframe.html' if (
request.GET.get('is_iframe')) else 'interactive/video_interactive.html'

is_password_protected = (
video.password is not None and video.password != '')

show_page = get_video_access(request, video, slug_private)

if show_page:
return render(
request, template_video, {
'channel': channel,
'video': video,
'theme': theme,
'notesForm': notesForm,
'playlist': playlist,
'interactive': interactive
}
)
else:
if is_password_protected:
form = VideoPasswordForm(
request.POST) if request.POST else VideoPasswordForm()
return render(
request, 'interactive/video_interactive.html', {
'channel': channel,
'video': video,
'theme': theme,
'form': form,
'notesForm': notesForm
}
)
elif request.user.is_authenticated():
messages.add_message(
request, messages.ERROR,
_(u'You cannot watch this video.'))
raise PermissionDenied
else:
iframe_param = 'is_iframe=true&' if (
request.GET.get('is_iframe')) else ''
return redirect(
'%s?%sreferrer=%s' % (
settings.LOGIN_URL,
iframe_param,
request.get_full_path())
)
return render_video(request, slug, slug_c, slug_t, slug_private,
template_video, {'h5p': h5p, 'score': score})
Binary file modified pod/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 9014acb

Please sign in to comment.