From 752b36169cc7490f83366bb4276a522ca0210c29 Mon Sep 17 00:00:00 2001
From: erichard <elliot.richard@lal.in2p3.fr>
Date: Thu, 20 Feb 2020 16:45:04 +0100
Subject: [PATCH] Change import workflow with new package "labels_system"

---
 app/__init__.py                                  | 6 ++++--
 app/labels_system/__init__.py                    | 6 ++++++
 app/labels_system/{label_system.py => routes.py} | 9 ++++-----
 3 files changed, 14 insertions(+), 7 deletions(-)
 create mode 100644 app/labels_system/__init__.py
 rename app/labels_system/{label_system.py => routes.py} (82%)

diff --git a/app/__init__.py b/app/__init__.py
index 611ce46..4c438d6 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -1,6 +1,5 @@
 import os
 from flask import Flask, render_template
-from app.labels_system.label_system import sort
 
 class CustomFlask(Flask):
     jinja_options = Flask.jinja_options.copy()
@@ -18,11 +17,14 @@ def create_app():
 
     app.config.from_object(os.environ['LABELSTOWER_ENV'])
 
+
+    from app.labels_system import bp
+    app.register_blueprint(bp, url_prefix='/sort')
+
     @app.route('/')
     @app.route('/browse')
     def home():
         return render_template('browse.html', txt=text_component)
-    app.register_blueprint(sort, url_prefix='/sort')
     return app
 
 
diff --git a/app/labels_system/__init__.py b/app/labels_system/__init__.py
new file mode 100644
index 0000000..5c1516e
--- /dev/null
+++ b/app/labels_system/__init__.py
@@ -0,0 +1,6 @@
+from flask import Blueprint
+
+bp = Blueprint('sort', __name__)
+
+from app.labels_system import routes
+
diff --git a/app/labels_system/label_system.py b/app/labels_system/routes.py
similarity index 82%
rename from app/labels_system/label_system.py
rename to app/labels_system/routes.py
index 5af4533..f463b73 100644
--- a/app/labels_system/label_system.py
+++ b/app/labels_system/routes.py
@@ -1,15 +1,14 @@
 from typing import Dict, List
 import json
-from flask import Blueprint
 from app.labels_system.getter import get_selected_elements, get_discriminating_labels, get_high_discriminating_labels
+from app.labels_system import bp
 
-sort = Blueprint('sort', __name__)
 
 #URLs call to update labels and elements along researchs
 
-@sort.route('/search/<int:number_of_mandatory_labels>', defaults={'optional1':'', 'optional2':''})
-@sort.route('/search/<int:number_of_mandatory_labels>/<string:optional1>', defaults={'optional2':''})
-@sort.route('/search/<int:number_of_mandatory_labels>/<string:optional1>/<string:optional2>')
+@bp.route('/search/<int:number_of_mandatory_labels>', defaults={'optional1':'', 'optional2':''})
+@bp.route('/search/<int:number_of_mandatory_labels>/<string:optional1>', defaults={'optional2':''})
+@bp.route('/search/<int:number_of_mandatory_labels>/<string:optional1>/<string:optional2>')
 def search(number_of_mandatory_labels: int, optional1: str, optional2: str) -> List[List[Dict[int, str]]] :
     '''
     Return updated lists of selected elements and high discriminating labels useful to continu research
-- 
GitLab