Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to forbid viewing other's modification history. #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions spirit/comment/history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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

Expand All @@ -17,6 +19,12 @@ def detail(request, comment_id):
comment = get_object_or_404(Comment.objects.for_access(request.user),
pk=comment_id)

# not comment author and not moderator:
if request.user != comment.user and not request.user.st.is_moderator:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and ST_PRIVATE_COMMENT_HISTORY is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

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_CUSTOMIZE_ALLOW_OTHERS_VIEWING_MODIFICATION_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 user.st.is_moderator or st_settings.ST_CUSTOMIZE_ALLOW_OTHERS_VIEWING_MODIFICATION_HISTORY or c.user == user %}
<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_CUSTOMIZE_ALLOW_OTHERS_VIEWING_MODIFICATION_HISTORY = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called ST_PRIVATE_COMMENT_HISTORY