From bac17faed22069704a216dfb7c260c34e33d68c9 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 29 Jun 2018 13:25:09 +0200 Subject: [PATCH] Create the Event model --- app/models.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/models.py b/app/models.py index 46d5ce2..c3fb466 100644 --- a/app/models.py +++ b/app/models.py @@ -54,3 +54,34 @@ class Role(db.Model, RoleMixin): def __repr__(self): return f'' + + +class Event(db.Model): + __tablename__ = 'events' + id = db.Column(db.Integer(), primary_key=True) + + #: The ID of the user who created the event + user_id = db.Column(db.Integer(), db.ForeignKey('users.id'), nullable=False) + + user = db.relationship('User', backref=db.backref('events', lazy='dynamic')) + + #: The title of the event + title = db.Column(db.Unicode(length=200), nullable=False) + + #: The time zone to be used for `start_time` and `end_time` + time_zone = db.Column(db.String(length=80), nullable=False) + + #: The starting timestamp of the event + start_time = db.Column(db.DateTime(), nullable=False) + + #: The ending timestamp of the event + end_time = db.Column(db.DateTime(), nullable=False) + + #: If `True`, the event is a whole-day event + all_day = db.Column(db.Boolean(), default=False) + + #: The description of the event + description = db.Column(db.UnicodeText()) + + def __repr__(self): + return f''