from django.db import models
from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
from django.db.models import Q, Max, Min
from django.db.models.signals import post_save
from django.conf import settings
@property
def safe_url(self):
- return urllib.quote(self.url)
+ domain = Site.objects.get_current().domain
+ url = self.url
+ if 'pilotsystems' in domain:
+ url = url.replace('http://e-learning.crfpa.pre-barreau.com', '//'+domain)
+
+ url = url.replace('http://', '//')
+ return urllib.quote(url)
+
+ def unquoted_url(self):
+ domain = Site.objects.get_current().domain
+ url = self.url
+ if 'pilotsystems' in domain:
+ url = url.replace('http://e-learning.crfpa.pre-barreau.com', '//'+domain)
+ return url
+
+ def has_annotations_file(self):
+ """
+ check if an annotations file exists. Then use this file, otherwise use the new db implementation
+ """
+ return os.path.exists(os.path.join(settings.WEBVIEWER_ANNOTATIONS_PATH, self.uuid+'.xfdf'))
def box_upload(self):
sleep = 10
{% load telemeta_utils %}
{% load teleforma_tags %}
{% load i18n %}
+{% load static %}
+{% load webviewer %}
{% load thumbnail %}
{% block extra_javascript %}
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script src="/static/exam/js/exam.js"></script>
+ <!--<script src='{% static "WebViewer/lib/html5/external/jquery-3.2.1.min.js" %}'></script>-->
+ <script src='{% static "WebViewer/lib/WebViewer.min.js" %}'></script>
<script>
// increase the default animation speed to exaggerate the effect
{% if script.comments %}
});
{% endif %}
</script>
+
+
{% endblock extra_javascript %}
{% block content %}
<br /><br />
<div class="media">
<div class="script">
+ {% if script.has_annotations_file %}
<iframe id="box-iframe" style="position:fixed; top:12%; left:0px; bottom:0px; right:0px; width:100%; height:85%; border:none; margin:0; padding:0; z-index:0;" src="{% if user.quotas.all or user.is_superuser %}{{ script_service_url }}?url={{ script.safe_url }}&username=Examinator&uuid={{ script.uuid }}{% else %}{{ script_service_url }}?url={{ script.safe_url }}&username={{ user.username }}&uuid={{ script.uuid }}{% endif %}">
</iframe>
+ {% else %}
+ {% webviewer url=script.unquoted_url uuid=script.uuid %}
+ {% endif %}
</div>
</div>