Skip to content

Commit 9014acb

Browse files
author
Ptitloup
authored
Merge pull request #88 from EsupPortail/dev
Dev
2 parents b7760ae + b76df23 commit 9014acb

File tree

26 files changed

+1381
-1092
lines changed

26 files changed

+1381
-1092
lines changed

pod/enrichment/templates/enrichment/video_enrichment-iframe.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
{% block page_title %}{%if channel %}{{channel.title}} - {%endif%}{%if theme %}{{theme.title}} - {%endif%}({% trans 'Enriched' %}) {{video.title}}{% endblock %}
1212

1313
{% block video-element %}
14-
14+
{% if form %}
15+
{% include 'videos/video-form.html' %}
16+
{% else %}
1517
<video id="podvideoplayer" class="video-js vjs-default-skin vjs-big-play-centered" preload="auto" height="360"
1618
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%}>
1719
<p class="vjs-no-js">
@@ -28,7 +30,7 @@
2830
<form method="post" action="{% url 'video_count' id=video.id %}" id="video_count_form">
2931
{% csrf_token %}
3032
</form>
31-
33+
{% endif %}
3234
{% endblock video-element %}
3335

3436

pod/enrichment/views.py

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
from django.conf import settings
21
from django.contrib import messages
32
from django.contrib.admin.views.decorators import staff_member_required
43
from django.core.exceptions import PermissionDenied
5-
from django.core.exceptions import SuspiciousOperation
64
from django.http import HttpResponse
75
from django.template.loader import render_to_string
86
from django.shortcuts import render
97
from django.shortcuts import get_object_or_404
10-
from django.shortcuts import redirect
118
from django.utils.translation import ugettext as _
129
from django.views.decorators.csrf import csrf_protect
1310

14-
from pod.video.models import Video, Channel, Theme
15-
from pod.video.views import get_note_form, get_video_access
16-
from pod.video.forms import VideoPasswordForm
11+
from pod.video.models import Video
12+
from pod.video.views import render_video
1713

1814
from .models import Enrichment, EnrichmentGroup
1915
from .forms import EnrichmentForm, EnrichmentGroupForm
@@ -212,61 +208,12 @@ def edit_enrichment_cancel(request, video):
212208
@csrf_protect
213209
def video_enrichment(request, slug, slug_c=None,
214210
slug_t=None, slug_private=None):
215-
try:
216-
id = int(slug[:slug.find("-")])
217-
except ValueError:
218-
raise SuspiciousOperation('Invalid video id')
219-
video = get_object_or_404(Video, id=id)
220-
notesForm = get_note_form(request, video)
221-
channel = get_object_or_404(Channel, slug=slug_c) if slug_c else None
222-
theme = get_object_or_404(Theme, slug=slug_t) if slug_t else None
223-
playlist = None
224211

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

228-
is_password_protected = (
229-
video.password is not None and video.password != '')
230-
231-
show_page = get_video_access(request, video, slug_private)
232-
233-
if show_page:
234-
return render(
235-
request, template_video, {
236-
'channel': channel,
237-
'video': video,
238-
'theme': theme,
239-
'notesForm': notesForm,
240-
'playlist': playlist
241-
}
242-
)
243-
else:
244-
if is_password_protected:
245-
form = VideoPasswordForm(
246-
request.POST) if request.POST else VideoPasswordForm()
247-
return render(
248-
request, 'enrichment/video_enrichment.html', {
249-
'channel': channel,
250-
'video': video,
251-
'theme': theme,
252-
'form': form,
253-
'notesForm': notesForm
254-
}
255-
)
256-
elif request.user.is_authenticated():
257-
messages.add_message(
258-
request, messages.ERROR,
259-
_(u'You cannot watch this video.'))
260-
raise PermissionDenied
261-
else:
262-
iframe_param = 'is_iframe=true&' if (
263-
request.GET.get('is_iframe')) else ''
264-
return redirect(
265-
'%s?%sreferrer=%s' % (
266-
settings.LOGIN_URL,
267-
iframe_param,
268-
request.get_full_path())
269-
)
215+
return render_video(request, slug, slug_c, slug_t, slug_private,
216+
template_video, None)
270217

271218

