-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2088ea1
commit 10208ef
Showing
9 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
'prenotazioni', | ||
'rest_framework', | ||
'rest_framework_api_key', | ||
'django_apscheduler', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
18 changes: 18 additions & 0 deletions
18
prenotazioni/migrations/0002_rename_primadonazione_prenotazioni_analisieffettuate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.2.5 on 2024-01-21 10:57 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('prenotazioni', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='prenotazioni', | ||
old_name='primadonazione', | ||
new_name='analisieffettuate', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from datetime import datetime, timedelta | ||
from django.core.mail import EmailMessage | ||
from .models import prenotazioni | ||
|
||
|
||
def notificaPrenotazioni(): | ||
gg = datetime.now() + timedelta(days=1) | ||
dbListaPrenotazioni = prenotazioni.objects.filter(data=gg.date()) | ||
|
||
if not dbListaPrenotazioni: | ||
return | ||
|
||
listaPrenotazioni = "<br>".join([f"<b>Nome:</b> {prenotazione.nome} - <b>Telefono:</b> {prenotazione.nome} - <b>Ha effettuato le analisi predonazione:</b> {prenotazione.analisieffettuate}" for prenotazione in dbListaPrenotazioni]) | ||
|
||
oggetto = "Prenotazioni donazione sangue " + gg.strftime("%d/%m/%Y") | ||
|
||
corpo = f'Prenotazioni per la donazione del sangue di domani: <br><br>{listaPrenotazioni}' | ||
|
||
notifyemail = os.environ.get('NOTIFYEMAIL', '') | ||
|
||
if notifyemail: | ||
listaEmail = notifyemail.split(',') | ||
else: | ||
listaEmail = [] | ||
|
||
email = EmailMessage( | ||
oggetto, | ||
corpo, | ||
os.getenv("DEFAULT_FROM_EMAIL"), | ||
listaEmail, | ||
) | ||
email.content_subtype = "html" | ||
email.send() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters