refactor templates
This commit is contained in:
parent
5323204789
commit
ae707720bc
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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)},
|
||||
|
|
|
|||
Loading…
Reference in New Issue