Skip to content

feat(RecordCommunitiesService): Add get_record_requests service method#2294

Open
sakshamarora1 wants to merge 1 commit intoinveniosoftware:masterfrom
sakshamarora1:feat/show_accepted_request
Open

feat(RecordCommunitiesService): Add get_record_requests service method#2294
sakshamarora1 wants to merge 1 commit intoinveniosoftware:masterfrom
sakshamarora1:feat/show_accepted_request

Conversation

@sakshamarora1
Copy link
Copy Markdown
Contributor

closes: inveniosoftware/invenio-requests#568
requires: inveniosoftware/invenio-communities#1361

  • Moved from invenio_app_rdm/records_ui/views/records.py
  • Since the function checks for permissions and also access the API layer, it should be a service method following the existing methods in this service class also accessing the communities API

  * Moved from invenio_app_rdm/records_ui/views/records.py
  * Since the function checks for permissions and also access the API layer, it should be a service method following the existing methods in this service class also accessing the communities API
Comment on lines +512 to +546
parent = record._record.parent
community_requests = parent.communities.get_requests()
community_requests = {
str(request.community_id): str(request.request_id)
for request in community_requests
}

# Get the requests that concern only the current record, i.e. submission or inclusion regardless of their status
# This takes precedence over only considering accepted requests because there may be an unaccepted request in this
# version of the record that should be shown instead of the accepted request.
record_requests = current_requests_service.search(
identity,
extra_filter=dsl.Q(
"bool",
must=[
dsl.Q("term", **{"topic.record": record.id}),
dsl.Q(
"terms",
**{
"type": [
CommunityInclusion.type_id,
CommunitySubmission.type_id,
]
},
),
],
),
params={"sort": "oldest"},
)
record_requests = {
request["receiver"]["community"]: request["id"]
for request in record_requests
}

community_requests.update(record_requests)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this potentially overwrite requests? If a community have an accepted request from parent.communities.get_requests() and a pending request?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the pending request is shown. Only in case there is no request for the record as a topic, it will show the accepted request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"View comments" button under the community is not visible on other record versions (landing page)

2 participants