-
Notifications
You must be signed in to change notification settings - Fork 50
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
circulation: Support self checkout by patrons #1213
circulation: Support self checkout by patrons #1213
Conversation
2c9b2d3
to
674f4ca
Compare
@@ -315,3 +315,6 @@ | |||
}, | |||
) | |||
) | |||
|
|||
# Feature Toggles | |||
CIRCULATION_SELF_CHECKOUT_ENABLED = SELF_CHECKOUT_ENABLED |
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.
Could you clarify why is this assignment needed?
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, circulation is an extension it uses the circulation config and not the main config, so this is needed to get the value from the main config.
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 wouldn't fit this variable under circulation because we are not bringing this change to the circulation module. The prefixes like CIRCULATION_
or ILS_
are meant to hint from which module the variable is coming from
invenio_app_ils/config.py
Outdated
@@ -1071,3 +1078,6 @@ def _(x): | |||
ILS_PATRON_SYSTEM_AGENT_CLASS = SystemAgent | |||
|
|||
DB_VERSIONING_USER_MODEL = None | |||
|
|||
# Feature Toggles | |||
SELF_CHECKOUT_ENABLED = False |
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.
to keep the config variables naming consistent:
SELF_CHECKOUT_ENABLED = False | |
ILS_SELF_CHECKOUT_ENABLED = False |
invenio_app_ils/permissions.py
Outdated
"bulk-loan-extension", | ||
] | ||
is_authenticated_user = current_app.config.get( | ||
"ILS_AUTHENTICATED_USER_PERMISSIONS", [] |
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.
well done for caring for flexibility of the configuration!
In this case it is a bit overkill though, because we already had the config:
ILS_VIEWS_PERMISSIONS_FACTORY = views_permissions_factory
invenio_app_ils/circulation/api.py
Outdated
# 1. self checkout feature flag is enabled | ||
# 2. The patron ids match | ||
if ( | ||
kwargs.get("self_checkout", False) |
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.
just a reminder: we agreed to check if the action is performed by the librarian, not to pass the kwarg from the UI, since it is more reliable check.
invenio_app_ils/circulation/api.py
Outdated
if ( | ||
kwargs.get("self_checkout", False) | ||
and current_app.config.get("CIRCULATION_SELF_CHECKOUT_ENABLED", False) | ||
and patron_pid != current_user.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.
for readability (check if the logic is correct ;) the point is to have less content heavy conditional statements to be able to understand the bussiness logic behind it easier:
if ( | |
kwargs.get("self_checkout", False) | |
and current_app.config.get("CIRCULATION_SELF_CHECKOUT_ENABLED", False) | |
and patron_pid != current_user.id | |
): | |
self_checkout_enabled = current_app.config.get("CIRCULATION_SELF_CHECKOUT_ENABLED", False) | |
is_librarian = .... check if librarian | |
is_patron_current_user = patron_pid == current_user.id | |
if self_checkout_enabled and (not is_librarian or not is_patron_current_user): |
8ae4a08
to
89635a3
Compare
98e9907
to
1eb37bc
Compare
closes: CERNDocumentServer/cds-ils#839