-
Notifications
You must be signed in to change notification settings - Fork 165
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
Création d'un historique de sanctions pour le staff #4177
Changes from 3 commits
ea1bf8a
a5681ae
fbc31e4
ca01fdd
e39fe7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{% extends "member/base.html" %} | ||
{% load i18n %} | ||
{% load date %} | ||
|
||
|
||
{% block title %} | ||
{% trans "Historique des sanctions de" %} {{ usr.username }} | ||
{% endblock %} | ||
|
||
|
||
|
||
{% block breadcrumb %} | ||
<li><a href="{% url "member-detail" usr.username %}">{{ usr.username }}</a></li> | ||
<li>{% trans "Historique des sanctions" %}</li> | ||
{% endblock %} | ||
|
||
|
||
|
||
{% block headline %} | ||
{% trans "Historique des sanctions de" %} {{ usr.username }} | ||
{% endblock %} | ||
|
||
|
||
|
||
{% block content %} | ||
{% if sanctions %} | ||
<table class="fullwidth"> | ||
<thead> | ||
<th>{% trans "Type" %}</th> | ||
<th>{% trans "Explication" %}</th> | ||
<th class="wide">{% trans "Modérateur" %}</th> | ||
<th class="wide">{% trans "Date" %}</th> | ||
</thead> | ||
<tbody> | ||
{% for sanction in sanctions %} | ||
<tr> | ||
<td>{{ sanction.type }}</td> | ||
<td> | ||
{% if sanction.note %} | ||
{{ sanction.note }} | ||
{% else %} | ||
– | ||
{% endif %} | ||
</td> | ||
<td class="wide"><a href="{% url "member-detail" sanction.moderator.username %}">{{ sanction.moderator.username }}</a></td> | ||
<td class="wide">{{ sanction.pubdate|format_date|capfirst }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<p>{{ usr.username }} {% trans "n'a jamais été sanctionné." %}</p> | ||
{% endif %} | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -496,6 +496,23 @@ def modify_profile(request, user_pk): | |
return redirect(profile.get_absolute_url()) | ||
|
||
|
||
@login_required | ||
def sanctions_history(request, user_pk): | ||
"""Display the history of a member sanctions""" | ||
|
||
if not request.user.has_perm('member.change_profile'): | ||
raise PermissionDenied | ||
|
||
user = get_object_or_404(User, pk=user_pk) | ||
|
||
sanctions = Ban.objects.filter(user=user).order_by('-pubdate').select_related('moderator') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pour une raison qui m'échappe, c'est plus performant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je suis un peu étonné pour le coup vu que Je trouve que There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ce que je croyais aussi, jusqu'à ce que @vhf démontre le contraire : #4096 (comment) |
||
|
||
return render(request, 'member/sanctions_history.html', { | ||
'usr': user, | ||
'sanctions': sanctions, | ||
}) | ||
|
||
|
||
@login_required | ||
def tutorials(request): | ||
"""Returns all tutorials of the authenticated user.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu peux même aller plus loin et utiliser
result.context['sanctions']
pour vérifier ce que la liste de sanctions contient effectivement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonne idée :)