Added short_description property to Ticket
returns a cleaned version of the description limited to 150 characters. Suffixed with "...".
This commit is contained in:
@ -103,6 +103,12 @@ class Ticket(models.Model):
|
|||||||
)
|
)
|
||||||
return cleaned_description
|
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):
|
def save(self, *args, **kwargs):
|
||||||
"""Override the save method to clean the description and apply timestamps."""
|
"""Override the save method to clean the description and apply timestamps."""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user