From 13d4eb8358e3c529020e87baabc23fbba9191f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bodor=20M=C3=A1t=C3=A9?= <bodor.mate@kszk.bme.hu> Date: Sat, 19 Jan 2019 15:45:29 +0100 Subject: [PATCH] Create email --- src/account/auth_pipeline.py | 6 +++--- src/common/email.py | 32 +++++++++++++++++++++++++--- src/kszkepzes/settings/production.py | 12 ++--------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/account/auth_pipeline.py b/src/account/auth_pipeline.py index 16eb573..571b46d 100644 --- a/src/account/auth_pipeline.py +++ b/src/account/auth_pipeline.py @@ -1,14 +1,14 @@ from django.core import exceptions -from common.email import registration_email +from common.email import registration from . import models def create_profile(backend, user, response, *args, **kwargs): if backend.name == 'authsch': - if user.email is not None: - registration_email(user.email) try: user.profile except exceptions.ObjectDoesNotExist: models.Profile.objects.create(user=user) + if user.email is not None: + registration(user.email) diff --git a/src/common/email.py b/src/common/email.py index 6e455ad..67ca7d6 100644 --- a/src/common/email.py +++ b/src/common/email.py @@ -1,6 +1,32 @@ from django.core.mail import send_mail -def registration_email(email): - send_mail('TESZT', 'Udvozlunk a kszkepzesen, ne felejtsd el kitolteni a profilod.', - 'noreply@devteam.sch.bme.hu', [email, ]) \ No newline at end of file +def registration(email): + subject = "REGISTRATION TEST" + message = "ĂdvĂśzlĂźnk a kszkĂŠpzĂŠsen!" + send_mail(subject, message, 'noreply@devteam.sch.bme.hu', [email, ]) + + +def admitted(email): + subject = "ADMITTED TEST" + message = "GratulĂĄlunk, te vagy a kivĂĄlasztott!!" + send_mail(subject, message, 'noreply@devteam.sch.bme.hu', [email, ]) + + +def denied(email): + subject = "DENIED TEST" + message = "Sajnos idĂŠn nem nyertĂŠl felvĂŠtelt, prĂłbĂĄld meg legkĂśzelebb" + send_mail(subject, message, 'noreply@devteam.sch.bme.hu', [email, ]) + + +def new_homework(email): + subject = "NEW HOMEWORK TEST" + message = "Szia!\nEgy Ăşj hĂĄzi lett kiadva, ha tĂz percen belĂźl megoldod akkor fasza gyerek vagy," \ + " ha nem ĂŠleted vĂŠgĂŠig bĂĄnnifogod..." + send_mail(subject, message, 'noreply@devteam.sch.bme.hu', [email, ]) + + +def homework_corrected(email): + subject = "HOMEWORK CORRECTED TEST" + message = "NagyszerĹą mentoraink kijavĂtottĂĄk hĂĄzifeladatod, vajon most kaptĂĄl meglepit?!" + send_mail(subject, message, 'noreply@devteam.sch.bme.hu', [email, ]) diff --git a/src/kszkepzes/settings/production.py b/src/kszkepzes/settings/production.py index 4d66610..24575d5 100644 --- a/src/kszkepzes/settings/production.py +++ b/src/kszkepzes/settings/production.py @@ -27,14 +27,6 @@ REST_FRAMEWORK = { STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected') - -# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -# EMAIL_HOST = 'mail.sch.bme.hu' -# EMAIL_USE_TLS = True -# EMAIL_PORT = 587 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_USE_TLS = True -EMAIL_PORT = 587 -EMAIL_HOST_USER = 'bmate711kamu@gmail.com' -EMAIL_HOST_PASSWORD = '1IronxDog' +EMAIL_HOST = 'mail.sch.bme.hu' +EMAIL_PORT = 25 -- GitLab