# 86 Comment field length
* removes comment field length limit * adds improvements for rendering large comments
This commit is contained in:
@@ -52,3 +52,19 @@ def default_if_zero(val1, val2):
|
||||
|
||||
"""
|
||||
return val1 if val1 > 0 else val2
|
||||
|
||||
|
||||
@register.filter("shorten")
|
||||
def shorten(val, length):
|
||||
""" Returns val shortened to the first number of length character
|
||||
|
||||
Args:
|
||||
val (str): The value
|
||||
length (int): The number of characters left
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
if val is not None and len(val) > length:
|
||||
val = f"{val[:length]}..."
|
||||
return val
|
||||
|
||||
Reference in New Issue
Block a user