slugify to a max of 50 and remove date

This commit is contained in:
2026-05-30 09:18:42 +03:00
parent d87d9c2977
commit ae9d33473c
3 changed files with 6 additions and 5 deletions

View File

@@ -172,7 +172,7 @@ class Topics(Model):
name = name.strip()
description = description.strip()
now = int(time.time())
slug = f'{slugify(name)}-{now}'
slug = slugify(name, max_length=50)
topic_count = Topics.count()
return Topics.create({
@@ -287,7 +287,7 @@ class Threads(Model):
def new(cls, user_id: int, topic_id: int, title: str, content: str, language: str = 'babycode') -> Threads:
from slugify import slugify
now = int(time.time())
slug = f'{slugify(title)}-{now}'
slug = slugify(title, max_length=50)
thread = Threads.create({
'topic_id': topic_id,
'user_id': user_id,