From c7457f6ed1fb1d61bfea20d0fedc10c4d520a491 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 9 Jul 2018 12:11:15 +0200 Subject: [PATCH] Add the event_uuid field to the Event model --- calsocial/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/calsocial/models.py b/calsocial/models.py index 2f3feba..bd274dd 100644 --- a/calsocial/models.py +++ b/calsocial/models.py @@ -35,6 +35,12 @@ users_roles = db.Table( db.Column('role_id', db.Integer(), db.ForeignKey('roles.id'))) +def generate_uuid(): + from uuid import uuid4 + + return uuid4().hex + + class SettingsProxy: """Proxy object to get settings for a user """ @@ -197,6 +203,9 @@ class Event(db.Model): # pylint: disable=invalid-name id = db.Column(db.Integer(), primary_key=True) + #: The UUID of the event. This is what is presented to the users and used in federation. + event_uuid = db.Column(db.String(length=40), unique=True, nullable=False, default=generate_uuid) + #: The ID of the user who created the event user_id = db.Column(db.Integer(), db.ForeignKey('users.id'), nullable=False)