Skip to content

Commit

Permalink
Move get_publication_writer to layman.util
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 13, 2023
1 parent b6f7c58 commit f0b16f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/layman/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,3 +701,12 @@ def get_complete_publication_info(workspace, publication_type, publication_name,
f"publication_status={publication_status}, is_updating_after={is_updating_after}")

return complete_info


def get_publication_writer(workspace, publication_type, publication_name):
from layman.common.prime_db_schema.publications import is_user
info = get_publication_info(workspace, publication_type, publication_name, context={'keys': ['access_rights']})
return next(
user_or_role for user_or_role in info['access_rights']['write']
if user_or_role == settings.RIGHTS_EVERYONE_ROLE or is_user(user_or_role)
)
7 changes: 1 addition & 6 deletions tests/asserts/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import inspect
from layman import util as layman_util, settings, app
from layman.common.prime_db_schema.publications import is_user
from test_tools import process_client
from .. import Action, Publication

Expand All @@ -10,11 +9,7 @@

def get_publication_writer(publication):
with app.app_context():
info = layman_util.get_publication_info(publication.workspace, publication.type, publication.name, context={'keys': ['access_rights']})
writer = next(
user_or_role for user_or_role in info['access_rights']['write']
if user_or_role == settings.RIGHTS_EVERYONE_ROLE or is_user(user_or_role)
)
writer = layman_util.get_publication_writer(publication.workspace, publication.type, publication.name)
return writer


Expand Down

0 comments on commit f0b16f7

Please sign in to comment.