mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-06 10:13:01 +00:00
Render solution video in a modal
This commit is contained in:
parent
9159e7323d
commit
f2704b3f13
@ -1,5 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
from corres2math.lists import get_sympa_client
|
from corres2math.lists import get_sympa_client
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
@ -162,6 +164,11 @@ class Video(models.Model):
|
|||||||
return re.compile("(https?://|)(www\\.|)(youtube\\.com/watch\\?v=|youtu\\.be/)([a-zA-Z0-9-_]*)?.*?")\
|
return re.compile("(https?://|)(www\\.|)(youtube\\.com/watch\\?v=|youtu\\.be/)([a-zA-Z0-9-_]*)?.*?")\
|
||||||
.match("https://www.youtube.com/watch?v=73nsrixx7eI").group(4)
|
.match("https://www.youtube.com/watch?v=73nsrixx7eI").group(4)
|
||||||
|
|
||||||
|
def as_iframe(self):
|
||||||
|
if self.platform == "youtube":
|
||||||
|
return render_to_string("participation/youtube_iframe.html", context=dict(youtube_code=self.youtube_code))
|
||||||
|
return None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _("Video of team {name} ({trigram})")\
|
return _("Video of team {name} ({trigram})")\
|
||||||
.format(name=self.participation.team.name, trigram=self.participation.team.trigram)
|
.format(name=self.participation.team.name, trigram=self.participation.team.trigram)
|
||||||
|
@ -26,15 +26,11 @@
|
|||||||
{% if current_phase.phase_number == 1 or participation.solution.link == "" %}
|
{% if current_phase.phase_number == 1 or participation.solution.link == "" %}
|
||||||
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadVideoModal">{% trans "Upload" %}</button>
|
<button class="btn btn-primary" data-toggle="modal" data-target="#uploadVideoModal">{% trans "Upload" %}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if participation.solution.link %}
|
||||||
|
<button class="btn btn-info" data-toggle="modal" data-target="#displayVideoModal">{% trans "Display" %}</button>
|
||||||
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
{% if participation.solution.platform == "youtube" %}
|
|
||||||
{% include "participation/youtube_iframe.html" with youtube_code=participation.solution.youtube_code %}
|
|
||||||
{% elif participation.solution %}
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
{% trans "This video platform is not supported yet." %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -43,6 +39,9 @@
|
|||||||
{% trans "Upload" as modal_button %}
|
{% trans "Upload" as modal_button %}
|
||||||
{% url "participation:upload_video" pk=participation.solution_id as modal_action %}
|
{% url "participation:upload_video" pk=participation.solution_id as modal_action %}
|
||||||
{% include "base_modal.html" with modal_id="uploadVideo" %}
|
{% include "base_modal.html" with modal_id="uploadVideo" %}
|
||||||
|
{% trans "Display solution" as modal_title %}
|
||||||
|
{% trans "This video platform is not supported yet." as unsupported_platform %}
|
||||||
|
{% include "base_modal.html" with modal_id="displayVideo" modal_action="" modal_button="" modal_additional_class="modal-lg" modal_content=participation.solution.as_iframe|default:unsupported_platform %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extrajavascript %}
|
{% block extrajavascript %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user