fix: Filter for trust level correctly, use new user model
This commit is contained in:
parent
b4fbb13714
commit
2bf6d0cb66
@ -4,14 +4,14 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.utils.translation import gettext
|
from django.utils.translation import gettext
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.db.models import Q
|
from django.db.models import Q, Min
|
||||||
from fellchensammlung.models import User
|
from fellchensammlung.models import User
|
||||||
from notfellchen.settings import host
|
from notfellchen.settings import host
|
||||||
|
|
||||||
|
|
||||||
def mail_admins_new_report(report):
|
def mail_admins_new_report(report):
|
||||||
subject = _("Neue Meldung")
|
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"
|
greeting = _("Moin,") + "\r\n"
|
||||||
new_report_text = _("es wurde ein Regelverstoß gemeldet.") + "\r\n"
|
new_report_text = _("es wurde ein Regelverstoß gemeldet.") + "\r\n"
|
||||||
if len(report.reported_broken_rules.all()) > 0:
|
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()
|
report_url = "https://" + host + report.get_absolute_url()
|
||||||
link_text = f"Um alle Details zu sehen, geh bitte auf: {report_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
|
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])
|
message = mail.EmailMessage(subject, body_text, settings.DEFAULT_FROM_EMAIL, [moderator.email])
|
||||||
print("Sending email to ", moderator.user.email)
|
print("Sending email to ", moderator.email)
|
||||||
message.send()
|
message.send()
|
||||||
|
Loading…
Reference in New Issue
Block a user