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

Fix #2275 : uniformisation du nombre de messages d'un membre (forum) #2285

Merged
merged 1 commit into from
Feb 25, 2015
Merged
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: 9 additions & 2 deletions templates/member/profile.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "member/base.html" %}

{% load emarkdown %}
{% load email_obfuscator %}
{% load date %}
Expand Down Expand Up @@ -397,7 +398,7 @@ <h4>Articles</h4>
{% endif %}
{% endwith %}

{% if profile.get_post_count > 0 %}
{% if perms.member.change_post and profile.get_post_count_as_staff > 0 or profile.get_post_count > 0 %}
<h4>{% trans "Forums" %}</h4>
<ul>
<li>
Expand All @@ -409,7 +410,13 @@ <h4>{% trans "Forums" %}</h4>
<li>
<a href="{% url "zds.forum.views.find_post" usr.pk %}">
{% trans "Messages postés" %}
<span class="count">{{ profile.get_post_count }}</span>
<span class="count">
{% if perms.member.change_post %}
{{ profile.get_post_count_as_staff }}
{% else %}
{{ profile.get_post_count }}
{% endif %}
</span>
</a>
</li>
</ul>
Expand Down
4 changes: 4 additions & 0 deletions zds/member/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def get_avatar_url(self):

def get_post_count(self):
"""Number of messages posted."""
return Post.objects.filter(author__pk=self.user.pk, is_visible=True).count()

def get_post_count_as_staff(self):
"""Number of messages posted (view as staff)."""
return Post.objects.filter(author__pk=self.user.pk).count()

def get_topic_count(self):
Expand Down