diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-06-01 16:22:18 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-06-01 16:22:18 +0200 |
| commit | 1a7370c19a7eed6a5f0f48e270092f9b3caebbc1 (patch) | |
| tree | ff1ac87d40bde43648e579e43543d3e1646d00d4 /cli/app/sql/models/graph.py | |
| parent | 0890fdd951d021308550a0db2e7b6f2593512957 (diff) | |
models and controllers
Diffstat (limited to 'cli/app/sql/models/graph.py')
| -rw-r--r-- | cli/app/sql/models/graph.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cli/app/sql/models/graph.py b/cli/app/sql/models/graph.py new file mode 100644 index 0000000..59d55c8 --- /dev/null +++ b/cli/app/sql/models/graph.py @@ -0,0 +1,35 @@ +from sqlalchemy import create_engine, Table, Column, Text, String, Integer, DateTime, JSON +import sqlalchemy.sql.functions as func +from sqlalchemy_utc import UtcDateTime, utcnow +from wtforms_alchemy import ModelForm + +from app.sql.common import db, Base, Session + +from app.utils.file_utils import sha256_tree +from app.settings import app_cfg + +from os.path import join + +class Graph(Base): + """Table for storing references to graphs""" + __tablename__ = 'graphs' + id = Column(Integer, primary_key=True) + path = Column(String(64, convert_unicode=True), nullable=False) + title = Column(String(64, convert_unicode=True), nullable=False) + description = Column(Text(convert_unicode=True), nullable=False) + settings = Column(JSON, default={}, nullable=True) + created_at = Column(UtcDateTime(), default=utcnow()) + updated_at = Column(UtcDateTime(), default=utcnow()) + + # pages = relationship("Page", secondary="pages", lazy='dynamic') + + def toJSON(self): + return { + 'id': self.id, + 'path': self.path, + 'title': self.title, + 'description': self.description, + 'settings': self.settings, + 'created_at': self.created_at, + 'updated_at': self.updated_at, + } |
