xplosiveloons

Untitled

May 3rd, 2021
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. class Restriction(db.Model):
  2.     __tablename__ = "restriction"
  3.     id = db.Column(db.Integer, primary_key=True)
  4.     title= db.Column(db.String, nullable= False)
  5.     description = db.Column(db.String, nullable=False)
  6.     recipes= db.relationship('Recipe', secondary= restiction_association_table, back_populates = 'restrictions')
  7.  
  8.     def __init__(self, **kwargs):
  9.         self.title=kwargs.get("title")
  10.         self.description=kwargs.get("description")
  11.  
  12.     def serialize(self):
  13.         return {
  14.             'id': self.id,
  15.             'title': self.title,
  16.             'description': self.description,
  17.             'recipes': [r.serialize() for r in self.recipes]
  18.         }
  19.    
  20.     def simple_serialize(self):
  21.         return{
  22.             'id': self.id,
  23.             'title': self.title,
  24.             'description': self.description
  25.         }    
  26.    
Advertisement
Add Comment
Please, Sign In to add comment