[extensions-web] Posting comments now redirects you to the extension's page



commit 835b9fb6bc5942cf26e76bf597934a56cbc6f260
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Dec 14 17:05:02 2011 -0500

    Posting comments now redirects you to the extension's page

 sweettooth/extensions/models.py |    5 +++++
 sweettooth/ratings/urls.py      |    7 +++++++
 sweettooth/ratings/views.py     |   10 ++++++++++
 sweettooth/urls.py              |    1 +
 4 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index e46142c..66422fe 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -7,6 +7,7 @@ except ImportError:
 import uuid
 from zipfile import ZipFile, BadZipfile
 
+from django.core.urlresolvers import reverse
 from django.contrib.auth.models import User
 from django.db import models
 from django.dispatch import Signal
@@ -134,6 +135,10 @@ class Extension(models.Model):
     def visible_shell_version_map_json(self):
         return json.dumps(self.visible_shell_version_map)
 
+    def get_absolute_url(self):
+        return reverse('extensions-detail', kwargs=dict(pk=self.pk,
+                                                        slug=self.slug))
+
 class InvalidShellVersion(Exception):
     pass
 
diff --git a/sweettooth/ratings/urls.py b/sweettooth/ratings/urls.py
new file mode 100644
index 0000000..06b83e4
--- /dev/null
+++ b/sweettooth/ratings/urls.py
@@ -0,0 +1,7 @@
+
+from django.conf.urls.defaults import patterns, include, url
+from ratings import views
+
+urlpatterns = patterns('',
+    url(r'^posted/$', views.comment_done, name='comments-comment-done'),
+)
diff --git a/sweettooth/ratings/views.py b/sweettooth/ratings/views.py
new file mode 100644
index 0000000..2a910dc
--- /dev/null
+++ b/sweettooth/ratings/views.py
@@ -0,0 +1,10 @@
+
+from django.contrib import comments
+from django.contrib.messages import info
+from django.shortcuts import redirect
+
+def comment_done(request):
+    pk = request.GET['c']
+    comment = comments.get_model().objects.get(pk=pk)
+    info(request, "Thank you for your comment")
+    return redirect(comment.get_content_object_url())
diff --git a/sweettooth/urls.py b/sweettooth/urls.py
index 1f71946..9825226 100644
--- a/sweettooth/urls.py
+++ b/sweettooth/urls.py
@@ -17,6 +17,7 @@ urlpatterns = patterns('',
     url(r'^errors/', include('errorreports.urls')),
 
     url(r'^admin/', include(admin.site.urls)),
+    url(r'^comments/', include('ratings.urls')),
     url(r'^comments/', include('django.contrib.comments.urls')),
 
 )



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]