From 2bf6d0cb66b8ccc5ef56feb0d0233a36c9033574 Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 4 Aug 2024 15:34:06 +0200 Subject: [PATCH] fix: Filter for trust level correctly, use new user model --- src/fellchensammlung/mail.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fellchensammlung/mail.py b/src/fellchensammlung/mail.py index 51fc00d..e003fa8 100644 --- a/src/fellchensammlung/mail.py +++ b/src/fellchensammlung/mail.py @@ -4,14 +4,14 @@ from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext from django.conf import settings from django.core import mail -from django.db.models import Q +from django.db.models import Q, Min from fellchensammlung.models import User from notfellchen.settings import host def mail_admins_new_report(report): subject = _("Neue Meldung") - for moderator in User.objects.filter(Q(trust_level=User.MODERATOR) | Q(trust_level=User.ADMIN)): + for moderator in User.objects.filter(trust_level__gt=User.TRUST_LEVEL[User.MODERATOR]): greeting = _("Moin,") + "\r\n" new_report_text = _("es wurde ein Regelverstoß gemeldet.") + "\r\n" if len(report.reported_broken_rules.all()) > 0: @@ -27,6 +27,6 @@ def mail_admins_new_report(report): report_url = "https://" + host + report.get_absolute_url() link_text = f"Um alle Details zu sehen, geh bitte auf: {report_url}" body_text = greeting + new_report_text + reported_rules_text + comment_text + link_text - message = mail.EmailMessage(subject, body_text, settings.DEFAULT_FROM_EMAIL, [moderator.user.email]) - print("Sending email to ", moderator.user.email) + message = mail.EmailMessage(subject, body_text, settings.DEFAULT_FROM_EMAIL, [moderator.email]) + print("Sending email to ", moderator.email) message.send()