From 758f3bdfd9bd3e59343506c4f289371b05644d48 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 25 Jan 2018 23:04:12 +0100 Subject: [PATCH] Use WebView in the same iframe ATM --- teleforma/exam/models.py | 33 ++++++++++++++++--- .../exam/templates/exam/script_detail.html | 2 +- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index b4062489..7423b1e5 100644 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -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: diff --git a/teleforma/exam/templates/exam/script_detail.html b/teleforma/exam/templates/exam/script_detail.html index f72fb5e5..3056f66d 100644 --- a/teleforma/exam/templates/exam/script_detail.html +++ b/teleforma/exam/templates/exam/script_detail.html @@ -123,7 +123,7 @@

-
-- 2.39.5