Skip to content

Conversation

@shreyanshdwivedi
Copy link
Member

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:

  • Updates the typo
  • Updates docs
  • Implemented checks on feedback so that it can be updated/created only by owner/organizer of the event.

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

@auto-label auto-label bot added the feature label Jun 19, 2019
@shreyanshdwivedi
Copy link
Member Author

@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

iamareebjamal
iamareebjamal previously approved these changes Jun 19, 2019
uds5501
uds5501 previously approved these changes Jun 19, 2019
kushthedude
kushthedude previously approved these changes Jun 19, 2019
Copy link
Member

@mrsaicharan1 mrsaicharan1 left a 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

@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal how can I create session object for the travis to pass?

@iamareebjamal
Copy link
Member

factoryboy

@fossasia fossasia deleted a comment Jun 21, 2019
@fossasia fossasia deleted a comment Jun 21, 2019
@fossasia fossasia deleted a comment Jun 21, 2019
@fossasia fossasia deleted a comment Jun 21, 2019
@shreyanshdwivedi shreyanshdwivedi changed the title feat: implement checks on session rating [WIP] feat: implement checks on session rating Jun 21, 2019
@auto-label auto-label bot removed the feature label Jun 21, 2019
@fossasia fossasia deleted a comment Jun 22, 2019
@fossasia fossasia deleted a comment Jun 22, 2019
@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal @uds5501 @mrsaicharan1 @kushthedude fixed the travis failure. Please review

event = EventFactoryBasic()
db.session.add(event)
feedback = FeedbackFactory()
db.session.add(feedback)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use SessionFactory

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

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?

@shreyanshdwivedi shreyanshdwivedi changed the title [WIP] feat: implement checks on session rating feat: implement checks on session rating Jun 22, 2019
@auto-label auto-label bot added the feature label Jun 22, 2019
@fossasia fossasia deleted a comment Jun 22, 2019
@fossasia fossasia deleted a comment Jun 22, 2019
@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal I confirmed with others. There is no functionality for event feedback in place currently.
So when event feedback is to be implemented, we can create a new API blueprint for it then

"user": {
"data": {
"type": "user",
"id": "2"
Copy link
Member

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

},
"type": "feedback",
"id": 1,
"id": 2,
Copy link
Member

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?

event_id = 1
comment = "Awesome session."
session_id = 1
user_id = 2
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member Author

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")

@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal please review

session = SessionFactory()
db.session.add(session)
user = UserFactory()
db.session.add(user)
Copy link
Member

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
@iamareebjamal iamareebjamal merged commit 5ae00ff into fossasia:development Jun 26, 2019
satyasashi added a commit to satyasashi/open-event-server that referenced this pull request Jun 27, 2019
feat: implement checks on session rating (fossasia#6070)
iamareebjamal pushed a commit to iamareebjamal/open-event-server that referenced this pull request Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement checks for ratings of sessions by event organizer/owner

6 participants