Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Nov 20, 2024
1 parent 8d23542 commit eaaf4a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/palace/manager/api/admin/controller/lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ def hide_lane(self, lane_identifier):
return Response(str(_("Success")), 200)

def reset(self):
self.require_library_manager(get_request_library())
library = get_request_library()
self.require_library_manager(library)

create_default_lanes(self._db, get_request_library())
create_default_lanes(self._db, library)
return Response(str(_("Success")), 200)

def change_order(self):
Expand Down
30 changes: 17 additions & 13 deletions src/palace/manager/api/admin/controller/work_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ def details(self, identifier_type, identifier):
:return: An OPDSEntryResponse
"""
self.require_librarian(get_request_library())
library = get_request_library()
self.require_librarian(library)

work = self.load_work(get_request_library(), identifier_type, identifier)
work = self.load_work(library, identifier_type, identifier)
if isinstance(work, ProblemDetail):
return work

annotator = AdminAnnotator(self.circulation, get_request_library())
annotator = AdminAnnotator(self.circulation, library)

# single_entry returns an OPDSEntryResponse that will not be
# cached, which is perfect. We want the admin interface
Expand Down Expand Up @@ -137,7 +138,8 @@ def rights_status(self):

def edit(self, identifier_type, identifier):
"""Edit a work's metadata."""
self.require_librarian(get_request_library())
library = get_request_library()
self.require_librarian(library)

# TODO: It would be nice to use the metadata layer for this, but
# this code handles empty values differently than other metadata
Expand All @@ -146,7 +148,7 @@ def edit(self, identifier_type, identifier):
# db so that it can overrule other data sources that set a value,
# unlike other sources which set empty fields to None.

work = self.load_work(get_request_library(), identifier_type, identifier)
work = self.load_work(library, identifier_type, identifier)
if isinstance(work, ProblemDetail):
return work

Expand Down Expand Up @@ -434,9 +436,10 @@ def unsuppress(

def refresh_metadata(self, identifier_type, identifier, provider=None):
"""Refresh the metadata for a book from the content server"""
self.require_librarian(get_request_library())
library = get_request_library()
self.require_librarian(library)

work = self.load_work(get_request_library(), identifier_type, identifier)
work = self.load_work(library, identifier_type, identifier)
if isinstance(work, ProblemDetail):
return work

Expand Down Expand Up @@ -465,9 +468,10 @@ def refresh_metadata(self, identifier_type, identifier, provider=None):

def classifications(self, identifier_type, identifier):
"""Return list of this work's classifications."""
self.require_librarian(get_request_library())
library = get_request_library()
self.require_librarian(library)

work = self.load_work(get_request_library(), identifier_type, identifier)
work = self.load_work(library, identifier_type, identifier)
if isinstance(work, ProblemDetail):
return work

Expand Down Expand Up @@ -503,9 +507,10 @@ def classifications(self, identifier_type, identifier):

def edit_classifications(self, identifier_type, identifier):
"""Edit a work's audience, target age, fiction status, and genres."""
self.require_librarian(get_request_library())
library = get_request_library()
self.require_librarian(library)

work = self.load_work(get_request_library(), identifier_type, identifier)
work = self.load_work(library, identifier_type, identifier)
if isinstance(work, ProblemDetail):
return work

Expand Down Expand Up @@ -671,9 +676,8 @@ def edit_classifications(self, identifier_type, identifier):
return Response("", 200)

def custom_lists(self, identifier_type, identifier):
self.require_librarian(get_request_library())

library = get_request_library()
self.require_librarian(library)
work = self.load_work(library, identifier_type, identifier)
if isinstance(work, ProblemDetail):
return work
Expand Down

0 comments on commit eaaf4a4

Please sign in to comment.