272219
"""
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% extends 'videos/video-iframe.html' %}
2+
{% load i18n %}
3+
{% load staticfiles %}
4+
5+
{% block page_extra_head %}
6+
<style>
7+
#h5pcontent {
8+
margin: auto;
9+
text-align: center;
10+
background-color: black;
11+
width: 100%;
12+
height: 480px;
13+
}
14+
#icontent {
15+
display: block;
16+
margin: 0 auto;
17+
width: 100%;
18+
height: 100%;
19+
background-color: black;
20+
}
21+
</style>
22+
{% endblock page_extra_head %}
23+
24+
{% block page_title %}{%if channel %}{{channel.title}} - {%endif%}{%if theme %}{{theme.title}} - {%endif%}({% trans 'Interactive video' %}) {{video.title}}{% endblock %}
25+
26+
{% block video-element %}
27+
{% if form %}
28+
{% include 'videos/video-form.html' %}
29+
{% else %}
30+
<div id="h5pcontent">
31+
<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>
32+
</div>
33+
<form method="post" action="{% url 'video_count' id=video.id %}" id="video_count_form">
34+
{% csrf_token %}
35+
</form>
36+
{% endif %}
37+
{% endblock video-element %}
38+
39+
40+
{% block more_script %}
41+
{{block.super}}
42+
<script>
43+
var video_height = 0;
44+
$('#icontent').on('load',function() {
45+
$('#icontent').fadeIn('slow', function(){
46+
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
47+
$("#h5pcontent").height(video_height);
48+
});
49+
$('#icontent').contents().find("body").attr("style", "background-color:black");
50+
});
51+
52+
</script>
53+
{% endblock more_script %}

pod/interactive/templates/interactive/video_interactive.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
{% else %}
3636
<div id="h5pcontent">
37-
<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>
37+
<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>
3838
</div>
3939

4040
<form method="post" action="{% url 'video_count' id=video.id %}" id="video_count_form">
@@ -76,7 +76,7 @@ <h3>{% trans 'Scoreboard' %}</h3>
7676
<i>{% trans 'Click below to refresh the information.' %}</i>
7777
<button type="submit" class="btn btn-info btn-sm" id="refresh-score" ><i data-feather="refresh-cw"></i></button>
7878
<br>
79-
{% if interactive.score and request.user == video.owner or request.user.is_superuser %}
79+
{% if more_data.score and request.user == video.owner or request.user.is_superuser %}
8080
<i>{% trans 'The scoreboard displays the users who viewed your interactive video and their results.' %}</i>
8181
<table class="table">
8282
<thead>
@@ -88,7 +88,7 @@ <h3>{% trans 'Scoreboard' %}</h3>
8888
</tr>
8989
</thead>
9090
<tbody id="user-score">
91-
{% for user in interactive.score %}
91+
{% for user in more_data.score %}
9292
{% if user.max_points and user.max_points != ".." %}
9393
<tr>
9494
<td>{{user.user}}</td>
@@ -108,8 +108,8 @@ <h3>{% trans 'Scoreboard' %}</h3>
108108
</table>
109109
{% elif request.user.is_authenticated %}
110110
<div id="personnal-score">
111-
{% if interactive.score %}
112-
{% with interactive.score|first as userscore %}
111+
{% if more_data.score %}
112+
{% with more_data.score|first as userscore %}
113113
{% trans 'You got the following score on this video' %}: {{userscore.points}} / {{userscore.max_points}}
114114
{% endwith %}
115115
{% else %}
@@ -119,8 +119,8 @@ <h3>{% trans 'Scoreboard' %}</h3>
119119
{% else %}
120120
<div id="personnal-score">
121121
<p>{% trans 'You are watching this video as anonymous user'%}</p>
122-
{% if interactive.score %}
123-
{% with interactive.score|first as userscore %}
122+
{% if more_data.score %}
123+
{% with more_data.score|first as userscore %}
124124
{% trans 'You got the following score on this video' %}: {{userscore.points}} / {{userscore.max_points}}
125125
{% endwith %}
126126
{% else %}
@@ -145,25 +145,25 @@ <h3>{% trans 'Scoreboard' %}</h3>
145145
var video_height = 0;
146146
$('#icontent').on('load',function() {
147147
$('#icontent').fadeIn('slow', function(){
148-
video_height = $('#icontent').contents().find("#h5p-iframe-{{interactive.h5p.content_id}}").height();
148+
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
149149
$("#h5pcontent").height(video_height);
150150
});
151151
});
152152
$("#collapseAside").on('shown.bs.collapse', function () {
153153
setTimeout(function (){
154-
video_height = $('#icontent').contents().find("#h5p-iframe-{{interactive.h5p.content_id}}").height();
154+
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
155155
$("#h5pcontent").height(video_height);
156156
}, 500);
157157
});
158158
$("#collapseAside").on('hidden.bs.collapse', function () {
159159
setTimeout(function (){
160-
video_height = $('#icontent').contents().find("#h5p-iframe-{{interactive.h5p.content_id}}").height();
160+
video_height = $('#icontent').contents().find("#h5p-iframe-{{more_data.h5p.content_id}}").height();
161161
$("#h5pcontent").height(video_height);
162162
}, 500);
163163
});
164164
$(document).on('click', '#refresh-score', function() {
165165
$.ajax({
166-
url: '{% url "h5pp:h5pajax" %}?user-scores={{interactive.h5p.content_id}}',
166+
url: '{% url "h5pp:h5pajax" %}?user-scores={{more_data.h5p.content_id}}',
167167
type: 'GET',
168168
success: function(list) {
169169
var table = $('#user-score');

pod/interactive/views.py

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
from django.shortcuts import render
2-
from django.conf import settings
32
from django.contrib import messages
43
from django.contrib.admin.views.decorators import staff_member_required
54
from django.core.exceptions import PermissionDenied
65
from django.core.exceptions import SuspiciousOperation
76
from django.shortcuts import get_object_or_404
8-
from django.shortcuts import redirect
97
from django.utils.translation import ugettext as _
108
from django.views.decorators.csrf import csrf_protect
119

12-
from pod.video.models import Video, Channel, Theme
13-
from pod.video.views import get_note_form, get_video_access
14-
from pod.video.forms import VideoPasswordForm
10+
from pod.video.models import Video
11+
from pod.video.views import render_video
1512
from .models import Interactive, InteractiveGroup
1613
from .forms import InteractiveGroupForm
1714
from h5pp.models import h5p_contents, h5p_libraries
@@ -96,10 +93,9 @@ def video_interactive(request, slug, slug_c=None,
9693
except ValueError:
9794
raise SuspiciousOperation('Invalid video id')
9895
video = get_object_or_404(Video, id=id)
99-
notesForm = get_note_form(request, video)
100-
channel = get_object_or_404(Channel, slug=slug_c) if slug_c else None
101-
theme = get_object_or_404(Theme, slug=slug_t) if slug_t else None
102-
playlist = None
96+
97+
template_video = 'interactive/video_interactive-iframe.html' if (
98+
request.GET.get('is_iframe')) else 'interactive/video_interactive.html'
10399

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

114-
interactive = {'h5p': h5p, 'score': score}
115-
116-
template_video = 'interactive/video_interactive-iframe.html' if (
117-
request.GET.get('is_iframe')) else 'interactive/video_interactive.html'
118-
119-
is_password_protected = (
120-
video.password is not None and video.password != '')
121-
122-
show_page = get_video_access(request, video, slug_private)
123-
124-
if show_page:
125-
return render(
126-
request, template_video, {
127-
'channel': channel,
128-
'video': video,
129-
'theme': theme,
130-
'notesForm': notesForm,
131-
'playlist': playlist,
132-
'interactive': interactive
133-
}
134-
)
135-
else:
136-
if is_password_protected:
137-
form = VideoPasswordForm(
138-
request.POST) if request.POST else VideoPasswordForm()
139-
return render(
140-
request, 'interactive/video_interactive.html', {
141-
'channel': channel,
142-
'video': video,
143-
'theme': theme,
144-
'form': form,
145-
'notesForm': notesForm
146-
}
147-
)
148-
elif request.user.is_authenticated():
149-
messages.add_message(
150-
request, messages.ERROR,
151-
_(u'You cannot watch this video.'))
152-
raise PermissionDenied
153-
else:
154-
iframe_param = 'is_iframe=true&' if (
155-
request.GET.get('is_iframe')) else ''
156-
return redirect(
157-
'%s?%sreferrer=%s' % (
158-
settings.LOGIN_URL,
159-
iframe_param,
160-
request.get_full_path())
161-
)
110+
return render_video(request, slug, slug_c, slug_t, slug_private,
111+
template_video, {'h5p': h5p, 'score': score})

pod/locale/fr/LC_MESSAGES/django.mo

1.94 KB
Binary file not shown.

0 commit comments

Comments
 (0)