]> git.parisson.com Git - teleforma.git/commitdiff
Use WebView in the same iframe ATM
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 25 Jan 2018 22:04:12 +0000 (23:04 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 25 Jan 2018 22:04:12 +0000 (23:04 +0100)
teleforma/exam/models.py
teleforma/exam/templates/exam/script_detail.html

index b40624897bbe86a8444b7dab8be66f3a15dcb71c..7423b1e5dee098b4db2ace626968201bf41f49d7 100644 (file)
@@ -35,7 +35,7 @@
 """
 
 from __future__ import division
-import os, uuid, time, hashlib, mimetypes, tempfile, datetime
+import os, uuid, time, hashlib, mimetypes, tempfile, datetime, urllib
 
 from django.db import models
 from django.contrib.auth.models import User
@@ -50,15 +50,35 @@ from django.template.loader import render_to_string
 from postman.utils import email_visitor, notify_user
 from postman.models import Message
 
+
 app = 'teleforma'
 
 class MetaCore:
 
     app_label = 'exam'
 
+
 import crocodoc
 crocodoc.api_token = settings.BOX_API_TOKEN
 
+
+# import boxsdk
+# from boxsdk import OAuth2, Client
+# import StringIO
+#
+# box_client_id = settings.BOX_CLIENT_ID
+# box_client_secret = settings.BOX_CLIENT_SECRET
+# box_redirect_url = settings.BOX_REDIRECT_URL
+#
+# oauth = OAuth2(
+#     client_id=box_client_id,
+#     client_secret=box_client_secret,
+#     store_tokens='',
+# )
+#
+# box_auth_url, box_csrf_token = oauth.get_authorization_url('http://' + BOX_REDIRECT_URL)
+# box_client = Client(oauth)
+
 SCRIPT_STATUS = ((0, _('rejected')), (1, _('draft')), (2, _('submitted')),
                 (3, _('pending')),(4, _('marked')), (5, _('read')), (6, _('backup')) )
 
@@ -72,8 +92,8 @@ REJECT_REASON = (('unreadable', _('unreadable')),
                 ('wrong format', _('wrong format')),
                 ('unreadable file', _('unreadable file')),
                 ('no file', _('no file')),
-                ('file too large', _('file too large')),
                 ('error retrieving file', _('error retrieving file')),
+                ('file too large', _('file too large')),
                 )
 
 cache_path = settings.MEDIA_ROOT + 'cache/'
@@ -350,12 +370,15 @@ class Script(BaseResource):
 
         if not os.path.exists(new_abs):
             os.symlink(old_abs, new_abs)
-            # self.url = 'http://teleforma.parisson.com/media/scripts/2014/06/24/Gstreamer_monitoring_Pipleline.pdf'
 
         if not self.url:
             self.url = settings.MEDIA_URL + unicode(new_rel)
             self.save()
 
+    @property
+    def safe_url(self):
+        return urllib.quote(self.url)
+
     def box_upload(self):
         sleep = 10
         max_loop = 12
@@ -397,7 +420,7 @@ class Script(BaseResource):
         self.save()
 
     def submit(self):
-        self.box_upload_done = 0
+        self.box_upload_done = 0
 
         if not self.file:
             self.auto_reject('no file')
@@ -423,7 +446,7 @@ class Script(BaseResource):
         if not self.status == 0 and self.file:
             if not self.box_uuid:
                 self.uuid_link()
-            self.box_upload()
+            self.box_upload()
             if not self.corrector and self.box_upload_done == 1:
                 self.auto_set_corrector()
             else:
index f72fb5e5567e65f9cbb7f004662ebe110fb6d46e..3056f66d98a4d9a5da0e359a4dcd0d7db4471d9d 100644 (file)
 <br /><br />
 <div class="media">
  <div class="script">
-    <iframe id="box-iframe" style="position:fixed; top:14%; left:0px; bottom:0px; right:0px; width:100%; height:85%; border:none; margin:0; padding:0; z-index:0;" src="{% if user.quotas.all %}{{ script.box_admin_url }}{% else %}{{ script.box_user_url }}{% endif %}">
+    <iframe id="box-iframe" style="position:fixed; top:14%; left:0px; bottom:0px; right:0px; width:100%; height:85%; border:none; margin:0; padding:0; z-index:0;" src="{% if user.quotas.all %}http://teleforma.parisson.com/webview/teleforma.html?url={{ script.safe_url }}?username=Examinator{% else %}http://teleforma.parisson.com/webview/teleforma.html?url={{ script.safe_url }}?username={{ user.username }}{% endif %}">
     </iframe>
  </div>
 </div>