Skip to content

Commit

Permalink
fix: sessions cannot be edited after cfs ends
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI committed Jan 18, 2020
1 parent f1787ca commit 8a4c251
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/api/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from app.models.session_type import SessionType
from app.models.speaker import Speaker
from app.models.track import Track
from app.models.speakers_call import SpeakersCall
from datetime import datetime
from app.models.user import User
from app.models.session_speaker_link import SessionsSpeakersLink
from app.settings import get_settings
Expand Down Expand Up @@ -148,6 +150,13 @@ def before_update_object(self, session, data, view_kwargs):
if session.is_locked and data.get('is_locked') == session.is_locked:
raise ForbiddenException({'source': '/data/attributes/is-locked'}, "Locked sessions cannot be edited")

speakers_call = safe_query(self, SpeakersCall, 'event_id', session.event_id, 'event-id')
speakers_call_tz = speakers_call.ends_at.tzinfo
if speakers_call.ends_at <= datetime.now().replace(tzinfo=speakers_call_tz) and \
not (has_access('is_admin') or has_access('is_organizer', event_id=session.event_id)):
raise ForbiddenException({'source': ''},
"Cannot edit session after the call for speaker is ended")

def after_update_object(self, session, data, view_kwargs):
""" Send email if session accepted or rejected """

Expand Down
4 changes: 4 additions & 0 deletions tests/hook_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,8 @@ def session_patch(transaction):
"""
with stash['app'].app_context():
session = SessionFactory()
speakers_call = SpeakersCallFactory()
db.session.add(speakers_call)
db.session.add(session)
db.session.commit()

Expand All @@ -1081,6 +1083,8 @@ def session_delete(transaction):
"""
with stash['app'].app_context():
session = SessionFactory()
speakers_call = SpeakersCallFactory()
db.session.add(speakers_call)
db.session.add(session)
db.session.commit()

Expand Down

0 comments on commit 8a4c251

Please sign in to comment.