Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spirit/comment/history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
from __future__ import unicode_literals

from django.contrib.auth.decorators import login_required
from django.http import Http404
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext as _

from djconfig import config

from ...core.conf import settings
from ...core.utils.paginator import yt_paginate
from .models import CommentHistory
from ..models import Comment
Expand All @@ -17,6 +20,14 @@ def detail(request, comment_id):
comment = get_object_or_404(Comment.objects.for_access(request.user),
pk=comment_id)

# Block if private is set and not comment author and not moderator:
if (settings.ST_PRIVATE_COMMENT_HISTORY and
request.user != comment.user and
not request.user.st.is_moderator):
raise Http404(
_("You have no right to view other's modification history.")
)

comments = CommentHistory.objects\
.filter(comment_fk=comment)\
.select_related('comment_fk__user__st')\
Expand Down
4 changes: 3 additions & 1 deletion spirit/comment/templates/spirit/comment/_render_list.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load spirit_tags i18n %}

<div class="comments">

{% load_settings "ST_PRIVATE_COMMENT_HISTORY" %}
{% for c in comments %}

<div class="comment{% if c.action %} is-highlighted{% endif %}" id="c{{forloop.counter0|add:comments.start_index }}" data-number="{{ forloop.counter0|add:comments.start_index }}" data-pk="{{ c.pk }}">
Expand All @@ -22,7 +22,9 @@

<ul class="comment-date">
{% if c.modified_count > 0 %}
{% if not st_settings.ST_PRIVATE_COMMENT_HISTORY or c.user == user or user.st.is_moderator %}
<li><a href="{% url "spirit:comment:history:detail" comment_id=c.pk %}"><i class="fa fa-pencil"></i> {{ c.modified_count }}</a></li>
{% endif %}
{% endif %}

<li title="{{ c.date }}">{{ c.date|shortnaturaltime }}</li>
Expand Down
2 changes: 2 additions & 0 deletions spirit/core/conf/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@
os.path.dirname(
os.path.dirname(
os.path.dirname(__file__))))

ST_PRIVATE_COMMENT_HISTORY = True