From 548154fdc3ceb823dc6711d363d0df3b204bf381 Mon Sep 17 00:00:00 2001 From: artragis Date: Sun, 29 Oct 2023 20:33:46 +0100 Subject: [PATCH] =?UTF-8?q?Tente=20de=20cr=C3=A9er=20un=20raccourcis=20pou?= =?UTF-8?q?r=20que=20les=20modo=20puissent=20supprimer=20les=20mauvais=20d?= =?UTF-8?q?omaines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/member/profile.html | 8 ++++++++ zds/member/views/profile.py | 2 +- zds/utils/templatetags/interventions.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/templates/member/profile.html b/templates/member/profile.html index ca4d983dd7..9cd8c355fe 100644 --- a/templates/member/profile.html +++ b/templates/member/profile.html @@ -856,6 +856,14 @@

{% trans 'Sanctions' %}

{% trans "Confirmer" %} + + {% if profile.user | has_new_provider and can_ban_provider %} +
+ {% csrf_token %} + +
+ {% endif %} {% endif %} {% endif %} diff --git a/zds/member/views/profile.py b/zds/member/views/profile.py index 16b0a83aaf..2005b9fd7f 100644 --- a/zds/member/views/profile.py +++ b/zds/member/views/profile.py @@ -198,7 +198,7 @@ def get_context_data(self, **kwargs): context["karmaform"] = KarmaForm(profile) context["alerts"] = profile.alerts_on_this_profile.all().order_by("-pubdate") context["has_unsolved_alerts"] = profile.alerts_on_this_profile.filter(solved=False).exists() - + context["can_ban_provider"] = self.request.user.has_perm("user.change_bannedemailprovider") context["summaries"] = self.get_summaries(profile, hide_forum_activity) return context diff --git a/zds/utils/templatetags/interventions.py b/zds/utils/templatetags/interventions.py index 789e5c1a1b..0bdb76f57b 100644 --- a/zds/utils/templatetags/interventions.py +++ b/zds/utils/templatetags/interventions.py @@ -2,6 +2,7 @@ from django import template from django.conf import settings +from django.contrib.auth.models import User from django.utils.translation import gettext_lazy as _ from django.db.models import F @@ -153,6 +154,16 @@ def new_providers_count(user): return NewEmailProvider.objects.count() +@register.filter(name="has_new_provider") +def has_new_provider(user: User): + return NewEmailProvider.objects.where(user=user).exists() + + +@register.filter(name="get_new_provider_pk") +def get_new_provider_pk(user: User): + return NewEmailProvider.objects.where(user=user).get().pk + + @register.filter(name="requested_hats_count") def requested_hats_count(user): return HatRequest.objects.filter(is_granted__isnull=True).count()