本文整理汇总了Python中misago.threads.models.Thread.top_category方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.top_category方法的具体用法?Python Thread.top_category怎么用?Python Thread.top_category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misago.threads.models.Thread
的用法示例。
在下文中一共展示了Thread.top_category方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: merge_threads
# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import top_category [as 别名]
def merge_threads(user, validated_data, threads):
new_thread = Thread(
category=validated_data['category'],
weight=validated_data.get('weight', 0),
is_closed=validated_data.get('is_closed', False),
started_on=threads[0].started_on,
last_post_on=threads[0].last_post_on,
)
new_thread.set_title(validated_data['title'])
new_thread.save()
categories = []
for thread in threads:
categories.append(thread.category)
new_thread.merge(thread)
thread.delete()
new_thread.synchronize()
new_thread.save()
if new_thread.category not in categories:
categories.append(new_thread.category)
for category in categories:
category.synchronize()
category.save()
# set extra attrs on thread for UI
new_thread.is_read = False
new_thread.subscription = None
# add top category to thread
if validated_data.get('top_category'):
categories = list(Category.objects.all_categories().filter(
id__in=user.acl['visible_categories']
))
add_categories_to_threads(
validated_data['top_category'], categories, [new_thread])
else:
new_thread.top_category = None
new_thread.save()
add_acl(user, new_thread)
return new_thread