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')
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, }
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')