本文整理汇总了Python中misago.threads.models.Thread.is_read方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.is_read方法的具体用法?Python Thread.is_read怎么用?Python Thread.is_read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misago.threads.models.Thread
的用法示例。
在下文中一共展示了Thread.is_read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: merge_threads
# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import is_read [as 别名]
def merge_threads(request, validated_data, threads, poll):
new_thread = Thread(
category=validated_data['category'],
started_on=threads[0].started_on,
last_post_on=threads[0].last_post_on,
)
new_thread.set_title(validated_data['title'])
new_thread.save()
if poll:
poll.move(new_thread)
categories = []
for thread in threads:
categories.append(thread.category)
new_thread.merge(thread)
thread.delete()
record_event(
request,
new_thread,
'merged',
{
'merged_thread': thread.title,
},
commit=False,
)
new_thread.synchronize()
new_thread.save()
if validated_data.get('weight') == Thread.WEIGHT_GLOBAL:
moderation.pin_thread_globally(request, new_thread)
elif validated_data.get('weight'):
moderation.pin_thread_locally(request, new_thread)
if validated_data.get('is_hidden', False):
moderation.hide_thread(request, new_thread)
if validated_data.get('is_closed', False):
moderation.close_thread(request, new_thread)
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_acl(request.user, new_thread)
return new_thread
示例2: merge_threads
# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import is_read [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