diff --git a/brainstorm/templates/brainstorm/idea.html b/brainstorm/templates/brainstorm/idea.html
index 3c74ea2..539e679 100644
--- a/brainstorm/templates/brainstorm/idea.html
+++ b/brainstorm/templates/brainstorm/idea.html
@@ -29,9 +29,24 @@
{% endfor %}
-{% get_comment_form for idea as comment_form %}
-
diff --git a/brainstorm/urls.py b/brainstorm/urls.py
index 67953a9..c69a11a 100644
--- a/brainstorm/urls.py
+++ b/brainstorm/urls.py
@@ -14,6 +14,7 @@ urlpatterns = patterns('',
)
urlpatterns += patterns('brainstorm.views',
+ url(r'^submit_comment/$', 'submit_comment', name='submit_idea_comment'),
url(r'^(?P[\w-]+)/$', 'idea_list', {'ordering': 'most_popular'}, name='subsite'),
url(r'^(?P[\w-]+)/latest/$', 'idea_list', {'ordering': 'latest'}, name='subsite_latest'),
url(r'^(?P[\w-]+)/(?P\d+)/$', 'idea_detail', name='idea'),
diff --git a/brainstorm/views.py b/brainstorm/views.py
index bd9f925..f2197c4 100644
--- a/brainstorm/views.py
+++ b/brainstorm/views.py
@@ -1,7 +1,11 @@
+import datetime
from django.template import RequestContext
from django.core.paginator import Paginator, InvalidPage, EmptyPage
+from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect
+from django.contrib.comments.models import Comment
+from django.contrib.contenttypes.models import ContentType
from django.views.decorators.http import require_POST
from brainstorm.models import Subsite, Idea
@@ -36,7 +40,6 @@ def idea_detail(request, slug, id):
{'subsite':subsite, 'idea': idea},
context_instance=RequestContext(request))
-
@require_POST
def new_idea(request, slug):
subsite = get_object_or_404(Subsite, pk=slug)
@@ -50,3 +53,22 @@ def new_idea(request, slug):
idea = Idea.objects.create(title=title, description=description,
user=user, subsite=subsite)
return HttpResponseRedirect(idea.get_absolute_url())
+
+@require_POST
+def submit_comment(request):
+ from django.conf import settings
+ content_type = ContentType.objects.get_for_model(Idea).id
+ site = settings.SITE_ID
+ object_pk = request.POST['idea_id']
+ name = request.POST.get('name', 'anonymous')
+ email = request.POST.get('email', '')
+ url = request.POST.get('url', '')
+ comment = request.POST['comment']
+ date = datetime.datetime.now()
+ ip = request.META['REMOTE_ADDR']
+ c = Comment.objects.create(user_name=name, user_email=email, user_url=url,
+ comment=comment, submit_date=date, ip_address=ip,
+ site_id=site, content_type_id=content_type, object_pk=object_pk)
+ idea = Idea.objects.get(pk=object_pk)
+ linkback = '%s#c%s' % (idea.get_absolute_url(), c.id)
+ return HttpResponseRedirect(linkback)