]> git.openstreetmap.org Git - osqa.git/commitdiff
Some more fixes in the subscribe button.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 19 Jul 2010 14:24:31 +0000 (14:24 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 19 Jul 2010 14:24:31 +0000 (14:24 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@549 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/user.py
forum/skins/default/templates/subscription_status.html
forum/urls.py
forum/views/commands.py

index 7772bc9fc630e695f7209406f9f2b1b1e0b4c672..36f0e905d4e1357a9a02bb9d86d5345d56fc2a06 100644 (file)
@@ -85,6 +85,9 @@ class AnonymousUser(DjangoAnonymousUser):
     def can_upload_files(self):
         return False
 
+    def is_a_super_user_or_staff(self):
+        return False
+
 def true_if_is_super_or_staff(fn):
     def decorated(self, *args, **kwargs):
         return self.is_superuser or self.is_staff or fn(self, *args, **kwargs)
index 46ad235beaeb75728646588cb392afaf18c3781f..d97dccd4e361c97b2426c442846b8e04376e011c 100644 (file)
@@ -14,7 +14,7 @@
             <p>{% trans "You are not subscribed to this question." %}</p>\r
         {% endif %}\r
     </div>\r
-    <p><a class="ajax-command sidebar_button subscription_switch" href="{% url subscribe id=question.id %}">\r
+    <p><a class="ajax-command sidebar_button subscription_switch" href="{% url subscribe_simple id=question.id %}">\r
         {% if subscription %}\r
             {% trans "unsubscribe me" %}\r
         {% else %}\r
index 9d3c4d68f1a59f7750fce621c50dd6ebe7435fb9..107a01d1d5e546bca7e9d24b09c53270a3823aca 100644 (file)
@@ -85,6 +85,7 @@ urlpatterns += patterns('',
                         url(r'^%s(?P<id>\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'),
                         url(r'^%s(?P<id>\d+)/' % _('delete/'), app.commands.delete_post, name='delete_post'),
                         url(r'^%s(?P<id>\d+)/(?P<user>\d+)?/$' % _('subscribe/'), app.commands.subscribe, name="subscribe"),
+                        url(r'^%s(?P<id>\d+)/$' % _('subscribe/'), app.commands.subscribe, name="subscribe_simple"),
                         url(r'^%s' % _('matching_tags/'), app.commands.matching_tags, name='matching_tags'),
                         url(r'^%s(?P<id>\d+)/' % _('node_markdown/'), app.commands.node_markdown, name='node_markdown'),
                         url(r'^%s(?P<id>\d+)/' % _('convert/'), app.commands.convert_to_comment,
index e41c2e06ec431776490fc0bf1f650c3fefab00ec..04360475ffb7dad550c1d4e012a073857aed40f5 100644 (file)
@@ -436,12 +436,15 @@ def convert_to_comment(request, id):
     return RefreshPageCommand()
 
 @decorate.withfn(command)
-def subscribe(request, id, user=0):    
+def subscribe(request, id, user=None):
     if user:
-        user = User.objects.filter(id=user)[0]
-        if not (user.is_a_super_user_or_staff() or user.is_authenticated()):
-            raise CommandException(_("You do not have the correct credentials to preform this action."))
+        try:
+            user = User.objects.get(id=user)
+        except User.DoesNotExist:
+            raise Http404()
 
+        if not (request.user.is_a_super_user_or_staff() or user.is_authenticated()):
+            raise CommandException(_("You do not have the correct credentials to preform this action."))
     else:
         user = request.user