def post_policy(request): if not (request.user.has_perm('privacy.add_policy') and request.user.has_perm('privacy.add_comment')): return HttpResponseForbidden("not sufficient permissions") p = Policy.objects.create(text=request.POST['content']) c = Comment.objects.create(text=request.POST['comment'], policy=p, who=request.user) LogEntry.objects.log_action(request.user.id, Policy.contenttype().id, p.id, force_text(p), ADDITION) LogEntry.objects.log_action(request.user.id, Comment.contenttype().id, c.id, force_text(c), ADDITION) return redirect(reverse('privacy:show', kwargs={'id': p.id}))
def post_policy(request): if not (request.user.has_perm('privacy.add_policy') and request.user.has_perm('privacy.add_comment')): return HttpResponseForbidden("not sufficient permissions") p = Policy.objects.create(text=request.POST['content']) c = Comment.objects.create(text=request.POST['comment'], policy=p, who=request.user) LogEntry.objects.log_action(request.user.id, Policy.contenttype().id, p.id, force_unicode(p), ADDITION) LogEntry.objects.log_action(request.user.id, Comment.contenttype().id, c.id, force_unicode(c), ADDITION) return redirect(reverse('privacy.views.show_policy', kwargs={'id': p.id}))
def add_comment(request): """Add a comment to a policy, requires privacy.add_comment priviledges. """ if not request.user.has_perm('privacy.add_comment'): return HttpResponseForbidden("not sufficient permissions") if request.method == "POST": try: p = get_object_or_404(Policy, id=request.POST['policy']) except ValueError: raise Http404 c = Comment.objects.create(text=request.POST['comment'], policy=p, who=request.user) LogEntry.objects.log_action(request.user.id, Comment.contenttype().id, c.id, force_text(c), ADDITION) return redirect(reverse('privacy:versions'))
def add_comment(request): """Add a comment to a policy, requires privacy.add_comment priviledges. """ if not request.user.has_perm('privacy.add_comment'): return HttpResponseForbidden("not sufficient permissions") if request.method == "POST": try: p = get_object_or_404(Policy, id=request.POST['policy']) except ValueError: raise Http404 c = Comment.objects.create(text=request.POST['comment'], policy=p, who=request.user) LogEntry.objects.log_action(request.user.id, Comment.contenttype().id, c.id, force_unicode(c), ADDITION) return redirect(reverse('privacy.views.versions'))
def add_comment(request): """Add a comment to a policy, requires privacy.add_comment priviledges. """ if not request.user.has_perm('privacy.add_comment'): return HttpResponseRedirect(reverse('accounts.views.versions')) if request.method == "POST": try: p = Policy.objects.get(id = int(request.POST['policy'])) c = Comment.objects.create(text=request.POST['comment'], policy=p, who=request.user) LogEntry.objects.log_action(request.user.id, Comment.contenttype().id, c.id, force_unicode(c), ADDITION) except Exception, e: import pdb pdb.set_trace() pass