-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: sessions cannot be edited after cfs ends #6757
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test this locally?
@mrsaicharan1 - Yes the CI is failing, I am fixing the dredd test |
a77cb48
to
c081efd
Compare
Codecov Report
@@ Coverage Diff @@
## development #6757 +/- ##
===============================================
- Coverage 65.4% 65.38% -0.02%
===============================================
Files 300 301 +1
Lines 15337 15356 +19
===============================================
+ Hits 10031 10041 +10
- Misses 5306 5315 +9
Continue to review full report at Codecov.
|
app/api/sessions.py
Outdated
@@ -148,6 +150,11 @@ 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') | |||
if speakers_call.ends_at.replace(tzinfo=None) <= datetime.now().replace(tzinfo=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I won't be able to delete the session as well.
Second, you have made it timezone unaware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal - Shall the sessions be deleted after the CFS is ended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admin/Co-organizer should be able to edit and delete both
c081efd
to
6673ac4
Compare
6673ac4
to
8a4c251
Compare
@iamareebjamal - Review |
8a4c251
to
dbab61c
Compare
dbab61c
to
ceb867e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the complete issue, Speaker details needs to be locked as well. Or if you are partially fixing than don't mention the fixes keyword!
I have read the issue, the speaker details can't be locked currently as it's related to the user not the CFS of the event. Once the speaker is created the same profile is applied for all the cfs of every event. Edit: The above is not true as the speaker profile is generated everytime for every new event |
Remove the keyword fixes then.
…On Sun, 19 Jan, 2020, 11:37 Suneet Srivastava, ***@***.***> wrote:
Read the complete issue, Speaker details needs to be locked as well
I have read the issue, the speaker details can't be locked currently as
it's related to the user not the CFS of the event. Once the speaker is
created the same profile is applied for all the cfs of every event.
@kushthedude <https://github.com/kushthedude>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6757?email_source=notifications&email_token=AKQMTLVGFT43OFLUTM6QYQ3Q6PU3FA5CNFSM4KITREOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJKJ4WY#issuecomment-575970907>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKQMTLRFGS7H3W4W3FU7R5LQ6PU3FANCNFSM4KITREOA>
.
|
@kushthedude - What I looked upon is for every event a new speaker profile is generated. |
e8965e9
to
865d84d
Compare
70ed3e9
to
5f0755e
Compare
@iamareebjamal @kushthedude @mrsaicharan1 - Please review. Thanks |
@iamareebjamal - Review please thanks. |
app/api/speakers.py
Outdated
if speakers_call and not (has_access('is_admin') or has_access('is_organizer', event_id=speaker.event_id) or | ||
has_access('is_coorganizer', event_id=speaker.event_id)): | ||
speakers_call_tz = speakers_call.ends_at.tzinfo | ||
if speakers_call.ends_at <= datetime.now().replace(tzinfo=speakers_call_tz): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate logic
5f0755e
to
63d26c3
Compare
app/api/speakers.py
Outdated
from app.models.session_speaker_link import SessionsSpeakersLink | ||
from app.models.user import User | ||
|
||
from datetime import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'datetime.datetime' imported but unused
app/api/speakers.py
Outdated
from app.api.schema.speakers import SpeakerSchema | ||
from app.models import db | ||
from app.models.event import Event | ||
from app.models.session import Session | ||
from app.models.speaker import Speaker | ||
from app.models.speakers_call import SpeakersCall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'app.models.speakers_call.SpeakersCall' imported but unused
app/api/sessions.py
Outdated
@@ -17,6 +18,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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'datetime.datetime' imported but unused
app/api/sessions.py
Outdated
@@ -17,6 +18,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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'app.models.speakers_call.SpeakersCall' imported but unused
app/api/helpers/speaker.py
Outdated
else: | ||
return True | ||
else: | ||
raise ForbiddenException({'source' : '/data/event-id'}, 'Speaker Calls for event {id} not found'.format(id=event_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (125 > 120 characters)
whitespace before ':'
app/api/helpers/speaker.py
Outdated
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=event_id) or has_access('is_coorganizer', event_id=event_id)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
visually indented line with same indent as next logical line
app/api/helpers/speaker.py
Outdated
@@ -0,0 +1,22 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
63d26c3
to
9eba3ca
Compare
app/api/helpers/speaker.py
Outdated
speakers_call = SpeakersCall.query.filter_by(event_id=event_id).one() | ||
if speakers_call: | ||
speakers_call_tz = speakers_call.ends_at.tzinfo | ||
if speakers_call.ends_at <= datetime.now().replace(tzinfo=speakers_call_tz)\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
110d5d1
to
7236b59
Compare
app/api/helpers/speaker.py
Outdated
speakers_call = SpeakersCall.query.filter_by(event_id=event_id).one() | ||
if speakers_call: | ||
speakers_call_tz = speakers_call.ends_at.tzinfo | ||
if speakers_call.ends_at <= datetime.now().replace(tzinfo=speakers_call_tz) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
@iamareebjamal - Review now |
app/api/helpers/speaker.py
Outdated
speakers_call = SpeakersCall.query.filter_by(event_id=event_id).one() | ||
if speakers_call: | ||
speakers_call_tz = speakers_call.ends_at.tzinfo | ||
if speakers_call.ends_at <= datetime.now().replace(tzinfo=speakers_call_tz) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use datetime.utcnow()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal - Won't work
TypeError: can't compare offset-naive and offset-aware datetimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to compare the current time (with the timezone of the speaker call) and the speaker call end date which already is timezone aware
app/api/helpers/speaker.py
Outdated
speakers_call = SpeakersCall.query.filter_by(event_id=event_id).one() | ||
if speakers_call: | ||
speakers_call_tz = speakers_call.ends_at.tzinfo | ||
if speakers_call.ends_at <= datetime.now().replace(tzinfo=speakers_call_tz) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just return not of this expression, no need for explicit returns of boolean
7236b59
to
5921239
Compare
@iamareebjamal - Ping! |
app/api/helpers/speaker.py
Outdated
Method to check that user has permission to edit the speaker or session | ||
after the CFS ends | ||
""" | ||
speakers_call = SpeakersCall.query.filter_by(event_id=event_id).one() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will not filter out deleted speaker calls
5921239
to
73ae8f9
Compare
Method to check that user has permission to edit the speaker or session | ||
after the CFS ends | ||
""" | ||
speakers_call = SpeakersCall.query.filter_by(event_id=event_id, deleted_at=None).one() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
Complexity increasing per file
==============================
- app/api/helpers/speaker.py 5
See the complete overview on Codacy |
@iamareebjamal - Review |
@iamareebjamal - Thankyou lord 🥇😆 |
Fixes #6726
Short description of what this resolves:
fix: sessions cannot be edited after cfs ends
Checklist
development
branch.