Back to a kind of working state
Package version are now pinned.
This commit is contained in:
26
model.py
26
model.py
@@ -19,14 +19,16 @@ class Post(db.Model):
|
||||
|
||||
@property
|
||||
def serialize(self):
|
||||
return {"id": self.id,
|
||||
"priority": self.priority,
|
||||
"category_id": self.category_id,
|
||||
"category": self.category.name,
|
||||
"title": self.title,
|
||||
"intro": self.intro,
|
||||
"description": self.description,
|
||||
"images": [image.uri for image in self.images]}
|
||||
return {
|
||||
"id": self.id,
|
||||
"priority": self.priority,
|
||||
"category_id": self.category_id,
|
||||
"category": self.category.name,
|
||||
"title": self.title,
|
||||
"intro": self.intro,
|
||||
"description": self.description,
|
||||
"images": [image.uri for image in self.images],
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def get_posts():
|
||||
@@ -34,7 +36,11 @@ class Post(db.Model):
|
||||
|
||||
@staticmethod
|
||||
def get_posts_with_category(category_id):
|
||||
return Post.query.filter(Post.category_id == category_id).order_by(Post.priority).all()
|
||||
return (
|
||||
Post.query.filter(Post.category_id == category_id)
|
||||
.order_by(Post.priority)
|
||||
.all()
|
||||
)
|
||||
|
||||
|
||||
class Image(db.Model):
|
||||
@@ -53,6 +59,6 @@ class ImageBase64(db.Model):
|
||||
|
||||
|
||||
class Category(db.Model):
|
||||
__tablename__ = "categories"
|
||||
__tablename__ = "category"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(80), nullable=False)
|
||||
|
||||
Reference in New Issue
Block a user