示例#1
0
文件: tests.py 项目: magatz/pybbm-1
    def test_topic_delete_form(self):
        form = TopicDeleteForm(topic=self.topic, data={
            'topic': self.topic.pk,
            'confirm': True
        })

        self.assertTrue(form.is_valid())

        form.save()

        self.assertTrue(self.topic.deleted)
示例#2
0
    def test_topic_delete_form(self):
        form = TopicDeleteForm(topic=self.topic,
                               data={
                                   'topic': self.topic.pk,
                                   'confirm': True
                               })

        self.assertTrue(form.is_valid())

        form.save()

        self.assertTrue(self.topic.deleted)
示例#3
0
文件: views.py 项目: s1n4/pybb
def topic_delete(request, pk):
    topic = get_object_or_404(Topic, pk=pk)
    if not request.user.is_superuser:
        messages.error(request, _("You're not allowed to delete topic"))
        return reverse('pybb:home_page')
    if request.method == 'POST':
        form = TopicDeleteForm(request.POST)
    else:
        form = TopicDeleteForm()
    if form.is_valid():
        topic.delete()
        messages.success(request, _('Topic deleted'))
        return redirect('pybb:home_page')
    context = {'topic': topic, 'form': form,
            }
    return render(request, 'pybb/topic_delete.html', context)
示例#4
0
def topic_delete(request, pk):
    topic = get_object_or_404(Topic, pk=pk)
    if not request.user.is_superuser:
        messages.error(request, u'У вас нет права на удаление темы')
        return reverse('pybb:home_page')
    if request.method == 'POST':
        form = TopicDeleteForm(request.POST)
    else:
        form = TopicDeleteForm()
    if form.is_valid():
        topic.delete()
        messages.success(request, u'Тема удалена')
        return redirect('pybb:home_page')
    context = {'topic': topic, 'form': form,
            }
    return render(request, 'pybb/topic_delete.html', context)
示例#5
0
def topic_delete(request, pk):
    topic = get_object_or_404(Topic, pk=pk)
    if not request.user.is_superuser:
        messages.error(request, u'У вас нет права на удаление темы')
        return reverse('pybb:home_page')
    if request.method == 'POST':
        form = TopicDeleteForm(request.POST)
    else:
        form = TopicDeleteForm()
    if form.is_valid():
        topic.delete()
        messages.success(request, u'Тема удалена')
        return redirect('pybb:home_page')
    context = {
        'topic': topic,
        'form': form,
    }
    return render(request, 'pybb/topic_delete.html', context)