Skip to content

Commit

Permalink
wrote view
Browse files Browse the repository at this point in the history
git-svn-id: http://django-flag.googlecode.com/svn/trunk@13 6223c904-8705-11dd-a5c9-f1483cedc3eb
  • Loading branch information
jtauber committed Sep 20, 2008
1 parent 078c184 commit b7740b7
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions flag/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.contrib.auth.decorators import login_required, user_passes_test
from django.http import HttpResponseRedirect, Http404
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404

from flag.models import add_flag

@login_required
def flag(request):


form = form_class(request.POST)

content_type = request.POST.get("content_type")
object_id = request.POST.get("object_id")
creator_field = request.POST.get("creator_field")
comment = request.POST.get("comment")
next = request.POST.get("next")

content_type = get_object_or_404(ContentType, id = int(content_type))
object_id = int(object_id)

content_object = content_type.get_object_for_this_type(idobject_id)

if creator_field and hasattr(content_object, creator_field):
creator = getattr(content_object, creator_field)
else:
creator = None

add_flag(request.user, content_type, object_id, creator, comment)
request.user.message_set.create(message="You have added a flag. A moderator will review your submission shortly.")

if next:
return HttpResponseRedirect(next)
else:
return Http404

0 comments on commit b7740b7

Please sign in to comment.