More revisions

This commit is contained in:
Raoul Snyman 2021-05-27 19:22:47 -07:00
parent 92122b465e
commit 0cf304696d
No known key found for this signature in database
GPG Key ID: 423F9B322D9BEF2C

View File

@ -105,27 +105,9 @@ class Node(Model):
return node_dict
class Revision(Model):
"""
A version of a node
"""
__tablename__ = 'revisions'
id = Column(Integer, primary_key=True)
version = Column(String(255), nullable=False)
title = Column(String(255), nullable=False)
body = Column(Text)
format = Column(Text, nullable=False)
slug = Column(String(255), nullable=False)
created = Column(DateTime, nullable=False, index=True, default=datetime.utcnow)
node_id = Column(Integer, ForeignKey('nodes.id'), nullable=False)
node = relationship('Node', backref='revisions')
class Field(Model):
"""
A field is a model for extra field types on nodes
A field is a model for field types on nodes
"""
__tablename__ = 'fields'
@ -138,6 +120,41 @@ class Field(Model):
modified = Column(DateTime, nullable=False, default=datetime.utcnow)
class FieldRevision(Model):
"""
A revision of a field on a node
"""
__tablename__ = 'field_revisions'
id = Column(Integer, primary_key=True)
version = Column(Integer, nullable=False)
title = Column(String(255), nullable=False)
body = Column(Text)
format = Column(Text, nullable=False)
slug = Column(String(255), nullable=False)
created = Column(DateTime, nullable=False, index=True, default=datetime.utcnow)
node_id = Column(Integer, ForeignKey('nodes.id'), nullable=False)
class NodeField(Model):
"""
A node field is a field on a particular node
"""
__tablename__ = 'node_fields'
id = Column(Integer, primary_key=True)
field_id = Column(Integer, ForeignKey('fields.id'))
node_id = Column(Integer, ForeignKey('nodes.id'))
revision_id = Column(Integer, ForeignKey('field_revisions.id'), nullable=False, index=True)
title = Column(String(255), nullable=False)
description = Column(Text)
created = Column(DateTime, nullable=False, default=datetime.utcnow)
modified = Column(DateTime, nullable=False, default=datetime.utcnow)
current_revision = relationship('FieldRevision', backref='node_field')
field = relationship('Field', backref='node_field')
class File(Model):
"""
A file in the media library.