Aevann 2024-02-15 20:48:36 +02:00
parent fad0f736f3
commit 6c7eb8a3b2
5 changed files with 15 additions and 4 deletions

View File

@ -16,6 +16,7 @@ class Group(Base):
created_utc = Column(Integer)
owner_id = Column(Integer, ForeignKey("users.id"))
description = Column(String)
description_html = Column(String)
memberships = relationship("GroupMembership", primaryjoin="GroupMembership.group_name==Group.name", order_by="GroupMembership.approved_utc")
owner = relationship("User", primaryjoin="Group.owner_id==User.id")

View File

@ -353,10 +353,18 @@ def group_change_description(v, group_name):
if description:
description = description.strip()
if len(description) > 100:
abort(400, "New description is too long (max 100 characters)")
description_html = filter_emojis_only(description)
if len(description_html) > 500:
abort(400, "Rendered description is too long!")
else:
description = None
description_html = None
group.description = description
group.description_html = description_html
g.db.add(group)
return {"message": 'Description changed successfully!'}

View File

@ -33,9 +33,9 @@
</div>
</div>
</form>
{% elif group.description %}
{% elif group.description_html %}
<h5 class="mt-5">!{{group}} Description</h3>
<p class="mb-2">{{group.description}}</p>
<p class="mb-2">{{group.description_html | safe}}</p>
{% endif %}
<br>

View File

@ -62,8 +62,8 @@
{% endif %}
</td>
<td>
{% if group.description %}
{{group.description}}
{% if group.description_html %}
{{group.description_html | safe}}
{% endif %}
</td>
<td data-time="{{group.created_utc}}"></td>

View File

@ -0,0 +1,2 @@
alter table groups add column description_html varchar(500);
update groups set description_html=description;