diff --git a/.env.example b/.env.example index db25fdfd..e152be20 100644 --- a/.env.example +++ b/.env.example @@ -45,3 +45,16 @@ AUTH0_TOKEN_URL= AUTH0_CLIENT_ID= AUTH0_CLIENT_SECRET= AUTH0_AUDIENCE= + +# email settings +EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend' +EMAIL_HOST='smtp.gmail.com' +EMAIL_USE_TLS=True +EMAIL_PORT=587 +DEFAULT_FROM_EMAIL=Plio +EMAIL_HOST_USER= # sender's email-id +# password associated with above email-id +# for accounts with 2-factor authentication, you have to create a application-specific +# passwords. More on that here: +# https://dev.to/abderrahmanemustapha/how-to-send-email-with-django-and-gmail-in-production-the-right-way-24ab +EMAIL_HOST_PASSWORD= diff --git a/entrypoint.sh b/entrypoint.sh index dd06826b..b2605be3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,9 @@ #!/bin/bash set -e +# collect static files +python manage.py collectstatic --no-input + # run migrations python manage.py migrate diff --git a/plio/settings.py b/plio/settings.py index 7bedf7bf..04cec5de 100644 --- a/plio/settings.py +++ b/plio/settings.py @@ -291,7 +291,17 @@ } } +# authentication AUTH0_TOKEN_URL = os.environ.get("AUTH0_TOKEN_URL") AUTH0_CLIENT_ID = os.environ.get("AUTH0_CLIENT_ID") AUTH0_CLIENT_SECRET = os.environ.get("AUTH0_CLIENT_SECRET") AUTH0_AUDIENCE = os.environ.get("AUTH0_AUDIENCE") + +# email +EMAIL_BACKEND = os.environ.get("EMAIL_BACKEND") +EMAIL_HOST = os.environ.get("EMAIL_HOST") +EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS") +EMAIL_PORT = os.environ.get("EMAIL_PORT") +DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL") +EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") +EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD") diff --git a/plio/templates/waitlist-approve-email.html b/plio/templates/waitlist-approve-email.html new file mode 100644 index 00000000..9b97f031 --- /dev/null +++ b/plio/templates/waitlist-approve-email.html @@ -0,0 +1,140 @@ + + + + + + +
+
+
+ + + + + + +
+
+ + + + + + +
+ + + + + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + + + + + + + + + + +
+
Hooray ๐ŸŽ‰ Youโ€™re off the waitlist - welcome to Plio :)

With Plio, you can unlock the true potential of videos by making them interactive and understanding how your viewers engage with them.

Start pliofying the world by making your videos interactive today.
+
+ + + + + + +
Create a Plio
+
+

We sincerely hope that you'll enjoy Plio and we are eagerly waiting to hear from you about your experience.
+
+
Cheers,
Plioneers
+
+
+
+
+
+ + + + + + +
+
+ + + + + + + + + +
+
www.plio.in
Bengaluru, India
+
+ + + + + + +
+
+
+
+
+
+
+
+ + diff --git a/plio/urls.py b/plio/urls.py index 7d68a3d9..f80861fc 100644 --- a/plio/urls.py +++ b/plio/urls.py @@ -15,8 +15,8 @@ """ from django.contrib import admin from django.urls import path, include -from rest_framework import routers, permissions from django.conf.urls import url +from rest_framework import routers, permissions from drf_yasg.views import get_schema_view from drf_yasg import openapi from tags.views import TagViewSet diff --git a/users/views.py b/users/views.py index 5928f894..9b6e0e12 100644 --- a/users/views.py +++ b/users/views.py @@ -1,5 +1,20 @@ from rest_framework.decorators import api_view, permission_classes, action from rest_framework.permissions import AllowAny +from rest_framework import viewsets, status +from rest_framework.response import Response + +import datetime +import string +import random +from oauth2_provider.models import AccessToken, Application, RefreshToken + +from asgiref.sync import async_to_sync +from django.contrib.auth import login +from django.dispatch import receiver +from django.db.models.signals import post_save, pre_save, post_delete +from django.core.mail import send_mail +from django.template.loader import render_to_string +from channels.layers import get_channel_layer from plio.settings import ( API_APPLICATION_NAME, @@ -9,25 +24,13 @@ AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_AUDIENCE, + DEFAULT_FROM_EMAIL, ) -from rest_framework import viewsets, status -from rest_framework.response import Response from users.models import User, OneTimePassword, OrganizationUser from users.serializers import UserSerializer, OtpSerializer, OrganizationUserSerializer -import datetime -import string -import random -from django.contrib.auth import login -from oauth2_provider.models import AccessToken, Application, RefreshToken from .services import SnsService - -from asgiref.sync import async_to_sync -from channels.layers import get_channel_layer -from django.dispatch import receiver -from django.db.models.signals import post_save, pre_save, post_delete - import requests @@ -197,6 +200,21 @@ def update_user(sender, instance: User, **kwargs): user_group_name, {"type": "send_user", "data": user_data} ) + # send an email if the user has been approved + if instance.email and instance.status == "approved": + subject = "Congrats - You're off the Plio waitlist! ๐ŸŽ‰" + recipient_list = [ + instance.email, + ] + html_message = render_to_string("waitlist-approve-email.html") + send_mail( + subject=subject, + message=None, + from_email=DEFAULT_FROM_EMAIL, + recipient_list=recipient_list, + html_message=html_message, + ) + @receiver(post_save, sender=OrganizationUser) @receiver(post_delete, sender=OrganizationUser)