diff --git a/input/admin.py b/input/admin.py index 3bacccb..b503b40 100755 --- a/input/admin.py +++ b/input/admin.py @@ -1,11 +1,10 @@ import csv from django.contrib import admin -from django.db import models, transaction +from django.db import models from django.http import HttpResponse from input.utils.list import reorder_value -from input.utils.mail import send_decision_mails from .forms import BaseProjectForm from .models import ( @@ -174,16 +173,6 @@ class ProjectAdmin(BaseProjectAdmin): class ProjectRequestAdmin(BaseProjectAdmin): granted = None - def save_model(self, request, obj: ProjectRequest, form: ProjectAdminForm, change: bool): - super().save_model(request, obj, form, change) - - if obj.granted is None: - return None - - transaction.on_commit(lambda: send_decision_mails(obj)) - - return obj.granted - @admin.register(ProjectDeclined) class ProjectDeclinedAdmin(BaseProjectAdmin): diff --git a/input/templates/mails/approval_denied_applicant.html b/input/templates/mails/approval_denied_applicant.html deleted file mode 100644 index 6343d74..0000000 --- a/input/templates/mails/approval_denied_applicant.html +++ /dev/null @@ -1,9 +0,0 @@ - - -

Hallo {{ data.realname }},

- -

Deine Förderanfrage {{project.name}} wurde leider abgelehnt.

- -

Fragen? community@wikimedia.de

- - diff --git a/input/templates/mails/approval_denied_applicant.txt b/input/templates/mails/approval_denied_applicant.txt deleted file mode 100644 index 55a8df6..0000000 --- a/input/templates/mails/approval_denied_applicant.txt +++ /dev/null @@ -1,5 +0,0 @@ -Hallo {{ data.realname }}, - -deine Förderanfrage {{project.name}} wurde leider abgelehnt. - -Fragen? community@wikimedia.de diff --git a/input/templates/mails/approval_denied_staff.html b/input/templates/mails/approval_denied_staff.html deleted file mode 100644 index 3281b63..0000000 --- a/input/templates/mails/approval_denied_staff.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

Hallo Team Community-Konferenzen & Förderung,

- -

Die Förderanfrage {{project.name}} von {{ data.realname }} wurde abgelehnt.

- - \ No newline at end of file diff --git a/input/templates/mails/approval_denied_staff.txt b/input/templates/mails/approval_denied_staff.txt deleted file mode 100644 index 2a96ae9..0000000 --- a/input/templates/mails/approval_denied_staff.txt +++ /dev/null @@ -1,3 +0,0 @@ -Hallo Team Community-Konferenzen & Förderung, - -die Förderanfrage {{project.name}} von {{ data.realname }} wurde abgelehnt. diff --git a/input/templates/mails/approval_granted_applicant.html b/input/templates/mails/approval_granted_applicant.html deleted file mode 100644 index c768a73..0000000 --- a/input/templates/mails/approval_granted_applicant.html +++ /dev/null @@ -1,10 +0,0 @@ - - -

Hallo {{ data.realname }},

- -

Deine Förderanfrage {{project.name}} wurde bewilligt.

- -

Das Team Community-Konferenzen & Förderung meldet sich bald bei dir.
- Fragen? community@wikimedia.de

- - diff --git a/input/templates/mails/approval_granted_applicant.txt b/input/templates/mails/approval_granted_applicant.txt deleted file mode 100644 index c1f3c24..0000000 --- a/input/templates/mails/approval_granted_applicant.txt +++ /dev/null @@ -1,7 +0,0 @@ -Hallo {{ data.realname }}, - -deine Förderanfrage {{project.name}} wurde bewilligt. - -Das Team Community-Konferenzen & Förderung meldet sich bald bei dir. -Fragen? community@wikimedia.de - diff --git a/input/templates/mails/approval_granted_staff.html b/input/templates/mails/approval_granted_staff.html deleted file mode 100644 index d315c00..0000000 --- a/input/templates/mails/approval_granted_staff.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

Hallo Team Community-Konferenzen & Förderung,

- -

Die Förderanfrage {{project.name}} von {{ data.realname }} wurde bewilligt.

- - \ No newline at end of file diff --git a/input/templates/mails/approval_granted_staff.txt b/input/templates/mails/approval_granted_staff.txt deleted file mode 100644 index 5fd989b..0000000 --- a/input/templates/mails/approval_granted_staff.txt +++ /dev/null @@ -1,3 +0,0 @@ -Hallo Team Community-Konferenzen & Förderung, - -die Förderanfrage {{project.name}} von {{ data.realname }} wurde bewilligt. diff --git a/input/tests/admin.py b/input/tests/admin.py index 5116180..06cef45 100644 --- a/input/tests/admin.py +++ b/input/tests/admin.py @@ -1,6 +1,5 @@ import datetime -from django.core import mail from django.forms import model_to_dict from django.test import TestCase @@ -109,7 +108,4 @@ class AdminTestCase(TestCase): if data[key] is None: data.pop(key) - with self.captureOnCommitCallbacks(execute=True): - request(self, url, expected_url=expected_url, data=data) - - self.assertEqual(len(mail.outbox), 2) + request(self, url, expected_url=expected_url, data=data) diff --git a/input/utils/mail/__init__.py b/input/utils/mail/__init__.py index 909951c..186e03d 100644 --- a/input/utils/mail/__init__.py +++ b/input/utils/mail/__init__.py @@ -10,9 +10,6 @@ __all__ = [ 'build_email', 'send_email', 'collect_and_attach', - 'send_applicant_decision_mail', - 'send_staff_decision_mail', - 'send_decision_mails', ] @@ -35,49 +32,3 @@ def build_email(template_name: str, context: dict, subject: str, *recipients: st def send_email(template_name: str, context: dict, subject: str, *recipients: str, fail_silently=False, **kwargs): return build_email(template_name, context, subject, *recipients, **kwargs).send(fail_silently) - - -def get_decision_mail_context(obj: Project): - """ - Build a minimal, consistent context for decision mails (applicant & staff). - """ - - return { - 'project': obj, - 'data': { - 'realname': obj.realname or obj.email, - 'name': obj.name, - }, - } - - -def send_base_decision_mail(obj: Project, scope: str, subject: str, recipient: str): - context = get_decision_mail_context(obj) - decision = 'granted' if obj.granted else 'denied' - decision_label = 'bewilligt' if obj.granted else 'abgelehnt' - subject = subject.format(name=obj.name, decision=decision_label) - - return send_email(f'approval_{decision}_{scope}', context, subject, recipient) - - -def send_applicant_decision_mail(obj: Project): - """ - Send a decision email to the applicant after manual approval/denial. - """ - - if recipient := obj.email: - return send_base_decision_mail(obj, 'applicant', 'Deine Förderanfrage „{name}“ – {decision}', recipient) - - return 0 - - -def send_staff_decision_mail(obj: Project): - """ - Send a decision email to the internal team (staff) after approval/denial. - """ - - return send_base_decision_mail(obj, 'staff', 'Entscheidung: {name} ({decision})', settings.IF_EMAIL) - - -def send_decision_mails(obj: Project): - return send_applicant_decision_mail(obj) + send_staff_decision_mail(obj)