From bb58f29c8636d3d5cc81cd33649e3b1ca970c34d Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Sun, 5 Dec 2021 19:57:18 +0100 Subject: [PATCH] =?UTF-8?q?Implementov=C3=A1no=20pos=C3=ADl=C3=A1n=C3=AD?= =?UTF-8?q?=20e-mail=C5=AF=20z=20korekturov=C3=A1tka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/admin.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/korektury/admin.py b/korektury/admin.py index 79dfffb1..0842eb15 100644 --- a/korektury/admin.py +++ b/korektury/admin.py @@ -2,6 +2,8 @@ from django.contrib import admin from reversion.admin import VersionAdmin from korektury.models import KorekturovanePDF +from django.core.mail import send_mail +from django.urls import reverse # Register your models here. class KorekturovanePDFAdmin(VersionAdmin): @@ -23,4 +25,24 @@ class KorekturovanePDFAdmin(VersionAdmin): list_filter = [] search_fields = [] + def save_model(self, request, obj, form, change): + super().save_model(request, obj, form, change) + if not change: # Je nový + odkaz = request.build_absolute_uri(reverse('korektury', kwargs={'pdf': obj.id})) + odesilatel = 'korekturovatko-nove-pdf@mam.mff.cuni.cz' + prijemce = 'org@mam.mff.cuni.cz' + predmet = f'Nové korektury: {obj.nazev}' + text = f'''\ +V korekturovátku se objevil nový soubor: {obj.nazev} +{odkaz} + +Popis souboru: +{obj.komentar} + +--- +S pozdravem a korekturám zdar! +Korekturovátko +''' + send_mail(predmet,text,odesilatel,[prijemce]) + admin.site.register(KorekturovanePDF, KorekturovanePDFAdmin)