]> git.openstreetmap.org Git - osqa.git/commitdiff
now superusers and staff can unsubscribe users subscription.
authorqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 16 Jul 2010 23:05:44 +0000 (23:05 +0000)
committerqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 16 Jul 2010 23:05:44 +0000 (23:05 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@546 0cfe37f9-358a-4d5e-be75-b63607b5c754

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

index cabaabbd156947e6456c3b82f999aa4d5920c18f..7772bc9fc630e695f7209406f9f2b1b1e0b4c672 100644 (file)
@@ -321,6 +321,10 @@ class User(BaseModel, DjangoUser):
     def can_upload_files(self):
         return self.reputation >= int(settings.REP_TO_UPLOAD)
 
+    @true_if_is_super_or_staff
+    def is_a_super_user_or_staff(self):
+        return False
+
     def email_valid_and_can_ask(self):
         return 'ask' not in settings.REQUIRE_EMAIL_VALIDATION_TO or self.email_isvalid
 
index 2087392db4052f44d3cdeaec74bc2d09203cff09..3f1f688f9870235648c65ecffdbbe769fc5c9d6c 100644 (file)
@@ -1,9 +1,10 @@
 {% load i18n humanize extra_filters extra_tags user_tags %}
 <div class="subscription_summary">
-    <div style="height:100%"><a class="sidebar_button subscription_unsubscribe_button" href="{% url subscribe id=subscription.question.id %}">
+    <div style="height:100%"><a class="sidebar_button subscription_unsubscribe_button" href="{% url subscribe id=subscription.question.id user=subscription.user.id %}">
         {% trans "Unsubscribe" %}
     </a></div>
 
     <div class="subscription_title"><a title="{{ question.summary }}" href="{{ question.get_absolute_url }}">{{question.headline}}</a></div>
     <div class="subscription_details"><span class="relativetime" title="{{subscription.last_view}}">{% trans "Last checked" %} {% diff_date subscription.last_view %}</span></div>
-</div>
\ No newline at end of file
+</div>
+
index 5cb6594d859024e0c3493c8bced8a4788b059562..9d3c4d68f1a59f7750fce621c50dd6ebe7435fb9 100644 (file)
@@ -84,7 +84,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+)/$' % _('subscribe/'), app.commands.subscribe, name="subscribe"),
+                        url(r'^%s(?P<id>\d+)/(?P<user>\d+)?/$' % _('subscribe/'), app.commands.subscribe, name="subscribe"),
                         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 956463ae03098fcba0706f7967c910fdb143e94d..74bbe5ad043f841cabb5578e0bf37830cb46da42 100644 (file)
@@ -436,23 +436,31 @@ def convert_to_comment(request, id):
     return RefreshPageCommand()
 
 @decorate.withfn(command)
-def subscribe(request, id):
+def subscribe(request, id, user=0):    
+    if user:
+        user = User.objects.filter(id=user)[0]
+        if user.is_a_super_user_or_staff():
+            raise CommandException(_("You do not have the correct credentials to preform this action."))
+
+    else:
+        user = request.user
+
     question = get_object_or_404(Question, id=id)
 
     try:
-        subscription = QuestionSubscription.objects.get(question=question, user=request.user)
+        subscription = QuestionSubscription.objects.get(question=question, user=user)
         subscription.delete()
         subscribed = False
     except:
-        subscription = QuestionSubscription(question=question, user=request.user, auto_subscription=False)
+        subscription = QuestionSubscription(question=question, user=user, auto_subscription=False)
         subscription.save()
         subscribed = True
 
     return {
-    'commands': {
-    'set_subscription_button': [subscribed and _('unsubscribe me') or _('subscribe me')],
-    'set_subscription_status': ['']
-    }
+        'commands': {
+            'set_subscription_button': [subscribed and _('unsubscribe me') or _('subscribe me')],
+            'set_subscription_status': ['']
+        }
     }
 
 #internally grouped views - used by the tagging system