-
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: Make event-invoices endpoint admin only #7096
Conversation
Codecov Report
@@ Coverage Diff @@
## development #7096 +/- ##
===============================================
- Coverage 62.01% 62.00% -0.01%
===============================================
Files 262 262
Lines 12995 13000 +5
===============================================
+ Hits 8059 8061 +2
- Misses 4936 4939 +3
Continue to review full report at Codecov.
|
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 everyone can edit and delete invoices
@iamareebjamal Please review |
app/api/event_invoices.py
Outdated
@@ -39,6 +40,10 @@ def query(self, view_kwargs): | |||
:param view_kwargs: | |||
:return: | |||
""" | |||
user = current_user | |||
if not user.is_admin and not user.is_super_admin: |
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.
is_staff
@@ -61,8 +61,9 @@ def is_organizer(view, view_args, view_kwargs, *args, **kwargs): | |||
if user.is_staff: | |||
return view(*view_args, **view_kwargs) | |||
|
|||
if user.is_owner(kwargs['event_id']) or user.is_organizer(kwargs['event_id']): | |||
return view(*view_args, **view_kwargs) | |||
if kwargs.get('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.
This can be extracted in a variable and reused
Here is an overview of what got changed by this pull request: Complexity increasing per file
==============================
- app/api/event_invoices.py 1
See the complete overview on Codacy |
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.
Perfect, please change PR name to what you have currently done
Ignore remaining deepsource issues. We should only fix code related to issue. Don't revert the already made changes though |
Fixes #7063
Short description of what this resolves:
Currently
/event-invoices
endpoint requires theevent_id
param in url or expects the user to be admin, which is not the case for this endpoint.Changes proposed in this pull request:
Remove decorators
is_organizer
andis_admin
.Checklist
development
branch.