diff --git a/src/fellchensammlung/templates/fellchensammlung/instance-health-check.html b/src/fellchensammlung/templates/fellchensammlung/instance-health-check.html index 5ea853f..5be5e85 100644 --- a/src/fellchensammlung/templates/fellchensammlung/instance-health-check.html +++ b/src/fellchensammlung/templates/fellchensammlung/instance-health-check.html @@ -119,4 +119,23 @@ +
Moin,
++ das ist eine Test-E-Mail. +
++ Hier ist ein total wichtiger Button. Klick den mal! +
+ +{% endblock %} \ No newline at end of file diff --git a/src/fellchensammlung/tools/admin.py b/src/fellchensammlung/tools/admin.py index ed05460..7f37cef 100644 --- a/src/fellchensammlung/tools/admin.py +++ b/src/fellchensammlung/tools/admin.py @@ -1,10 +1,13 @@ import logging +from notfellchen import settings from django.utils import timezone from datetime import timedelta from django_super_deduper.merge import MergedModelInstance from django.template.loader import render_to_string +from django.core import mail +from django.utils.html import strip_tags from fellchensammlung.models import AdoptionNotice, Location, RescueOrganization, AdoptionNoticeStatus, Log, \ AdoptionNoticeNotification @@ -125,3 +128,13 @@ def export_orgs_as_vcf(): with open(filename, "w") as f: f.write(result) print(f"Wrote {len(rescue_orgs)} contacts to {filename}") + + +def send_test_email(email): + subject = 'Test E-Mail' + html_message = render_to_string('fellchensammlung/mail/test.html', {'context': 'values'}) + plain_message = strip_tags(html_message) + from_email = f'From <{settings.DEFAULT_FROM_EMAIL}>' + to = email + + mail.send_mail(subject, plain_message, from_email, [to], html_message=html_message) diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index eb582f8..49f2721 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -30,7 +30,7 @@ from .tools import i18n from .tools.geo import GeoAPI, zoom_level_for_radius from .tools.metrics import gather_metrics_data from .tools.admin import clean_locations, get_unchecked_adoption_notices, deactivate_unchecked_adoption_notices, \ - deactivate_404_adoption_notices + deactivate_404_adoption_notices, send_test_email from .tasks import post_adoption_notice_save from rest_framework.authtoken.models import Token @@ -638,6 +638,9 @@ def instance_health_check(request): deactivate_unchecked_adoption_notices() elif action == "deactivate_404": deactivate_404_adoption_notices() + elif action == "send_test_email": + target_email = request.POST.get("test_email_address") + send_test_email(target_email) number_of_adoption_notices = AdoptionNotice.objects.all().count() none_geocoded_adoption_notices = AdoptionNotice.objects.filter(location__isnull=True)