def POST(self, request, post_id): post = get_object_or_404(Post, pk=post_id) thanks = get_object_or_404(Thanks, post=post, thanker=request.user) thanks.delete() if request.is_ajax(): return utils.render_mixed_mode( request, (('thanksBlock', 'thanks_block.html', {'post': post}), ('postControls', 'post_controls.html', {'post': post})), additional={'status': 'SUCCESS'}) return HttpResponseRedirect(post.get_url())
def POST(self, request): form = forms.RenderBBCodeForm(request.POST) if form.is_valid(): ctx = {'content': request.POST['content']} return utils.render_mixed_mode( request, (('postPreview', 'post_preview_block.html', ctx), ), additional={'status': 'SUCCESS'}) else: return JsonResponse({ 'status': 'INVALID_FORM', 'errors': form.errors })
def POST(self, request, post_id): min_posts = utils.get_config('initial_account_period_total') if request.user.post_set.count() < min_posts: raise PermissionDenied('Not enough posts to thank.') post = get_object_or_404(Post, pk=post_id) thanks = Thanks(post=post, thanker=request.user, thankee=post.author) try: thanks.save() except IntegrityError: pass if request.is_ajax(): return utils.render_mixed_mode( request, (('thanksBlock', 'thanks_block.html', {'post': post}), ('postControls', 'post_controls.html', {'post': post})), additional={'status': 'SUCCESS'}) else: return HttpResponseRedirect(post.get_url())