From: hernani Date: Mon, 19 Jul 2010 14:24:31 +0000 (+0000) Subject: Some more fixes in the subscribe button. X-Git-Tag: live~585 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/204b196b015876b87379c526b3f92e7e396464bd Some more fixes in the subscribe button. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@549 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/models/user.py b/forum/models/user.py index 7772bc9..36f0e90 100644 --- a/forum/models/user.py +++ b/forum/models/user.py @@ -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) diff --git a/forum/skins/default/templates/subscription_status.html b/forum/skins/default/templates/subscription_status.html index 46ad235..d97dccd 100644 --- a/forum/skins/default/templates/subscription_status.html +++ b/forum/skins/default/templates/subscription_status.html @@ -14,7 +14,7 @@

{% trans "You are not subscribed to this question." %}

{% endif %} -

+

{% if subscription %} {% trans "unsubscribe me" %} {% else %} diff --git a/forum/urls.py b/forum/urls.py index 9d3c4d6..107a01d 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -85,6 +85,7 @@ urlpatterns += patterns('', url(r'^%s(?P\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'), url(r'^%s(?P\d+)/' % _('delete/'), app.commands.delete_post, name='delete_post'), url(r'^%s(?P\d+)/(?P\d+)?/$' % _('subscribe/'), app.commands.subscribe, name="subscribe"), + url(r'^%s(?P\d+)/$' % _('subscribe/'), app.commands.subscribe, name="subscribe_simple"), url(r'^%s' % _('matching_tags/'), app.commands.matching_tags, name='matching_tags'), url(r'^%s(?P\d+)/' % _('node_markdown/'), app.commands.node_markdown, name='node_markdown'), url(r'^%s(?P\d+)/' % _('convert/'), app.commands.convert_to_comment, diff --git a/forum/views/commands.py b/forum/views/commands.py index e41c2e0..0436047 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -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