Skip to content

Commit

Permalink
improves registration email, makes custom registration view
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmegatelo committed Dec 8, 2024
1 parent 8bee8aa commit 9b2ed0e
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 74 deletions.
64 changes: 64 additions & 0 deletions feed/templates/django_registration/activation_email_body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{% extends 'emails/base.html' %}
{% block content %}
<div style="font-weight:normal;padding:0px 24px 16px 24px">
<p>Hi👋 I&#39;m Mikhail, creator of thewalter.app.</p>
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
I hope this message finds you well! First and foremost, I want
to extend my heartfelt thanks for your patience and enthusiasm.
It means the world to me that you’re excited to be a part of
thewalter.app.
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
There only one thing left for you to is your account activation.
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
To activate our account, simply click the link below and follow the
instructions:
</div>
<div style="padding:16px 24px 24px 24px">
<a
href="{{ protocol }}://{{ site }}{% url 'django_registration_activate' %}?activation_key={{activation_key}}"
style="color:#FFFFFF;font-size:16px;font-weight:500;background-color:#FF6340;border-radius:16px;display:inline-block;padding:8px 16px;text-decoration:none"
target="_blank"
><span
><!--[if mso
]><i
style="letter-spacing: 20px;mso-font-width:-100%;mso-text-raise:30"
hidden
>&nbsp;</i
><!
[endif]--></span
><span>Activate an account</span
><span
><!--[if mso
]><i
style="letter-spacing: 20px;mso-font-width:-100%"
hidden
>&nbsp;</i
><!
[endif]--></span
></a
>
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
<p>
If you have any questions or need assistance, don&#39;t
hesitate to reach out to me directly via
<a href="https://t.me/mrmike24" target="_blank">Telegram</a>
or
<a href="https://x.com/mrmegatelo" target="_blank">Twitter</a
>. Your feedback is invaluable as the service continues to
improve. I genuinely look forward to hearing about your
experiences and how thewalter.app is making a difference for
you.
</p>
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
Thank you once again for joining us on this journey. Welcome to
the Walter community – we’re so happy to have you here!
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
Warm regards, Mikhail
</div>
{% endblock %}
85 changes: 21 additions & 64 deletions feed/templates/django_registration/activation_email_body.txt
Original file line number Diff line number Diff line change
@@ -1,64 +1,21 @@
{% extends 'emails/base.html' %}
{% block content %}
<div style="font-weight:normal;padding:0px 24px 16px 24px">
<p>Hi👋 I&#39;m Mikhail, creator of thewalter.app.</p>
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
I hope this message finds you well! First and foremost, I want
to extend my heartfelt thanks for your patience and enthusiasm.
It means the world to me that you’re excited to be a part of
thewalter.app.
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
There only one thing left for you to is your account activation.
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
To activate our account, simply click the link below and follow the
instructions:
</div>
<div style="padding:16px 24px 24px 24px">
<a
href="{{ protocol }}://{{ site }}{% url 'django_registration_activate' %}?activation_key={{activation_key}}"
style="color:#FFFFFF;font-size:16px;font-weight:500;background-color:#FF6340;border-radius:16px;display:inline-block;padding:8px 16px;text-decoration:none"
target="_blank"
><span
><!--[if mso
]><i
style="letter-spacing: 20px;mso-font-width:-100%;mso-text-raise:30"
hidden
>&nbsp;</i
><!
[endif]--></span
><span>Activate an account</span
><span
><!--[if mso
]><i
style="letter-spacing: 20px;mso-font-width:-100%"
hidden
>&nbsp;</i
><!
[endif]--></span
></a
>
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
<p>
If you have any questions or need assistance, don&#39;t
hesitate to reach out to me directly via
<a href="https://t.me/mrmike24" target="_blank">Telegram</a>
or
<a href="https://x.com/mrmegatelo" target="_blank">Twitter</a
>. Your feedback is invaluable as the service continues to
improve. I genuinely look forward to hearing about your
experiences and how thewalter.app is making a difference for
you.
</p>
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
Thank you once again for joining us on this journey. Welcome to
the Walter community – we’re so happy to have you here!
</div>
<div style="font-weight:normal;padding:16px 24px 16px 24px">
Warm regards, Mikhail
</div>
{% endblock %}
Hi👋 I&#39;m Mikhail, creator of thewalter.app.

