-
Notifications
You must be signed in to change notification settings - Fork 8
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
Type param #177
Type param #177
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.
Looks good, just the comment about efficiency.
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.
Some minor comments but overall I think it looks good based on my understanding of what we are trying to achieve.
biblib/views/user_view.py
Outdated
@@ -228,8 +222,9 @@ def get(self): | |||
if sort_order not in ['asc', 'desc']: | |||
raise ValueError | |||
|
|||
ownership = get_params.get('ownership', default=False, type=check_boolean) | |||
current_app.logger.debug("GET params: {}, start: {}, end: {}".format(get_params, start, rows)) | |||
type = get_params.get('type', default='all', type=str) |
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.
My only concern on this is that type
is a python builtin, so it might be worth renaming to something safer in case type()
becomes relevant in the future.
biblib/views/user_view.py
Outdated
libraries_response['shared_with_me'] = shared_with_me | ||
else: | ||
libraries_response['libraries'] = my_libraries | ||
if type == 'all' or (type == 'owner' and main_permission in ['owner']) or (type == 'collaborator' and main_permission in ['admin', 'read', 'write']): |
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.
Maybe I am missing something, but do we still need this if
with the filtering incorporated in the new method you wrote above?
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.
Yes, seems like this part and the slicing of list (below) are not needed anymore
biblib/views/user_view.py
Outdated
@@ -58,9 +58,24 @@ def retrieve_user_email(owner_absolute_uid): | |||
service | |||
) | |||
return response | |||
|
|||
@classmethod | |||
def get_user_libraries(cls, session, service_uid, sort_col, sort_order, type): |
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.
I think this method looks good and also makes that previous query a lot more readable.
biblib/views/user_view.py
Outdated
|
||
if type == 'owner': | ||
query = query.filter(Permissions.permissions['owner'].astext.cast(Boolean).is_(True)) | ||
elif type != 'all': |
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 there a particular reason you opted for !='all'
instead of =='collaborator'
?
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.
Things look good to me
Desired behavior
Request
Response