slugify to a max of 50 and remove date
This commit is contained in:
@@ -106,7 +106,7 @@ def edit_topic_post(topic_id):
|
||||
topic.update({
|
||||
'name': target_name,
|
||||
'description': request.form.get('description').strip(),
|
||||
'slug': slugify(target_name[:50]),
|
||||
'slug': slugify(target_name, max_length=50),
|
||||
})
|
||||
return redirect(url_for('topics.topic_by_id', topic_id=topic.id))
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ def thread(thread_id, slug):
|
||||
if not thread:
|
||||
abort(404)
|
||||
if thread.slug != slug:
|
||||
return redirect(url_for('.thread', thread_id=thread_id, slug=thread.slug, **request.kwargs))
|
||||
return redirect(url_for('.thread', thread_id=thread_id, slug=thread.slug, **request.args))
|
||||
|
||||
topic = Topics.find({'id': thread.topic_id})
|
||||
started_by = Users.find({'id': thread.user_id})
|
||||
@@ -115,7 +115,8 @@ def edit_post(thread_id):
|
||||
abort(400)
|
||||
|
||||
if new_title != thread.title:
|
||||
thread.update({'title': new_title})
|
||||
from slugify import slugify
|
||||
thread.update({'title': new_title, 'slug': slugify(new_title, max_length=50)})
|
||||
|
||||
return redirect(url_for('.thread_by_id', thread_id=thread_id))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user