|
@ -32,6 +32,8 @@ from seminar.treelib import safe_pred |
|
|
|
|
|
|
|
|
from polymorphic.models import PolymorphicModel |
|
|
from polymorphic.models import PolymorphicModel |
|
|
|
|
|
|
|
|
|
|
|
from django.core.mail import EmailMessage |
|
|
|
|
|
from seminar.utils import aktivniResitele |
|
|
|
|
|
|
|
|
class SeminarModelBase(models.Model): |
|
|
class SeminarModelBase(models.Model): |
|
|
|
|
|
|
|
@ -539,9 +541,43 @@ class Cislo(SeminarModelBase): |
|
|
return None |
|
|
return None |
|
|
return c |
|
|
return c |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
|
super().__init__(*args, **kwargs) |
|
|
|
|
|
self.__original_verejne = self.verejne_db |
|
|
|
|
|
|
|
|
|
|
|
def posli_cislo_mailem(self): |
|
|
|
|
|
# parametry e-mailu |
|
|
|
|
|
odkaz = self.get_absolute_url() |
|
|
|
|
|
|
|
|
|
|
|
poslat_z_mailu = 'zadani@mam.mff.cuni.cz' |
|
|
|
|
|
predmet = 'Vyšlo číslo {}'.format(self.kod()) |
|
|
|
|
|
text_mailu = 'Ahoj,\n' \ |
|
|
|
|
|
'na adrese {} najdete nejnovější číslo.\n' \ |
|
|
|
|
|
'Vaše M&M\n'.format(odkaz) |
|
|
|
|
|
|
|
|
|
|
|
# Prijemci e-mailu |
|
|
|
|
|
emaily = map(lambda r: r.osoba.email, aktivniResitele(self )) |
|
|
|
|
|
|
|
|
|
|
|
if not settings.POSLI_MAILOVOU_NOTIFIKACI: |
|
|
|
|
|
print("Poslal bych upozornění na tyto adresy: ", " ".join(emaily)) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
email = EmailMessage( |
|
|
|
|
|
subject=predmet, |
|
|
|
|
|
body=text_mailu, |
|
|
|
|
|
from_email=poslat_z_mailu, |
|
|
|
|
|
bcc=list(emaily) |
|
|
|
|
|
#bcc = příjemci skryté kopie |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
def save(self, *args, **kwargs): |
|
|
def save(self, *args, **kwargs): |
|
|
super().save(*args, **kwargs) |
|
|
super().save(*args, **kwargs) |
|
|
self.vygeneruj_nahled() |
|
|
self.vygeneruj_nahled() |
|
|
|
|
|
# Při zveřejnění pošle mail |
|
|
|
|
|
if self.verejne_db and not self.__original_verejne: |
|
|
|
|
|
self.posli_cislo_mailem() |
|
|
# *Node.save() aktualizuje název *Nodu. |
|
|
# *Node.save() aktualizuje název *Nodu. |
|
|
try: |
|
|
try: |
|
|
self.cislonode.save() |
|
|
self.cislonode.save() |
|
|