summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/app/controllers/graph_controller.py20
-rw-r--r--cli/app/controllers/page_controller.py2
-rw-r--r--cli/app/controllers/tile_controller.py4
-rw-r--r--cli/app/server/web.py1
4 files changed, 24 insertions, 3 deletions
diff --git a/cli/app/controllers/graph_controller.py b/cli/app/controllers/graph_controller.py
index 25b49aa..3fa4cce 100644
--- a/cli/app/controllers/graph_controller.py
+++ b/cli/app/controllers/graph_controller.py
@@ -16,3 +16,23 @@ class GraphView(CrudView):
for item in item.pages:
session.query(Tile).filter(Tile.page_id == item.id).delete(synchronize_session=False)
session.query(Page).filter(Page.graph_id == item.id).delete(synchronize_session=False)
+
+ @route('/name/<path>', methods=['GET'])
+ def get_name(self, path: str):
+ """
+ Fetch a single {model}.
+ """
+ session = Session()
+ item = session.query(self.model).filter(self.model.path == path).first()
+ if not item:
+ session.close()
+ return jsonify({
+ 'status': 'error',
+ 'error': 'item not found'
+ })
+ result = {
+ 'status': 'ok',
+ 'res': item.toFullJSON() if hasattr(item, 'toFullJSON') else item.toJSON(),
+ }
+ session.close()
+ return jsonify(result)
diff --git a/cli/app/controllers/page_controller.py b/cli/app/controllers/page_controller.py
index d393625..1f53171 100644
--- a/cli/app/controllers/page_controller.py
+++ b/cli/app/controllers/page_controller.py
@@ -14,7 +14,7 @@ class PageView(CrudView):
def where(self, query, args):
graph_id = args.get('graph_id', default=None)
if graph_id is not None:
- query = query.where(Page.graph_id == int(graph_id))
+ query = query.filter(Page.graph_id == int(graph_id))
return query
def on_destroy(self, session, item):
diff --git a/cli/app/controllers/tile_controller.py b/cli/app/controllers/tile_controller.py
index fc36943..58fd6d0 100644
--- a/cli/app/controllers/tile_controller.py
+++ b/cli/app/controllers/tile_controller.py
@@ -13,8 +13,8 @@ class TileView(CrudView):
def where(self, query, args):
graph_id = args.get('graph_id', default=None)
if graph_id is not None:
- query = query.where(Tile.graph_id == int(graph_id))
+ query = query.filter(Tile.graph_id == int(graph_id))
page_id = args.get('page_id', default=None)
if page_id is not None:
- query = query.where(Tile.page_id == int(page_id))
+ query = query.filter(Tile.page_id == int(page_id))
return query
diff --git a/cli/app/server/web.py b/cli/app/server/web.py
index 739f271..83dbc24 100644
--- a/cli/app/server/web.py
+++ b/cli/app/server/web.py
@@ -30,6 +30,7 @@ def create_app(script_info=None):
app = Flask(__name__, static_folder=app_cfg.DIR_STATIC, static_url_path='/static')
app.config['SQLALCHEMY_DATABASE_URI'] = connection_url
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
+ app.url_map.strict_slashes = False
db.init_app(app)