forked from gergely/calendar-social
[Refactor] Move invitation code to the Event model
This commit is contained in:
@@ -417,6 +417,23 @@ class Event(db.Model):
|
||||
|
||||
return url_for('event_details', event_uuid=self.event_uuid)
|
||||
|
||||
def invite(self, inviter, invited):
|
||||
"""Invite ``invited`` to the event
|
||||
|
||||
The invitation will arrive from ``inviter``.
|
||||
"""
|
||||
|
||||
invite = Invitation(event=self, sender=inviter, invitee=invited)
|
||||
db.session.add(invite)
|
||||
|
||||
notification = Notification(profile=invited,
|
||||
actor=inviter,
|
||||
item=self,
|
||||
action=NotificationAction.invite)
|
||||
db.session.add(notification)
|
||||
|
||||
return invite
|
||||
|
||||
|
||||
class UserSetting(db.Model): # pylint: disable=too-few-public-methods
|
||||
"""Database model for user settings
|
||||
|
Reference in New Issue
Block a user