0.8.33 tickets text

This commit is contained in:
SDE
2023-12-03 20:49:07 +03:00
parent 447a78cd3a
commit fc37bea98a
2 changed files with 12 additions and 7 deletions

View File

@@ -38,8 +38,17 @@ class MsgGroup(BaseModel):
manager = models.ForeignKey(User, verbose_name=_('Менеджер'), related_name='rel_msgGroups_for_manager',
on_delete=models.SET_NULL, null=True)
def get_last_msg(self):
return self.rel_messages_for_group.all().order_by('-createDT').first()
def get_last_msg_txt(self):
msg = self.rel_messages_for_group.all().order_by('-createDT').first()
if not msg:
return self.text
if msg.text:
return msg.text
elif msg.files:
return msg.files[0].file_name
return self.name
class Meta:
verbose_name = _('Тикет')

View File

@@ -19,11 +19,7 @@
<div class="message-sprt-title">
<span>
{# Текст последнего сообщени в чате (с размытием)#}
{% if ticket.get_last_msg.text %}
{{ ticket.get_last_msg.text }}
{% elif ticket.get_last_msg.files %}
{{ ticket.get_last_msg.files.0.file_name }}
{% endif %}
{{ ticket.get_last_msg_txt }}
</span>
</div>