From 78ae61e282c99b3000782d6b7635f9448aa6295f Mon Sep 17 00:00:00 2001 From: Adabriand Furtado Date: Tue, 6 Oct 2015 17:11:25 -0300 Subject: [PATCH] Interface inicial do 2o loop da tarefa e file upload modificado para salvar numa pasta de sessão --- corretor.py | 25 ++++++++++++++++++------- main.py | 2 +- pyutil.py | 7 +++++++ view/assets/css/main.css | 11 ++++++++++- view/img/thumbnail.png | Bin 7501 -> 0 bytes view/template.html | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- 6 files changed, 144 insertions(+), 52 deletions(-) diff --git a/corretor.py b/corretor.py index d71f822..a6e415b 100644 --- a/corretor.py +++ b/corretor.py @@ -39,6 +39,8 @@ class Corretor: template = self.env.get_template('template.html') project.info['task_presenter'] = template.render(server=self.config['HOST_ENDPOINT']) project.info['thumbnail'] = self.config['HOST_ENDPOINT'] + "/img/thumbnail.png" + project.info['sched'] = "incremental" + project.allow_anonymous_contributors = False pbclient.update_project(project) def create_project(self): @@ -70,17 +72,26 @@ class Corretor: return '.' in filename and filename.rsplit('.', 1)[1] in allowed_extensions def upload_file(self): + upload_session_id = request.form['upload_session_id'] + sign_name = request.form['sign_name'] file = request.files['file'] result_msg = "" - code = 200 - if file and self.__allowed_file(file.filename): + code = 400 + if (not pyutil.is_int(upload_session_id)): + result_msg = "Invalid upload session id: " + upload_session_id + elif file and not self.__allowed_file(file.filename): + result_msg = file.filename + " extension is not acceptable." + else: filename = secure_filename(file.filename) - file.save(os.path.join(self.config['UPLOAD_FOLDER'], filename)) + upload_dir = os.path.join(self.config['UPLOAD_FOLDER'], upload_session_id) + if not os.path.exists(upload_dir): + os.makedirs(upload_dir) + uploaded_file = os.path.join(upload_dir, filename) + file.save(uploaded_file) + renamed_file = os.path.join(upload_dir, secure_filename(sign_name + "_CORRIGIDO.blend")) + os.rename(uploaded_file, renamed_file) # validar o .blend + code = 200 result_msg = "File " + filename + " was uploaded." - else: - result_msg = file.filename + " extension is not acceptable." - code = 400 pyutil.log(result_msg) return make_response(result_msg, code) - diff --git a/main.py b/main.py index a629669..d740054 100644 --- a/main.py +++ b/main.py @@ -42,7 +42,7 @@ def upload_file(): @app.route("/finish_task", methods=["POST"]) def finish_task(): - # TODO + # TODO read - request.data['upload_session_id'] e request.data['sign_name'] return def read_settings(app): diff --git a/pyutil.py b/pyutil.py index 1674fd7..d8598d1 100644 --- a/pyutil.py +++ b/pyutil.py @@ -59,3 +59,10 @@ def print_stack_trace(): def get_date_now(): return datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S') + +def is_int(string): + try: + int(string) + return True + except ValueError: + return False diff --git a/view/assets/css/main.css b/view/assets/css/main.css index 49debcd..2a62847 100755 --- a/view/assets/css/main.css +++ b/view/assets/css/main.css @@ -37,11 +37,15 @@ video { } /* Body */ -#body-container { +.body-container { background: rgba(236, 238, 242, 1.0); padding-bottom: 10px; } +#approval-container { + display: none; +} + /* Tabela */ .table-responsive { border: none; @@ -179,6 +183,11 @@ h6 { padding-right: 40px; } +#approval-task-container { + padding-top: 6px; + padding-right: 40px; +} + .finish-task-button { float: right; padding-bottom: 0px; diff --git a/view/img/thumbnail.png b/view/img/thumbnail.png index 1d20efe..ead10bc 100644 Binary files a/view/img/thumbnail.png and b/view/img/thumbnail.png differ diff --git a/view/template.html b/view/template.html index 92cd22d..19ff585 100755 --- a/view/template.html +++ b/view/template.html @@ -43,21 +43,23 @@
-
+
-
ANIMAÇÃO ATUAL "":
+
+ ANIMAÇÃO ATUAL "": +
-
@@ -89,40 +91,23 @@
-
VÍDEO DE REFERÊNCIA “” :
+
+ VÍDEO DE REFERÊNCIA “”: +
-
-
FINALIZAR @@ -133,10 +118,54 @@
+
+
+
+
+ ANIMAÇÃO"": +
+
+
+ +
+
+
+
+
+ VÍDEO DE REFERÊNCIA “”: +
+
+
+ +
+
+
+ APROVADO +
+
+ CORRIGIR +
+
+
+