From 55ea0962cb3b041af29ef8a5768eab53f1ef8fb5 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 25 Jul 2024 12:33:58 +0200 Subject: [PATCH] fix logic --- src/collective/feedback/restapi/services/get.py | 3 +-- src/collective/feedback/tests/test_feedbacks_get.py | 11 ++--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/collective/feedback/restapi/services/get.py b/src/collective/feedback/restapi/services/get.py index a32b16f..ab91d66 100644 --- a/src/collective/feedback/restapi/services/get.py +++ b/src/collective/feedback/restapi/services/get.py @@ -116,6 +116,7 @@ def get_single_object_feedbacks(self, uid): "answer": record._attrs.get("answer", ""), "comment": record._attrs.get("comment", ""), "title": commented_object.title, + "id": record.intid, } ) @@ -136,7 +137,6 @@ def get_data(self): uid = feedback._attrs.get("uid", "") date = feedback._attrs.get("date", "") vote = feedback._attrs.get("vote", "") - id = feedback.intid if uid not in feedbacks: obj = self.get_commented_obj(uid=uid) @@ -151,7 +151,6 @@ def get_data(self): "comments": 0, "title": feedback._attrs.get("title", ""), "uid": uid, - "id": id, } if obj: diff --git a/src/collective/feedback/tests/test_feedbacks_get.py b/src/collective/feedback/tests/test_feedbacks_get.py index f238fdf..b505567 100644 --- a/src/collective/feedback/tests/test_feedbacks_get.py +++ b/src/collective/feedback/tests/test_feedbacks_get.py @@ -37,13 +37,9 @@ def add_record(self, date=None, vote="", uid="", comment="", title=""): record.attrs["uid"] = uid if title: record.attrs["title"] = title - - id = soup.add(record) - + soup.add(record) transaction.commit() - return id - def setUp(self): self.app = self.layer["app"] self.portal = self.layer["portal"] @@ -119,7 +115,7 @@ def test_endpoint_returns_data(self): res = response.json() self.assertEqual(res["items_total"], 0) now = datetime.now() - id = self.add_record(vote=1, comment="is ok", date=now) + self.add_record(vote=1, comment="is ok", date=now) response = self.api_session.get(self.url) res = response.json() @@ -130,7 +126,6 @@ def test_endpoint_returns_data(self): [ { "comments": 1, - "id": id, "last_vote": json_compatible(now), "title": "", "uid": "", @@ -164,7 +159,6 @@ def test_global_editor_can_see_all_data(self): comment="ok also for restricted", uid=self.restricted_document.UID(), ) - api_session = RelativeSession(self.portal_url) api_session.headers.update({"Accept": "application/json"}) api_session.auth = ("global", "secret!!") @@ -185,7 +179,6 @@ def test_local_editor_can_see_only_data_for_his_contents(self): comment="ok also for restricted", uid=self.restricted_document.UID(), ) - api_session = RelativeSession(self.portal_url) api_session.headers.update({"Accept": "application/json"}) api_session.auth = ("local", "secret!!")