add: template editor
This commit is contained in:
@@ -7,7 +7,7 @@ from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
from sqlalchemy import create_engine, text, inspect
|
||||
from env_provider import DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, DB_SCHEMA_UPDATED, ENVIRONMENT
|
||||
|
||||
print(f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}")
|
||||
engine = create_engine(f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}")
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ class Markdown(Base):
|
||||
}
|
||||
__payload__ = {
|
||||
'dev': [
|
||||
{'id': 1, 'title': 'index', 'content': ' ', 'created_at': datetime.datetime.utcnow, 'path_id': 1 },
|
||||
{'id': 1, 'title': 'index', 'content': '{"markdown": ""}', 'created_at': datetime.datetime.utcnow, 'path_id': 1 },
|
||||
],
|
||||
'prod': [
|
||||
{'id': 1, 'title': 'index', 'content': ' ', 'created_at': datetime.datetime.utcnow, 'path_id': 1},
|
||||
{'id': 1, 'title': 'index', 'content': '{"markdown": ""}', 'created_at': datetime.datetime.utcnow, 'path_id': 1},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class MarkdownTemplate(Base):
|
||||
id = Column(Integer, primary_key=True)
|
||||
title = Column(String(255), nullable=False)
|
||||
parameters = Column(Text, nullable=True)
|
||||
define = Column(Text, nullable=True)
|
||||
layout = Column(Text, nullable=True)
|
||||
__table_args__ = (UniqueConstraint("title", name="unique_title"),)
|
||||
|
||||
def to_dict(self):
|
||||
@@ -14,5 +14,5 @@ class MarkdownTemplate(Base):
|
||||
'id': self.id,
|
||||
'title': self.title,
|
||||
'parameters': self.parameters,
|
||||
'define': self.define,
|
||||
'layout': self.layout,
|
||||
}
|
||||
|
||||
16
db/models/MarkdownTemplateSetting.py
Normal file
16
db/models/MarkdownTemplateSetting.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from sqlalchemy import Column, Integer, ForeignKey
|
||||
|
||||
from db.models import Base
|
||||
|
||||
|
||||
class MarkdownTemplateSetting(Base):
|
||||
__tablename__ = 'markdown_template_setting'
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
template_id = Column(Integer, ForeignKey('markdown_template.id'))
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'template_id': self.template_id,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user