Skip to content

Commit

Permalink
fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Jul 25, 2024
1 parent 7251c0a commit 55ea096
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/collective/feedback/restapi/services/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)

Expand All @@ -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)
Expand All @@ -151,7 +151,6 @@ def get_data(self):
"comments": 0,
"title": feedback._attrs.get("title", ""),
"uid": uid,
"id": id,
}

if obj:
Expand Down
11 changes: 2 additions & 9 deletions src/collective/feedback/tests/test_feedbacks_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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()
Expand All @@ -130,7 +126,6 @@ def test_endpoint_returns_data(self):
[
{
"comments": 1,
"id": id,
"last_vote": json_compatible(now),
"title": "",
"uid": "",
Expand Down Expand Up @@ -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!!")
Expand All @@ -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!!")
Expand Down

0 comments on commit 55ea096

Please sign in to comment.