I hope this message finds you well! First and foremost, I want
to extend my heartfelt thanks for your patience and enthusiasm.
It means the world to me that you’re excited to be a part of thewalter.app.

There only one thing left for you to is your account activation.

To activate our account, simply click the link below and follow the instructions:
<a href="{{ protocol }}://{{ site }}{% url 'django_registration_activate' %}?activation_key={{activation_key}}"
target="_blank"
>Activate an account</a>

If you have any questions or need assistance, don&#39;t hesitate to reach out to me directly via
<a href="https://t.me/mrmike24" target="_blank">Telegram</a> or <a href="https://x.com/mrmegatelo" target="_blank">Twitter</a>.
Your feedback is invaluable as the service continues to improve.
I genuinely look forward to hearing about your experiences and how thewalter.app is making a difference for you.

Thank you once again for joining us on this journey. Welcome to the Walter community – we’re so happy to have you here!

Warm regards, Mikhail
2 changes: 1 addition & 1 deletion feed/templates/django_registration/registration_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% block main %}
<div class="centered-form-wrapper">
{% include 'blocks/page-heading.html' with title=title %}
<form class="form" action="{% url 'django_registration_register' %}" method="post">
<form class="form" action="{% url 'register' %}" method="post">
{% csrf_token %}
{{ form.as_div }}
<button class="button button--primary flex-column-button-container" type="submit">{% translate 'Sign up' noop %}</button>
Expand Down
2 changes: 1 addition & 1 deletion feed/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="landing-caption-hero">
<h1 class="heading">{% translate 'The only feed you need.' noop %}</h1>
<p class="paragraph">{% translate 'Get what matters, skip the rest.' noop %}</p>
<a class="button button--primary" href="{% url 'django_registration_register' %}">{% translate 'Get started' noop %}</a>
<a class="button button--primary" href="{% url 'register' %}">{% translate 'Get started' noop %}</a>
</div>
<video src="{% static 'feed/videos/main.mp4' %}" width="858" height="484"
class="landing-caption__video"
Expand Down
9 changes: 2 additions & 7 deletions feed/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
),
path("profile/", include("django_registration.backends.activation.urls")),
path("profile/", include("django.contrib.auth.urls")),
path("profile/register/", anonym_required(views.profile.RegistrationView.as_view()), name="register"),
# Invite accept URLs
path(
"profile/invite/<uidb64>/<token>/set_username",
Expand Down Expand Up @@ -123,13 +124,7 @@
),
name="invite_accept_complete",
),
# Waitlist URLs
# path("profile/registration/", feed.views.waitlist.WaitlistView.as_view(), name="registration"),
# path(
# "profile/registration/success/",
# feed.views.waitlist.WaitlistSuccessView.as_view(),
# name="registration_success",
# ),

# API URLs
path(
"api/v1/subscriptions",
Expand Down
3 changes: 2 additions & 1 deletion feed/views/profile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import index, edit, invite_username
from .registration import RegistrationView

__all__ = ['index', 'edit', 'invite_username']
__all__ = ['index', 'edit', 'invite_username', 'RegistrationView']
40 changes: 40 additions & 0 deletions feed/views/profile/registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.core.mail import send_mail
from django.template.loader import render_to_string
from django_registration.backends.activation.views import RegistrationView as BaseRegistrationView
from django.conf import settings


class RegistrationView(BaseRegistrationView):

def send_activation_email(self, user):
"""
Custom method to enable HTML activation emails.
"""
activation_key = self.get_activation_key(user)
context = self.get_email_context(activation_key)
context['user'] = user
subject = render_to_string(
template_name=self.email_subject_template,
context=context,
request=self.request
)
# Force subject to a single line to avoid header-injection
# issues.
subject = ''.join(subject.splitlines())
text_content = render_to_string(
template_name='activation_email_body.txt',
context=context,
request=self.request
)
html_content = render_to_string(
template_name='activation_email_body.html',
context=context,
request=self.request
)
send_mail(
subject,
text_content,
settings.DEFAULT_FROM_EMAIL,
[user.email],
html_message=html_content
)

0 comments on commit 9b2ed0e

Please sign in to comment.