Ejemplo n.º 1
0
 def test_post_options(self):
     post = Post.objects.create(
         author=self.user,
         title='okok',
         text='eeee',
     )
     form = PostOptions({
         'disable_rate': True,
         'disable_reply': False,
         'pinch': True,
     }, instance=post)
     self.assertTrue(form.is_valid(), msg='options validating')
     post = form.save()
     self.assertTrue(post.disable_rate, msg='test options')
Ejemplo n.º 2
0
def post_options(request, post_id, disable_rate, disable_reply, pinch):
    """Change post options"""
    post = get_object_or_404(Post, id=post_id)
    form = PostOptions({
        'disable_rate': disable_rate,
        'disable_reply': disable_reply,
        'pinch': pinch,
    }, instance=post)
    if form.is_valid():
        post = form.save()
        return to_json(post)
    else:
        return {
            'error': form.errors,
        }
Ejemplo n.º 3
0
 def test_post_options(self):
     post = Post.objects.create(
         author=self.user,
         title='okok',
         text='eeee',
     )
     form = PostOptions(
         {
             'disable_rate': True,
             'disable_reply': False,
             'pinch': True,
         },
         instance=post)
     self.assertTrue(form.is_valid(), msg='options validating')
     post = form.save()
     self.assertTrue(post.disable_rate, msg='test options')