[Docs] Add/update docstrings and license text in every file

This commit is contained in:
2018-07-03 08:22:58 +02:00
parent a5bf841898
commit 2f66fdb83e
8 changed files with 230 additions and 2 deletions

View File

@@ -1,3 +1,22 @@
# Calendar.social
# Copyright (C) 2018 Gergely Polonkai
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Database models for Calendar.social
"""
from datetime import datetime
from flask_security import UserMixin, RoleMixin
@@ -11,6 +30,9 @@ users_roles = db.Table(
class User(db.Model, UserMixin):
"""Database model for users
"""
__tablename__ = 'users'
id = db.Column(db.Integer(), primary_key=True)
@@ -42,6 +64,9 @@ class User(db.Model, UserMixin):
class Role(db.Model, RoleMixin):
"""Database model for roles
"""
__tablename__ = 'roles'
id = db.Column(db.Integer(), primary_key=True)
@@ -56,6 +81,9 @@ class Role(db.Model, RoleMixin):
class Event(db.Model):
"""Database model for events
"""
__tablename__ = 'events'
id = db.Column(db.Integer(), primary_key=True)
@@ -70,10 +98,10 @@ class Event(db.Model):
#: 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
#: The starting timestamp of the event. It is in the UTC time zone
start_time = db.Column(db.DateTime(), nullable=False)
#: The ending timestamp of the event
#: The ending timestamp of the event. It is in the UTC time zone
end_time = db.Column(db.DateTime(), nullable=False)
#: If `True`, the event is a whole-day event
@@ -89,10 +117,16 @@ class Event(db.Model):
@property
def start_time_tz(self):
"""The same timestamp as `start_time`, but in the time zone specified by `time_zone`.
"""
return self.__as_tz(self.start_time)
@property
def end_time_tz(self):
"""The same timestamp as `end_time`, but in the time zone specified by `time_zone`.
"""
return self.__as_tz(self.end_time)
def __repr__(self):