1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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,
}
|