-
Notifications
You must be signed in to change notification settings - Fork 25
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
Permissions : Refactoring permissions usage #985
Conversation
8997f1c
to
a852fbb
Compare
a852fbb
to
1df6269
Compare
896e93b
to
e1a3737
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.
Can we get the coverage to green?
bb649d0
to
f862b5f
Compare
f862b5f
to
ce55333
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.
If I try to access following site https://localhost:5000/global/search/documents?q=&page=1&size=10 with deployment setup, I get following error:
127.0.0.1 - - [14/May/2020 16:21:00] "GET /api/documents/?q=&page=1&size=10&view=global HTTP/1.1" 500 -
Traceback (most recent call last):
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 2334, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/werkzeug/middleware/dispatcher.py", line 66, in __call__
return app(environ, start_response)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 2334, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
return self.app(environ, start_response)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 2320, in wsgi_app
response = self.handle_exception(e)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 1766, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 2317, in wsgi_app
response = self.full_dispatch_request()
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 1840, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 1743, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/app.py", line 1838, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
return view_func(**req.view_args)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/invenio_rest/views.py", line 240, in dispatch_request
*args, **kwargs
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/flask/views.py", line 158, in dispatch_request
return meth(*args, **kwargs)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/invenio_records_rest/views.py", line 429, in need_record_permission_decorator
return f(self, record=record, *args, **kwargs)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/invenio_records_rest/views.py", line 511, in inner
return f(self, pagination=req, *args, **kwargs)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/invenio_records_rest/views.py", line 651, in get
item_links_factory=self.item_links_factory,
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/invenio_rest/views.py", line 221, in make_response
return serializer(*args, **kwargs)
File "/Users/wep/devel/virtualenvs/rero-ils-5uhYvcmh-py3.6/lib/python3.6/site-packages/invenio_records_rest/serializers/response.py", line 56, in view
item_links_factory=item_links_factory),
File "/Users/wep/devel/rero/rero-ils/rero_ils/modules/serializers.py", line 103, in serialize_search
results, pid_fetcher), **self._format_args())
File "/Users/wep/devel/rero/rero-ils/rero_ils/modules/documents/serializers.py", line 77, in post_process_serialize_search
metadata.get('pid')).is_available(viewcode)
File "/Users/wep/devel/rero/rero-ils/rero_ils/modules/documents/api.py", line 82, in is_available
if holding.available:
AttributeError: 'NoneType' object has no attribute 'available'
I have restarted the setup -d and I think the error comes from an interrupted ebooks harvesting.
Shall we make our code more robust against this kind of problem?
Do you user my local branch or the PR files to tests ? |
701b63b
to
28bbbee
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.
Commit message approved. Also tested with rero/rero-ils-ui#268
28bbbee
to
af43f76
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.
tests OK. seems that works as expected
* Updates the permission API adding a section about the 'create' permission. * Updates `SearchSerializer` to remove permissions from hit result. Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
af43f76
to
88a9b37
Compare
Remove permissions from
SearchSerializer
to improve API performance.How to test?
https://localhost:5000/api/patrons
https://localhost:5000/api/documents
https://localhost:5000/api/items
https://localhost:5000/api/patrons/3
https://localhost:5000/api/items/3
https://localhost:5000/api/documents/3
Code review check list