Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

wrote view

git-svn-id: http://django-flag.googlecode.com/svn/trunk@13 6223c904-8705-11dd-a5c9-f1483cedc3eb
  • Loading branch information...
commit b7740b77600ea5fef50544ff9489cef564f02e87 1 parent 078c184
@jtauber jtauber authored
Showing with 31 additions and 3 deletions.
  1. +31 −3 flag/views.py
View
34 flag/views.py
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.