Skip to content

Commit

Permalink
Accept data as json body for @reset-counter endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Dec 17, 2024
1 parent c2e43a8 commit b94f248
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from zExceptions import BadRequest
from zExceptions import NotFound
from zope.annotation.interfaces import IAnnotations
from plone.restapi.deserializer import json_body


class CounterReset(Service):
Expand All @@ -25,13 +26,15 @@ def get_block_id(self, block_id):
return id

def reply(self):
block_id = self.get_block_id(self.request.get("block_id"))
data = json_body(self.request)
block_id = self.get_block_id(data.get("block_id"))

if not block_id:
raise NotFound(self.context, "", self.request)

try:
counter_value = int(self.request.get("counter_value", 0))
counter_value = int(data.get("counter_value", 0))

except ValueError:
raise BadRequest(
"Badly composed `counter_value` parameter, integer required."
Expand Down

0 comments on commit b94f248

Please sign in to comment.