-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: implement checks on session rating #6070
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
feat: implement checks on session rating #6070
Conversation
|
@uds5501 @mrsaicharan1 @kushthedude can you guys tell me how can I create a session with ID 1 for testing? Please see the travis failure error |
877576a to
b168d68
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.
@shreyanshdwivedi Please fix Travis. .apib docs file needs to be fixed here
|
@iamareebjamal how can I create session object for the travis to pass? |
|
factoryboy |
af58543
b168d68 to
af58543
Compare
af58543 to
0ecb230
Compare
0ecb230 to
3fa0de2
Compare
3fa0de2 to
df71f05
Compare
df71f05 to
aa03061
Compare
aa03061 to
796ed91
Compare
|
@iamareebjamal @uds5501 @mrsaicharan1 @kushthedude fixed the travis failure. Please review |
tests/hook_main.py
Outdated
| event = EventFactoryBasic() | ||
| db.session.add(event) | ||
| feedback = FeedbackFactory() | ||
| db.session.add(feedback) |
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.
You should use SessionFactory
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.
Using SessionFactory is failing tests. Moreover all hooks having creation object e.g. user, event, role etc. are followed similarly. I think it'll be okay to use this only @iamareebjamal
Your views?
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.
You changed event feedback to session feedback. Instead, we are supporting both if I'm not wrong
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 yes we are supporting both but currently only session feedback is being used. Moreover the error raised was related to user, not event.User.id = 2 not found. I'm adding a user attribute to check if error is being fixed or not
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 the tests passed. I used both session and user (which are currently into account). When we will kove to event rating, the tests will be updated and EventFactorybasic will be included. Please have a look now
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.
Instead of breaking a functionality, add it in such a way it does not break previous one. Add a new endpoint in API Blueprints instead of changing existing 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.
@iamareebjamal event feedback functionality is non-existent.
There was no check or piece of code which was for event rating functionality in our system. There was only feedback schema with both event and session relationships, so I just used it for session rating. When event rating is to be implemented, we can create a separate API blueprint for it at that time.
However if you think that I should revert the changes and create a separate API blueprint, please let me know. I'll make changes accordingly if you want
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.
The same API was being used for event feedback if I'm not wrong
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 actually there is no event feedback in existence AFAIK. However I've asked others on gitter if it exists.
There was only feedback schema and models which were meant for future implementation. They were never used (atleast in my knowledge).
Is android using it already?
4fb543f to
3299c74
Compare
0ea476d to
5dc7cd1
Compare
|
@iamareebjamal I confirmed with others. There is no functionality for event feedback in place currently. |
docs/api/api_blueprint.apib
Outdated
| "user": { | ||
| "data": { | ||
| "type": "user", | ||
| "id": "2" |
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.
The authenticated user is 1, should be 1 only. It should not be 2
docs/api/api_blueprint.apib
Outdated
| }, | ||
| "type": "feedback", | ||
| "id": 1, | ||
| "id": 2, |
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.
Since there is no other feedback in system before POST request, this should be 1?
5dc7cd1 to
8bff945
Compare
app/factories/feedback.py
Outdated
| event_id = 1 | ||
| comment = "Awesome session." | ||
| session_id = 1 | ||
| user_id = 2 |
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.
user_id 1 is the currently authenticated user. How can user 1 post session for 2? Checks aren't working correctly it seems
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.
Yeah. I somehow missed to set it to 1
But the test passed. That's weird
I'll make it to 1 anyway
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 I've updated it to 1. User with ID 1 can change sessions for 2 because the checks implemented here gives access to someone with organizer access of an event, to create/update feedback for that event -
if session and not has_access('is_organizer', event_id=session.event_id):
raise ForbiddenException({'source': ''},
"Event organizer access required")
8bff945 to
9f430df
Compare
9f430df to
03b5a49
Compare
|
@iamareebjamal please review |
03b5a49 to
6e29e05
Compare
tests/hook_main.py
Outdated
| session = SessionFactory() | ||
| db.session.add(session) | ||
| user = UserFactory() | ||
| db.session.add(user) |
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.
UserFactory is not needed since there already is a user - 1
Update docs for session rating fixes hound issue fixes travis failure update test hook
6e29e05 to
fd31de7
Compare
feat: implement checks on session rating (fossasia#6070)
Fixes fossasia/open-event-frontend#3156
Short description of what this resolves:
There should be checks that feedback can be updated/created only by owner/organizer of the event.
Changes proposed in this pull request:
Checklist
developmentbranch.