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

Tente de créer un raccourcis pour que les modo puissent supprimer les mauvais domaines #6552

Merged
merged 10 commits into from
Oct 17, 2024
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 %}
philippemilink marked this conversation as resolved.
Show resolved Hide resolved
<form method="post" action="{% url 'check-new-email-provider' user|get_new_provider_pk %}">
philippemilink marked this conversation as resolved.
Show resolved Hide resolved
{% 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()
Loading