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
{% 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>
+
,
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,
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