Added short_description property to Ticket

returns a cleaned version of the description limited to 150 characters.

Suffixed with "...".
This commit is contained in:
2024-01-19 17:54:11 +00:00
parent 880bab8d33
commit bd57cfb94d

View File

@ -103,6 +103,12 @@ class Ticket(models.Model):
)
return cleaned_description
def short_description(self):
"""Provide a snippet of the description for presentation purposes."""
short_description = bleach.clean(self.description, tags=[])[:150]
return f"{short_description}..."
def save(self, *args, **kwargs):
"""Override the save method to clean the description and apply timestamps."""