Skip to content

Commit

Permalink
patron: use of checkboxes for roles
Browse files Browse the repository at this point in the history
* Changing the json schema to use the multicheckbox type for the role field.
* Fix the Alembic role migration script.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
Garfield-fr and zannkukai committed Feb 7, 2023
1 parent 2880407 commit 6d7bdc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
11 changes: 7 additions & 4 deletions rero_ils/alembic/5f0b086e4b82_patron_role_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ def upgrade():

def get_new_roles(roles):
if 'system_librarian' in roles:
return [UserRole.FULL_PERMISSIONS]
elif 'librarian' in roles:
return [
roles.remove('system_librarian')
roles.append(UserRole.FULL_PERMISSIONS)
if 'librarian' in roles:
roles.remove('librarian')
roles.extend([
UserRole.PROFESSIONAL_READ_ONLY,
UserRole.ACQUISITION_MANAGER,
UserRole.CATALOG_MANAGER,
UserRole.CIRCULATION_MANAGER,
UserRole.USER_MANAGER
]
])
return roles

query = PatronsSearch()\
.filter('terms', roles=['librarian', 'system_librarian'])\
Expand Down
20 changes: 6 additions & 14 deletions rero_ils/modules/patrons/jsonschemas/patrons/patron-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,11 @@
"pro_user_manager",
"pro_acquisition_manager",
"pro_library_administrator"
],
"form": {
"type": "selectWithSort",
]
},
"form": {
"type": "multicheckbox",
"templateOptions": {
"options": [
{
"label": "patron",
Expand Down Expand Up @@ -475,17 +477,7 @@
"label": "pro_library_administrator",
"value": "pro_library_administrator"
}
]
}
},
"form": {
"validation": {
"messages": {
"roleMessage": "This user has already a professional role in another organisation. A user can be professional only in one organisation."
}
},
"fieldMap": "roles",
"templateOptions": {
],
"wrappers": [
"card"
]
Expand Down

0 comments on commit 6d7bdc7

Please sign in to comment.