La version 5 de Planète Casio. Regroupe le forum, les programmes, les tutoriel, les sprites et tous les autres outils développés par nos soins.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

from app import db
from datetime import datetime
class Post(db.Model):
"""Contents created and published by Users."""
__tablename__ = 'post'
# Unique Post ID for the whole site
id = db.Column(db.Integer, primary_key=True)
# Post type (polymorphic discriminator)
type = db.Column(db.String(20))
# Creation and edition date
date_created = db.Column(db.DateTime)
date_modified = db.Column(db.DateTime, index=True)
# Post author
author_id = db.Column(db.Integer, db.ForeignKey(''), nullable=False,
author = db.relationship('User', backref="posts", foreign_keys=author_id)
__mapper_args__ = {
'polymorphic_identity': __tablename__,
'polymorphic_on': type
def __init__(self, author):
Create a new Post.
author -- post author (User)
""" = author
self.date_created =
self.date_modified = self.date_created
def touch(self):
"""Touch a Post when it is edited."""
self.date_modified =
def change_ownership(self, new_author):
Change ownership of a Post. This is a privileged operation!
new_author -- new post author (User)
""" = new_author
def __repr__(self):
return f'<Post: #{}>'