1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-10-16 12:07:27 +00:00

Add 2 columns to Tweet model

This commit is contained in:
Lorenzo Balugani 2021-05-21 17:40:26 +02:00
parent 3a8df55178
commit a155beed4b
2 changed files with 8 additions and 4 deletions

View file

@ -84,8 +84,10 @@ class TweetSchema(Schema):
content = fields.String(description="The content of the tweet.")
location = fields.String(description="The location (coordinates) from which the tweet was tweeted.")
place = fields.String(description="The place from which the tweet was tweeted.")
poster = fields.String(default="The one that created the tweet.")
insert_time = fields.DateTime(default="The time on which the tweet was captured.")
poster = fields.String(description="The one that created the tweet.")
insert_time = fields.DateTime(description="The time on which the tweet was captured.")
post_time = fields.DateTime(description="The time on which the tweet was posted.")
image_url = fields.String(descritpion="The embedded image urls, separated by |. If there are no images, its None.")
conditions = fields.Nested(ConditionSchema, many=True)

View file

@ -13,11 +13,13 @@ class Tweet(ext.Model):
place = ext.Column(ext.String)
poster = ext.Column(ext.String)
insert_time = ext.Column(ext.DateTime, nullable=False)
post_time = ext.Column(ext.DateTime, nullable=True)
image_url = ext.Column(ext.String, nullable=True)
# Relationships
repositories = ext.relationship("Composed", back_populates="tweet", cascade="all, delete")
conditions = ext.relationship("Contains", back_populates="tweet", cascade="all, delete")
def to_json(self):
return {"snowflake": self.snowflake, "content": self.content, "location": self.location, "poster": self.poster,
"place": self.place, "insert_time": self.insert_time.isoformat(),
"conditions": [c.condition.to_json() for c in self.conditions]}
"place": self.place, "insert_time": self.insert_time.isoformat(), "post_time": self.post_time,
"image_url": self.image_url, "conditions": [c.condition.to_json() for c in self.conditions]}