Skip to content

Commit

Permalink
Merge pull request #70 from oarepo/fix-stateful-api
Browse files Browse the repository at this point in the history
Fixed stateful api inconsistencies
  • Loading branch information
mesemus authored Oct 18, 2024
2 parents 1d571ed + d2cf4cd commit 51a4340
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions oarepo_requests/types/delete_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def available_actions(cls):
allowed_topic_ref_types = ModelRefTypes(published=False, draft=True)

@override
def stateful_name(self, identity, *, topic=None, request=None):
def stateful_name(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return self.name
if not request:
Expand All @@ -38,7 +38,7 @@ def stateful_name(self, identity, *, topic=None, request=None):
return _("Request draft deletion")

@override
def stateful_description(self, identity, *, topic=None, request=None):
def stateful_description(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return _("Click to permanently delete the draft.")

Expand Down
4 changes: 2 additions & 2 deletions oarepo_requests/types/delete_published_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def available_actions(cls):
allowed_topic_ref_types = ModelRefTypes(published=True, draft=False)

@override
def stateful_name(self, identity, *, topic=None, request=None):
def stateful_name(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return self.name
if not request:
Expand All @@ -41,7 +41,7 @@ def stateful_name(self, identity, *, topic=None, request=None):
return _("Request record deletion")

@override
def stateful_description(self, identity, *, topic=None, request=None):
def stateful_description(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return _("Click to permanently delete the record.")

Expand Down
4 changes: 2 additions & 2 deletions oarepo_requests/types/edit_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def topic_change(self, request: Request, new_topic: Dict, uow):
uow.register(RecordCommitOp(request, indexer=current_requests_service.indexer))

@override
def stateful_name(self, identity, *, topic=None, request=None):
def stateful_name(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return self.name
if not request:
Expand All @@ -70,7 +70,7 @@ def stateful_name(self, identity, *, topic=None, request=None):
return _("Request edit access")

@override
def stateful_description(self, identity, *, topic=None, request=None):
def stateful_description(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return _("Click to start editing the metadata of the record.")

Expand Down
4 changes: 2 additions & 2 deletions oarepo_requests/types/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def available_actions(cls):
"decline": OARepoDeclineAction,
}

def stateful_name(self, identity, request):
def stateful_name(self, *, identity, topic, request=None, **kwargs):
"""
Returns the name of the request that reflects its current state.
Expand All @@ -74,7 +74,7 @@ def stateful_name(self, identity, request):
"""
return self.name

def stateful_description(self, identity, request):
def stateful_description(self, *, identity, topic, request=None, **kwargs):
"""
Returns the description of the request that reflects its current state.
Expand Down
4 changes: 2 additions & 2 deletions oarepo_requests/types/new_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def topic_change(self, request: Request, new_topic: Dict, uow):
uow.register(RecordCommitOp(request, indexer=current_requests_service.indexer))

@override
def stateful_name(self, identity, *, topic=None, request=None):
def stateful_name(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return self.name
if not request:
Expand All @@ -70,7 +70,7 @@ def stateful_name(self, identity, *, topic=None, request=None):
return _("Request new version access")

@override
def stateful_description(self, identity, *, topic=None, request=None):
def stateful_description(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return _("Click to start creating a new version of the record.")

Expand Down
4 changes: 2 additions & 2 deletions oarepo_requests/types/publish_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def topic_change(self, request: Request, new_topic: Dict, uow):
uow.register(RecordCommitOp(request, indexer=current_requests_service.indexer))

@override
def stateful_name(self, identity, *, topic=None, request=None):
def stateful_name(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return _("Publish draft")
if not request:
Expand All @@ -88,7 +88,7 @@ def stateful_name(self, identity, *, topic=None, request=None):
return _("Submit for review")

@override
def stateful_description(self, identity, *, topic=None, request=None):
def stateful_description(self, identity, *, topic, request=None, **kwargs):
if is_auto_approved(self, identity=identity, topic=topic):
return _(
"Click to immediately publish the draft. "
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-requests
version = 2.2.0
version = 2.2.1
description =
authors = Ronald Krist <[email protected]>
readme = README.md
Expand Down

0 comments on commit 51a4340

Please sign in to comment.