-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
permissions: allow read access to holding and items for all users
* Adds possibilities to access loan API for users of same organisation. * Restricts patron API loan search to his own loans. * Adds organisation to the loan schema. * Permits API access to holdings and items for all type of users. * Changes Loan route from /circulation/loans to /loans. * Sets loan API search sort order to loan transaction_date. Co-Authored-by: Aly Badr <aly.badr@rero.ch>
- Loading branch information
Aly Badr
committed
Nov 19, 2019
1 parent
f9a2c1f
commit 7219b7f
Showing
12 changed files
with
224 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2318,4 +2318,4 @@ | |
"default": false | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# RERO ILS | ||
# Copyright (C) 2019 RERO | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Loan permissions.""" | ||
|
||
|
||
from .api import Loan | ||
from ...permissions import patron_is_authenticated, staffer_is_authenticated, \ | ||
user_is_authenticated | ||
|
||
|
||
def can_list_loan_factory(record, *args, **kwargs): | ||
"""Checks if the logged user have access to loans list. | ||
only authenticated users can place a search on loans. | ||
""" | ||
def can(self): | ||
patron = user_is_authenticated() | ||
if patron: | ||
return True | ||
return False | ||
return type('Check', (), {'can': can})() | ||
|
||
|
||
def can_read_loan_factory(record, *args, **kwargs): | ||
"""Checks if the logged user have access to loans of its organisation. | ||
users with librarian or system_librarian roles can acess all loans. | ||
users with patron role can access only its loans. | ||
""" | ||
def can(self): | ||
patron = staffer_is_authenticated() or patron_is_authenticated() | ||
if patron and patron.organisation_pid == Loan(record).organisation_pid: | ||
if patron.is_librarian or patron.is_system_librarian: | ||
return True | ||
elif patron.is_patron and Loan(record).patron_pid == patron.pid: | ||
return True | ||
return False | ||
return type('Check', (), {'can': can})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters