diff --git a/zubhub_backend/zubhub/creators/serializers.py b/zubhub_backend/zubhub/creators/serializers.py index 8d58e99e7..2b554d2e7 100644 --- a/zubhub_backend/zubhub/creators/serializers.py +++ b/zubhub_backend/zubhub/creators/serializers.py @@ -302,6 +302,10 @@ def validate_email(self, value): _('No account found with this email. Verify and try again.')) return value + def get_email_options(self): + return { + 'html_email_template_name': 'registration/password_reset_email.html' + } class CreatorGroupWithMembershipsSerializer(serializers.ModelSerializer): members = CreatorGroupMembershipSerializer(many=True) diff --git a/zubhub_backend/zubhub/creators/views.py b/zubhub_backend/zubhub/creators/views.py index 76c4df953..9754b3478 100644 --- a/zubhub_backend/zubhub/creators/views.py +++ b/zubhub_backend/zubhub/creators/views.py @@ -32,6 +32,7 @@ from projects.permissions import (SustainedRateThrottle, PostUserRateThrottle, GetUserRateThrottle, GetAnonRateThrottle, CustomUserRateThrottle) +from zubhub.tasks import send_follower_notification_email # from ..projects.models import Project from .models import Location, CreatorGroup, PhoneConfirmationHMAC, GroupInviteConfirmationHMAC, CreatorGroupMembership @@ -471,6 +472,14 @@ def get_object(self): Activitylog.Type.FOLLOW, f'/creators/{obj}' ) + context = { + "user": { + "username": self.request.user.username, + "avatar": self.request.user.avatar, + "pk": self.request.user.pk + } + } + send_follower_notification_email.delay(obj.email, context) self.request.user.save() return obj diff --git a/zubhub_backend/zubhub/projects/views.py b/zubhub_backend/zubhub/projects/views.py index 69ed4ce98..015398828 100644 --- a/zubhub_backend/zubhub/projects/views.py +++ b/zubhub_backend/zubhub/projects/views.py @@ -16,6 +16,7 @@ SustainedRateThrottle, PostUserRateThrottle, GetUserRateThrottle, CustomUserRateThrottle) from activitylog.models import Activitylog +from zubhub.tasks import send_comment_notification_email, send_bookmark_notification_email from .models import Project, Comment, StaffPick, Category, Tag, PublishingRule from creators.models import Creator from .utils import (ProjectSearchCriteria, project_changed, detect_mentions, @@ -410,6 +411,16 @@ def get_object(self): f'/projects/{obj.pk}' ) + context = { + "project": { + "title": obj.title, + "description": obj.description, + "pk": obj.pk, + "image": obj.images.first().image_url, + }, + "bookmarked_by": self.request.user.username, + } + send_bookmark_notification_email.delay(obj.creator.email, context) return obj else: @@ -507,6 +518,18 @@ def create(self, request, *args, **kwargs): f'/projects/{result.pk}' ) + context = { + "project": { + "title": result.title, + "description": result.description, + "pk": result.pk, + "image": result.images.first().image_url + }, + "comment": text, + "commented_by": creator_str, + } + send_comment_notification_email.delay(result.creator.email, context) + return Response(ProjectSerializer(result, context={ 'request': request }).data, diff --git a/zubhub_backend/zubhub/static/images/Facebook.png b/zubhub_backend/zubhub/static/images/Facebook.png new file mode 100644 index 000000000..adb34c5a5 Binary files /dev/null and b/zubhub_backend/zubhub/static/images/Facebook.png differ diff --git a/zubhub_backend/zubhub/static/images/Instagram.png b/zubhub_backend/zubhub/static/images/Instagram.png new file mode 100644 index 000000000..2e80756d5 Binary files /dev/null and b/zubhub_backend/zubhub/static/images/Instagram.png differ diff --git a/zubhub_backend/zubhub/static/images/Linkedin.png b/zubhub_backend/zubhub/static/images/Linkedin.png new file mode 100644 index 000000000..3fd252252 Binary files /dev/null and b/zubhub_backend/zubhub/static/images/Linkedin.png differ diff --git a/zubhub_backend/zubhub/static/images/Pie-Illustration.png b/zubhub_backend/zubhub/static/images/Pie-Illustration.png new file mode 100644 index 000000000..1024a455b Binary files /dev/null and b/zubhub_backend/zubhub/static/images/Pie-Illustration.png differ diff --git a/zubhub_backend/zubhub/static/images/Twitter.png b/zubhub_backend/zubhub/static/images/Twitter.png new file mode 100644 index 000000000..31da3a1e7 Binary files /dev/null and b/zubhub_backend/zubhub/static/images/Twitter.png differ diff --git a/zubhub_backend/zubhub/static/images/ZubHub-Logo.png b/zubhub_backend/zubhub/static/images/ZubHub-Logo.png new file mode 100644 index 000000000..eb3dd90c5 Binary files /dev/null and b/zubhub_backend/zubhub/static/images/ZubHub-Logo.png differ diff --git a/zubhub_backend/zubhub/static/images/studio-logo-dark.png b/zubhub_backend/zubhub/static/images/studio-logo-dark.png new file mode 100644 index 000000000..3497b8df1 Binary files /dev/null and b/zubhub_backend/zubhub/static/images/studio-logo-dark.png differ diff --git a/zubhub_backend/zubhub/templates/account/email/email_confirmation_message.html b/zubhub_backend/zubhub/templates/account/email/email_confirmation_message.html new file mode 100644 index 000000000..842982ab8 --- /dev/null +++ b/zubhub_backend/zubhub/templates/account/email/email_confirmation_message.html @@ -0,0 +1,30 @@ +{% extends "email/email_base.html" %} +{% load static %} +{% load default_template_tags %} + +{% block title %}Activate Your Account{% endblock %} + +{% block content %} +

