~sirn/fanboi2

ref: 98796226802a26b82c888365ad5b9cd331006792 fanboi2/fanboi2/models/page.py -rw-r--r-- 1.1 KiB
98796226Kridsada Thanabulpong Bump copyright year. 3 years ago
                                                                                
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
from sqlalchemy.sql import func
from sqlalchemy.sql.schema import Column, UniqueConstraint
from sqlalchemy.sql.sqltypes import Integer, DateTime, String, Text, Unicode
from ._base import Base, Versioned


INTERNAL_PAGES = (
    ('global/css', 'none'),
    ('global/robots', 'none'),
    ('global/appendix', 'markdown'),
    ('global/footer', 'html'),
)


class Page(Versioned, Base):
    """Model class for pages. This model is a basis for user-accessible
    content that are not part of the board itself, including individual pages,
    custom CSS or board guidelines.
    """

    __tablename__ = 'page'
    __table_args__ = (UniqueConstraint('namespace', 'slug'),)

    id = Column(Integer, primary_key=True)
    created_at = Column(DateTime(timezone=True), default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())
    namespace = Column(String, nullable=False, default='public')
    title = Column(Unicode, nullable=False)
    slug = Column(String, nullable=False)
    body = Column(Text, nullable=False)
    formatter = Column(String, nullable=False, default='markdown')