forked from gergely/calendar-social
[Refactor] Move invitation code to the Event model
This commit is contained in:
@@ -255,7 +255,7 @@ class CalendarSocialApp(Flask):
|
||||
"""
|
||||
|
||||
from .forms import InviteForm
|
||||
from .models import db, Event, Invitation, Notification, NotificationAction
|
||||
from .models import db, Event
|
||||
|
||||
try:
|
||||
event = Event.query.filter(Event.event_uuid == event_uuid).one()
|
||||
@@ -267,15 +267,7 @@ class CalendarSocialApp(Flask):
|
||||
form = InviteForm(event)
|
||||
|
||||
if form.validate_on_submit():
|
||||
invite = Invitation(event=event, sender=current_user.profile)
|
||||
form.populate_obj(invite)
|
||||
db.session.add(invite)
|
||||
|
||||
notification = Notification(profile=form.invitee.data,
|
||||
actor=current_user.profile,
|
||||
item=event,
|
||||
action=NotificationAction.invite)
|
||||
db.session.add(notification)
|
||||
event.invite(current_user.profile, invitee=form.invitee.data)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
Reference in New Issue
Block a user