本文整理汇总了Python中misago.threads.models.Thread.last_poster_name方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.last_poster_name方法的具体用法?Python Thread.last_poster_name怎么用?Python Thread.last_poster_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misago.threads.models.Thread
的用法示例。
在下文中一共展示了Thread.last_poster_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: action_merge
# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import last_poster_name [as 别名]
def action_merge(self, request, threads):
if len(threads) == 1:
message = _("You have to select at least two threads to merge.")
raise moderation.ModerationError(message)
form = MergeThreadsForm()
if 'submit' in request.POST:
form = MergeThreadsForm(request.POST)
if form.is_valid():
with atomic():
merged_thread = Thread()
merged_thread.forum = self.forum
merged_thread.set_title(
form.cleaned_data['merged_thread_title'])
merged_thread.starter_name = "-"
merged_thread.starter_slug = "-"
merged_thread.last_poster_name = "-"
merged_thread.last_poster_slug = "-"
merged_thread.started_on = timezone.now()
merged_thread.last_post_on = timezone.now()
merged_thread.is_pinned = max(t.is_pinned for t in threads)
merged_thread.is_closed = max(t.is_closed for t in threads)
merged_thread.save()
for thread in threads:
moderation.merge_thread(
request.user, merged_thread, thread)
merged_thread.synchronize()
merged_thread.save()
self.forum.lock()
self.forum.synchronize()
self.forum.save()
changed_threads = len(threads)
message = ungettext(
'%(changed)d thread was merged into "%(thread)s".',
'%(changed)d threads were merged into "%(thread)s".',
changed_threads)
messages.success(request, message % {
'changed': changed_threads,
'thread': merged_thread.title
})
return None # trigger threads list refresh
if request.is_ajax():
template = self.merge_threads_modal_template
else:
template = self.merge_threads_full_template
return render(request, template, {
'form': form,
'forum': self.forum,
'path': get_forum_path(self.forum),
'threads': threads
})
示例2: post_action_split
# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import last_poster_name [as 别名]
def post_action_split(self, ids):
for id in ids:
if id == self.thread.start_post_id:
raise forms.ValidationError(_("You cannot split first post from thread."))
message = None
if self.request.POST.get('do') == 'split':
form = SplitThreadForm(self.request.POST, request=self.request)
if form.is_valid():
new_thread = Thread()
new_thread.forum = form.cleaned_data['thread_forum']
new_thread.name = form.cleaned_data['thread_name']
new_thread.slug = slugify(form.cleaned_data['thread_name'])
new_thread.start = timezone.now()
new_thread.last = timezone.now()
new_thread.start_poster_name = 'n'
new_thread.start_poster_slug = 'n'
new_thread.last_poster_name = 'n'
new_thread.last_poster_slug = 'n'
new_thread.save(force_insert=True)
prev_merge = -1
merge = -1
for post in self.posts:
if post.pk in ids:
if prev_merge != post.merge:
prev_merge = post.merge
merge += 1
post.merge = merge
post.move_to(new_thread)
post.save(force_update=True)
new_thread.sync()
new_thread.save(force_update=True)
self.thread.sync()
self.thread.save(force_update=True)
self.forum.sync()
self.forum.save(force_update=True)
if new_thread.forum != self.forum:
new_thread.forum.sync()
new_thread.forum.save(force_update=True)
self.request.messages.set_flash(Message(_("Selected posts have been split to new thread.")), 'success', 'threads')
return redirect(reverse('thread', kwargs={'thread': new_thread.pk, 'slug': new_thread.slug}))
message = Message(form.non_field_errors()[0], 'error')
else:
form = SplitThreadForm(request=self.request, initial={
'thread_name': _('[Split] %s') % self.thread.name,
'thread_forum': self.forum,
})
return self.request.theme.render_to_response('threads/split.html',
{
'message': message,
'forum': self.forum,
'parents': self.parents,
'thread': self.thread,
'posts': ids,
'form': FormLayout(form),
},
context_instance=RequestContext(self.request));
示例3: action_split
# 需要导入模块: from misago.threads.models import Thread [as 别名]
# 或者: from misago.threads.models.Thread import last_poster_name [as 别名]
def action_split(self, request, posts):
if posts[0].id == self.thread.first_post_id:
message = _("You can't split thread's first post.")
raise moderation.ModerationError(message)
form = SplitThreadForm(acl=request.user.acl)
if 'submit' in request.POST or 'follow' in request.POST:
form = SplitThreadForm(request.POST, acl=request.user.acl)
if form.is_valid():
split_thread = Thread()
split_thread.forum = form.cleaned_data['forum']
split_thread.set_title(
form.cleaned_data['thread_title'])
split_thread.starter_name = "-"
split_thread.starter_slug = "-"
split_thread.last_poster_name = "-"
split_thread.last_poster_slug = "-"
split_thread.started_on = timezone.now()
split_thread.last_post_on = timezone.now()
split_thread.save()
for post in posts:
post.move(split_thread)
post.save()
split_thread.synchronize()
split_thread.save()
if split_thread.forum != self.forum:
split_thread.forum.lock()
split_thread.forum.synchronize()
split_thread.forum.save()
changed_posts = len(posts)
message = ungettext(
'%(changed)d post was split to "%(thread)s".',
'%(changed)d posts were split to "%(thread)s".',
changed_posts)
messages.success(request, message % {
'changed': changed_posts,
'thread': split_thread.title
})
if 'follow' in request.POST:
return redirect(split_thread.get_absolute_url())
else:
return None # trigger thread refresh
if request.is_ajax():
template = self.split_thread_modal_template
else:
template = self.split_thread_full_template
return render(request, template, {
'form': form,
'forum': self.forum,
'thread': self.thread,
'path': get_forum_path(self.forum),
'posts': posts
})