Commit 53685739 authored by felix.herrmann's avatar felix.herrmann
Browse files

Merge branch '424-private-comments-shown-in-public' into 'master'

Resolve "Private comments shown in public"

Closes #424

See merge request !396
parents 5df33830 622cd9d0
......@@ -32,9 +32,7 @@ class Notification(MPTTModel):
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
notification_type = models.CharField(
max_length=4,
choices=NOTIFICATION_TYPE_CHOICES,
default=PUBLIC,
max_length=4, choices=NOTIFICATION_TYPE_CHOICES, default=PUBLIC,
)
text = BleachField(max_length=12000)
date_added = models.DateTimeField(auto_now_add=True)
......@@ -98,9 +96,7 @@ class Comment(MPTTModel):
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
doi = models.CharField(max_length=200, blank=True)
comment_type = models.CharField(
max_length=4,
choices=COMMENT_TYPE_CHOICES,
default=PUBLIC,
max_length=4, choices=COMMENT_TYPE_CHOICES, default=PUBLIC,
)
text = BleachField(max_length=12000)
date_added = models.DateTimeField(auto_now_add=True)
......@@ -133,6 +129,13 @@ class Comment(MPTTModel):
# self.date_added.strftime("%d.%m.%Y, %H:%M:%S"),
)
def is_public(self):
if (
self.comment_type == Comment.PUBLIC
or self.comment_type == Comment.PERMANENT
):
return True
def class_name(self):
return self.__class__.__name__
......
{% load static i18n activity_tags core_tags crispy_forms_tags mptt_tags humanize tz %}
<div class="row smallskip comment-card" id="comment-{{ comment.uuid }}">
<div class="col-md-10">
<div class="row">
<div class="col-md-1">
{% include 'ddusers/_user-image.html' with user_uuid=comment.owner.uuid user_photo=comment.owner.photo %}
<span class="badge badge-{{ comment.get_comment_type_display }}">{{ comment.get_comment_type_display }}</span>
</div>
<div class="col-md-11">
<span class="comment-name"> {{ comment.owner.get_academic_name }}</span> <span class="comment-naturaltime">{{ comment.date_added | naturaltime }}</span> {% if comment.deleted %}<span class="badge badge-deleted">{% trans "Deleted" %}</span>{% endif %}
{% with parent=comment|get_parent_comment %}
{% if comment.is_public or request.user == comment.owner or request.user == parent.owner %}
<div class="comment-text" id="comment-text-{{ comment.uuid }}">
{{ comment.text|linebreaks |urlize | safe }}
</div>
......@@ -46,6 +48,13 @@
{% endwith %}
</div>
</div>
{% else %}
<div class="comment-text" id="comment-text-{{ comment.uuid }}">
<p><i>{% trans "This comment is private." %}</i></p>
</div>
{% endif%}
{% endwith %}
{% comment %}
{% with prepared_form=comment|prepare_comment_form:request.user %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment