def test_post_update(self): """ lets update it """ res = self.c.put('/post/edit/{0}'.format(self.post_id), {'title': 'Sample Title Updated', 'synopsis': 'The Synopsis Updated', 'content': 'The Content Updated'}) self.assertEqual(Post.get(self.post_id).title, 'Sample Title Updated')
def put(self, request, id, **kwargs): coerce_put_post(request) post = Post.get(id) if post: post.title = request.PUT.get('title', '') post.synopsis = request.PUT.get('synopsis', '') post.content = request.PUT.get('content', '') post.put() return HttpResponse(json.dumps({'status': 'OK', 'message': 'Post Updated'})) return HttpResponse(json.dumps({'status': 'Error', 'message': 'Post not foud'}))
def get_context_data(self, id, **kwargs): context = super(PostView, self).get_context_data(**kwargs) context['post'] = Post.get(id) context['comments'] = Post.get_all_comments(id) return context