diff --git a/models/Strategy.py b/models/Strategy.py index 1be44be..6b62b57 100644 --- a/models/Strategy.py +++ b/models/Strategy.py @@ -17,6 +17,10 @@ class Strategy(): def get_route_prefix(cls): return "/strategies/" + cls.__name__.lower() + @classmethod + def get_template_prefix(cls): + return "/strategies" + @staticmethod def get_computed_properties(): return ["id", "createdAt"] diff --git a/routes/create.py b/routes/create.py index 1bf4f96..4534dfa 100644 --- a/routes/create.py +++ b/routes/create.py @@ -1,7 +1,7 @@ from db import get_connection, getRethinkDB from dataclasses import fields from typing import List, Type -from flask import jsonify, request, redirect, render_template +from flask import request, render_template r = getRethinkDB() def get_bool_attribute_names(cls: Type) -> List[str]: @@ -21,7 +21,7 @@ def create_routes(cls, app): cursor = r.table(table_name).run(get_connection()) fields = list(cursor) - return render_template(cls.get_route_prefix() + "/index.html", data={ + return render_template(cls.get_template_prefix() + "/index.html", data={ "title": cls.__name__, "fields": [cls.format(field) for field in fields], "prefix": cls.get_route_prefix(), @@ -31,7 +31,7 @@ def create_routes(cls, app): @app.route(cls.get_route_prefix() + "/create", methods=['GET']) def get_create(): - return render_template(cls.get_route_prefix() + "/create.html", data={ + return render_template(cls.get_template_prefix() + "/create.html", data={ "name": cls.__name__, "prefix": cls.get_route_prefix(), "computed": cls.get_computed_properties(), @@ -55,7 +55,7 @@ def create_routes(cls, app): def get_update(id): cursor = r.table(table_name).get(id).run(get_connection()) - return render_template(cls.get_route_prefix() + "/update.html", data={ + return render_template(cls.get_template_prefix() + "/update.html", data={ "name": cls.__name__, "field": cursor, "fields": {field.name: field.type.__name__ for field in fields(cls)}, diff --git a/templates/strategies/abc/create.html b/templates/strategies/create.html similarity index 100% rename from templates/strategies/abc/create.html rename to templates/strategies/create.html diff --git a/templates/strategies/abc/index.html b/templates/strategies/index.html similarity index 100% rename from templates/strategies/abc/index.html rename to templates/strategies/index.html diff --git a/templates/strategies/abc/update.html b/templates/strategies/update.html similarity index 100% rename from templates/strategies/abc/update.html rename to templates/strategies/update.html