Skip to content

Commit 4b92ad0

Browse files
committed
feat(core): Only add threads URL to comment if there are threads
ref: #1072
1 parent 707a3cf commit 4b92ad0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

app/core/serializers/ticketcommentbase.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,19 @@ def get_url(self, item) -> dict:
8888

8989
if item.id is not None and item.__class__._meta.model_name != 'ticketcommentsolution':
9090

91-
urls.update({
92-
'threads': reverse(
93-
'API:_api_ticket_comment_base_sub_thread-list',
94-
request = self._context['view'].request,
95-
kwargs={
96-
'ticket_id': ticket_id,
97-
'ticket_comment_model': 'comment',
98-
'parent_id': item.id
99-
}
100-
)
101-
})
91+
if len(item.threads.all()) > 1: # Only present threads URL when there are threads.
92+
93+
urls.update({
94+
'threads': reverse(
95+
'API:_api_ticket_comment_base_sub_thread-list',
96+
request = self._context['view'].request,
97+
kwargs={
98+
'ticket_id': ticket_id,
99+
'ticket_comment_model': 'comment',
100+
'parent_id': item.id
101+
}
102+
)
103+
})
102104

103105
return urls
104106

0 commit comments

Comments
 (0)