Skip to content

Commit

Permalink
Tente de créer un raccourcis pour que les modo puissent supprimer les…
Browse files Browse the repository at this point in the history
… mauvais domaines
  • Loading branch information
artragis committed Oct 29, 2023
1 parent 0a733a7 commit 548154f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions templates/member/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,14 @@ <h3>{% trans 'Sanctions' %}</h3>
{% trans "Confirmer" %}
</button>
</form>
<!-- if the user was banned and he was the first for his mail provider, propose
quick access to ban provider -->
{% if profile.user | has_new_provider and can_ban_provider %}
<form method="post" action="{% url 'check-new-email-provider' user|get_new_provider_pk %}">
{% csrf_token %}
<button type="submit" name="ban" class="btn btn-grey ico-after red cross">{% trans "Bannir le fournisseur" %}</button>
</form>
{% endif %}
{% endif %}
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion zds/member/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions zds/utils/templatetags/interventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()

0 comments on commit 548154f

Please sign in to comment.