Activate Your Account

+ +

Dear {{ user.username }}

+

Welcome to ZubHub! We're thrilled to have you on board. To get started, we just need to confirm your email address. Please click on the button below to activate your account.

+ + + Activate your account + + +
+

Please note that this link will expire in 30 minutes.

+

If you didn’t try to sign-in or create an account on ZubHub, you can safely ignore this email.

+
+{% endblock %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/account/email/email_confirmation_signup_message.html b/zubhub_backend/zubhub/templates/account/email/email_confirmation_signup_message.html new file mode 100644 index 000000000..ae475a5a5 --- /dev/null +++ b/zubhub_backend/zubhub/templates/account/email/email_confirmation_signup_message.html @@ -0,0 +1 @@ +{% include "account/email/email_confirmation_message.html" %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/email/badge.html b/zubhub_backend/zubhub/templates/email/badge.html new file mode 100644 index 000000000..29ef1f5c2 --- /dev/null +++ b/zubhub_backend/zubhub/templates/email/badge.html @@ -0,0 +1,22 @@ +{% extends "email/email_base.html" %} +{% load static %} + +{% block title %}You got a new badge!{% endblock %} + +{% block content %} +

You got a new badge!

+

Congratulations! You’ve unlocked a new achievement and earned the prestigious {{ badge.name }} badge. 🌟

+
+ Badge image +

{{ badge.name }}

+
+

{{ badge.message }} Click + + here + + to view more. +

+{% endblock %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/email/bookmark.html b/zubhub_backend/zubhub/templates/email/bookmark.html new file mode 100644 index 000000000..c71ca0723 --- /dev/null +++ b/zubhub_backend/zubhub/templates/email/bookmark.html @@ -0,0 +1,27 @@ +{% extends "email/email_base.html" %} +{% load static %} + +{% block title %}You've been bookmarked!{% endblock %} + +{% block content %} +

You've been bookmarked!

+ +

Your post just got bookmarked. Your content is worth saving!

+ + Project Image +

{{ project.title }}

+

{{ project.description|striptags }}

+
+
+

{{ bookmarked_by }} have bookmarked your project.

+
+ +
+

Join the conversation now and engage with your audience. Click + + here + + to view more. +

+
+{% endblock %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/email/comment.html b/zubhub_backend/zubhub/templates/email/comment.html new file mode 100644 index 000000000..f56e3706a --- /dev/null +++ b/zubhub_backend/zubhub/templates/email/comment.html @@ -0,0 +1,27 @@ +{% extends "email/email_base.html" %} +{% load static %} + +{% block title %}You got a comment!{% endblock %} + +{% block content %} +

You got a comment!

+ +

Great news! Someone just left a comment on your post. 🎉

+ + Project Image +

{{ project.title }}

+

{{ project.description|striptags }}

+
+
+

{{ commented_by }} says "{{ comment }}"

+
+ +
+

Join the conversation now and engage with your audience. Click + + here + + to view comment and respond. +

+
+{% endblock %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/email/email_base.html b/zubhub_backend/zubhub/templates/email/email_base.html new file mode 100644 index 000000000..e9fafda21 --- /dev/null +++ b/zubhub_backend/zubhub/templates/email/email_base.html @@ -0,0 +1,228 @@ +{% load static %} +{% load default_template_tags %} + + + + + + + + + + + + {% block title %}{% endblock %} + + + + + + +
 ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
+ + +
+ +
+ + + + + +
+ + +
+ + Zubhub's Logo + +
+ + + + +
+ + pie illustration + +
+ + +
+ + + + {% block content %}{% endblock %} + + +
+ +
+ Unstructured Studio's Logo +

Creative learning for all!

+
+ +
+ + + Facebook logo + + + + + Instagram logo + + + + + X logo + + + + + Linkedin logo + + +
+ +
+ + Help + +
+ + Unsubscribe + +
+ +
+

Unstructured Studio

+

301-4 Elsinore Path, Etobicoke, ON

+

M8V 4G7, CANADA

+

© 2023 All rights reserved.

+
+ +
+ + + +
+ + + + + \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/email/follower.html b/zubhub_backend/zubhub/templates/email/follower.html new file mode 100644 index 000000000..80a84ca17 --- /dev/null +++ b/zubhub_backend/zubhub/templates/email/follower.html @@ -0,0 +1,27 @@ +{% extends "email/email_base.html" %} +{% load static %} + +{% block title %}You have a new follower!{% endblock %} + +{% block content %} +

You have a new follower!

+

You just gained a new follower! You’re becoming quite the celebrity.

+ +
+ User avatar +

{{ user.username }}

+ + + View profile + +
+{% endblock %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/templates/registration/password_reset_email.html b/zubhub_backend/zubhub/templates/registration/password_reset_email.html index 4fc6fabb1..25357e91d 100644 --- a/zubhub_backend/zubhub/templates/registration/password_reset_email.html +++ b/zubhub_backend/zubhub/templates/registration/password_reset_email.html @@ -1,13 +1,32 @@ -{% load i18n %} +{% extends "email/email_base.html" %} +{% load static %} {% load default_template_tags %} -{% autoescape off %} -{%trans "You're receiving this email because you requested a password reset for your user account at " %}{% default_display_name %} -{% trans "Please go to the following page and choose a new password:" %} -{% block reset_link %} -{# {{protocol}}://{{domain}}/password-reset-confirm?uid={{uid}}&&token={{token}} #} -{% default_frontend_protocol %}://{% default_frontend_domain %}/password-reset-confirm?uid={{uid}}&&token={{token}} +{% autoescape on %} + +{% block title %}Reset Your Password{% endblock %} + +{% block content %} +

Reset Your Password

+ +

Dear {{ user.get_username }}

+

You're receiving this email because you requested to change your Zubhub password. Tap the button below to reset your password.

+ + + Reset your password + + +
+

Please note that this link will expire in 30 minutes.

+

If you didn't request this email, there's nothing to worry about. You can safely ignore it.

+
{% endblock %} -{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }} -{% trans "Thanks for using our site!" %} -{% trans "The " %}{% default_display_name %} {% trans " Team" %} -{% endautoescape %} \ No newline at end of file +{% endautoescape %} \ No newline at end of file diff --git a/zubhub_backend/zubhub/zubhub/tasks.py b/zubhub_backend/zubhub/zubhub/tasks.py new file mode 100644 index 000000000..d28471b7e --- /dev/null +++ b/zubhub_backend/zubhub/zubhub/tasks.py @@ -0,0 +1,53 @@ +from celery import shared_task +from django.core.mail import EmailMessage +from django.template.loader import render_to_string +from zubhub import settings + +@shared_task(name="zubhub.tasks.send_bookmark_notification_email", bind=True) +def send_bookmark_notification_email(self, email_to, context): + email_content = render_to_string("email/bookmark.html", context) + mail = EmailMessage( + "You've been bookmarked!", + email_content, + settings.DEFAULT_FROM_EMAIL, + [email_to] + ) + mail.content_subtype = "html" + return mail.send() + +@shared_task(name="zubhub.tasks.send_badge_notification_email", bind=True) +def send_badge_notification_email(self, email_to, context): + email_content = render_to_string("email/badge.html", context) + mail = EmailMessage( + "You got a new badge!", + email_content, + settings.DEFAULT_FROM_EMAIL, + [email_to] + ) + mail.content_subtype = "html" + return mail.send() + +@shared_task(name="zubhub.tasks.send_comment_notification_email", bind=True) +def send_comment_notification_email(self, email_to, context): + email_content = render_to_string("email/comment.html", context) + mail = EmailMessage( + "You got a comment!", + email_content, + settings.DEFAULT_FROM_EMAIL, + [email_to], + ) + mail.content_subtype = "html" + return mail.send() + + +@shared_task(name="zubhub.tasks.send_follower_notification_email", bind=True) +def send_follower_notification_email(self, email_to, context): + email_content = render_to_string("email/follower.html", context) + mail = EmailMessage( + "You have a new follower!", + email_content, + settings.DEFAULT_FROM_EMAIL, + [email_to] + ) + mail.content_subtype = "html" + return mail.send() \ No newline at end of file