Skip to content
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

packages api: handling packages with multiple owners #217

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions geo_rdm_records/base/services/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def create_search(
search = search_opts.search_cls(
using=current_search_client,
default_filter=default_filter,
index=index or indices, # enabling multiple indices search
index=indices
or record_cls.index.search_alias, # enabling multiple indices search
)

search = (
Expand Down Expand Up @@ -76,7 +77,6 @@ def search_request(
extra_filter=None,
permission_action="read",
indices=None,
index=None,
):
"""Factory for creating a Search DSL instance."""
search = self.create_search(
Expand All @@ -87,7 +87,6 @@ def search_request(
preference=preference,
extra_filter=extra_filter,
indices=indices,
index=index,
)

# Run search args evaluator
Expand Down Expand Up @@ -128,7 +127,6 @@ def _search(
extra_filter=extra_filter,
permission_action=permission_action,
indices=indices,
index=index,
)

# Run components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def context_associate_resource(self, identity, package=None, record=None, **kwar
# for the package.
record.parent.relationship.managed_by = package.parent

# Include owners
# Note: Added to handle cases where a package has multiple
# users accessing it.
record.parent["access"] = package.parent["access"]

def context_dissociate_resource(
self, identity, package=None, record=None, **kwargs
):
Expand All @@ -27,6 +32,9 @@ def context_dissociate_resource(
# avoiding errors
del record.parent.relationship.managed_by

# Note: As only drafts can be associated with a package, it is assumed
# that removing owners is not required in the dissociation operation.

def context_update_access(self, identity, data=None, record=None, errors=None):
"""Update draft handler."""
package_context_access = data.get("access", {})
Expand Down
Loading