From 627454320671ef96d011eb52fcd9b541106ff0c9 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 9 Jul 2018 07:58:29 +0200 Subject: [PATCH] Create the Invitation model --- calsocial/models.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/calsocial/models.py b/calsocial/models.py index 5d4a68f..e877458 100644 --- a/calsocial/models.py +++ b/calsocial/models.py @@ -552,3 +552,28 @@ class Notification(db.Model): message = messages[0 if self.item == current_user.profile else 1] return lazy_gettext(message, actor=self.actor, item=self.item) + + +class Invitation(db.Model): # pylint: disable=too-few-public-methods + """Database model for event invitations + """ + + __tablename__ = 'invitations' + + #: The ID of the sender’s profile + sender_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), primary_key=True) + + sender = db.relationship('Profile', foreign_keys=[sender_id]) + + #: The ID of the invitee’s profile + invitee_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), primary_key=True) + + invitee = db.relationship('Profile', foreign_keys=[invitee_id]) + + #: The ID of the event + event_id = db.Column(db.Integer(), db.ForeignKey('events.id'), primary_key=True) + + event = db.relationship('Event', backref=db.backref('invitations', lazy='dynamic')) + + #: The timestamp of the invitation + timestamp = db.Column(db.DateTime(), default=datetime.utcnow)