stages/email: add field to select E-Mail and subject
This commit is contained in:
parent
b907105f4a
commit
615cd7870d
|
@ -0,0 +1 @@
|
||||||
|
github: [BeryJu]
|
|
@ -22,6 +22,9 @@ class EmailStageSerializer(ModelSerializer):
|
||||||
"use_ssl",
|
"use_ssl",
|
||||||
"timeout",
|
"timeout",
|
||||||
"from_address",
|
"from_address",
|
||||||
|
"token_expiry",
|
||||||
|
"subject",
|
||||||
|
"template",
|
||||||
]
|
]
|
||||||
extra_kwargs = {"password": {"write_only": True}}
|
extra_kwargs = {"password": {"write_only": True}}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ class EmailStageForm(forms.ModelForm):
|
||||||
"use_ssl",
|
"use_ssl",
|
||||||
"timeout",
|
"timeout",
|
||||||
"from_address",
|
"from_address",
|
||||||
|
"token_expiry",
|
||||||
|
"subject",
|
||||||
|
"template",
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
"name": forms.TextInput(),
|
"name": forms.TextInput(),
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Generated by Django 3.0.5 on 2020-05-15 12:42
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_stages_email", "0002_auto_20200510_1844"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="emailstage",
|
||||||
|
name="subject",
|
||||||
|
field=models.TextField(default="passbook"),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="emailstage",
|
||||||
|
name="template",
|
||||||
|
field=models.TextField(
|
||||||
|
choices=[
|
||||||
|
("stages/email/for_email/password_reset.html", "Password Reset"),
|
||||||
|
(
|
||||||
|
"stages/email/for_email/account_confirmation.html",
|
||||||
|
"Account Confirmation",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
default="stages/email/for_email/password_reset.html",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -7,6 +7,19 @@ from django.utils.translation import gettext as _
|
||||||
from passbook.flows.models import Stage
|
from passbook.flows.models import Stage
|
||||||
|
|
||||||
|
|
||||||
|
class EmailTemplates(models.TextChoices):
|
||||||
|
"""Templates used for rendering the E-Mail"""
|
||||||
|
|
||||||
|
PASSWORD_RESET = (
|
||||||
|
"stages/email/for_email/password_reset.html",
|
||||||
|
_("Password Reset"),
|
||||||
|
) # nosec
|
||||||
|
ACCOUNT_CONFIRM = (
|
||||||
|
"stages/email/for_email/account_confirmation.html",
|
||||||
|
_("Account Confirmation"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EmailStage(Stage):
|
class EmailStage(Stage):
|
||||||
"""email stage"""
|
"""email stage"""
|
||||||
|
|
||||||
|
@ -17,12 +30,15 @@ class EmailStage(Stage):
|
||||||
use_tls = models.BooleanField(default=False)
|
use_tls = models.BooleanField(default=False)
|
||||||
use_ssl = models.BooleanField(default=False)
|
use_ssl = models.BooleanField(default=False)
|
||||||
timeout = models.IntegerField(default=10)
|
timeout = models.IntegerField(default=10)
|
||||||
|
from_address = models.EmailField(default="system@passbook.local")
|
||||||
|
|
||||||
token_expiry = models.IntegerField(
|
token_expiry = models.IntegerField(
|
||||||
default=30, help_text=_("Time in minutes the token sent is valid.")
|
default=30, help_text=_("Time in minutes the token sent is valid.")
|
||||||
)
|
)
|
||||||
|
subject = models.TextField(default="passbook")
|
||||||
from_address = models.EmailField(default="system@passbook.local")
|
template = models.TextField(
|
||||||
|
choices=EmailTemplates.choices, default=EmailTemplates.PASSWORD_RESET
|
||||||
|
)
|
||||||
|
|
||||||
type = "passbook.stages.email.stage.EmailStageView"
|
type = "passbook.stages.email.stage.EmailStageView"
|
||||||
form = "passbook.stages.email.forms.EmailStageForm"
|
form = "passbook.stages.email.forms.EmailStageForm"
|
||||||
|
|
|
@ -54,7 +54,7 @@ class EmailStageView(FormView, AuthenticationStage):
|
||||||
# Send mail to user
|
# Send mail to user
|
||||||
message = TemplateEmailMessage(
|
message = TemplateEmailMessage(
|
||||||
subject=_("passbook - Password Recovery"),
|
subject=_("passbook - Password Recovery"),
|
||||||
template_name="stages/email/for_email/password_reset.html",
|
template_name=self.executor.current_stage.template,
|
||||||
to=[pending_user.email],
|
to=[pending_user.email],
|
||||||
template_context={
|
template_context={
|
||||||
"url": self.get_full_url(**{QS_KEY_TOKEN: nonce.pk.hex}),
|
"url": self.get_full_url(**{QS_KEY_TOKEN: nonce.pk.hex}),
|
||||||
|
|
|
@ -3,82 +3,36 @@
|
||||||
{% load inline %}
|
{% load inline %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block pre_header %}
|
|
||||||
{% trans "We're thrilled to have you here! Get ready to dive into your new account." %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<!-- HERO -->
|
<td>
|
||||||
<tr>
|
<h2>
|
||||||
<td bgcolor="#3625b7" align="center" style="padding: 0px 10px 0px 10px;">
|
{% trans 'Welcome!' %}
|
||||||
<table border="0" cellpadding="0" cellspacing="0" width="480">
|
</h2>
|
||||||
<tr>
|
<p>
|
||||||
<td bgcolor="#566572" align="center" valign="top"
|
{% trans "We're excited to have you get started. First, you need to confirm your account. Just press the button below."%}
|
||||||
style="padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #8F9BA3; font-family: 'Metropolis', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
|
</p>
|
||||||
<h1 style="font-size: 32px; font-weight: 400; margin: 0; color: #E9ECEF;">{% trans 'Welcome!' %}
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="btn btn-primary">
|
||||||
</h1>
|
<tbody>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<td align="center">
|
||||||
</table>
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||||
</td>
|
<tbody>
|
||||||
</tr>
|
<tr>
|
||||||
<!-- COPY BLOCK -->
|
<td> <a href="{{ url }}" target="_blank">{% trans 'Confirm Account' %}</a> </td>
|
||||||
<tr>
|
</tr>
|
||||||
<td bgcolor="#1b2a32" align="center" style="padding: 0px 10px 0px 10px;">
|
</tbody>
|
||||||
<table border="0" cellpadding="0" cellspacing="0" width="480">
|
</table>
|
||||||
<!-- COPY -->
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td bgcolor="#566572" align="left"
|
</tbody>
|
||||||
style="padding: 20px 30px 40px 30px; color: #E9ECEF; font-family: 'Metropolis', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
|
</table>
|
||||||
<p style="margin: 0;">
|
<p>
|
||||||
{% trans "We're excited to have you get started. First, you need to confirm your account. Just press the button below."%}
|
{% blocktrans with url=url %}
|
||||||
</p>
|
If that doesn't work, copy and paste the following link in your browser: {{ url }}
|
||||||
</td>
|
{% endblocktrans %}
|
||||||
</tr>
|
</p>
|
||||||
<!-- BULLETPROOF BUTTON -->
|
<p>
|
||||||
<tr>
|
{% trans "If you have any questions, just reply to this email—we're always happy to help out." %}
|
||||||
<td bgcolor="#566572" align="left">
|
</p>
|
||||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
</td>
|
||||||
<tr>
|
|
||||||
<td bgcolor="#566572" align="center" style="padding: 20px 30px 60px 30px;">
|
|
||||||
<table border="0" cellspacing="0" cellpadding="0">
|
|
||||||
<tr>
|
|
||||||
<td align="center" style="border-radius: 3px;" bgcolor="#3625b7"><a
|
|
||||||
href="{{ url }}" target="_blank"
|
|
||||||
style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; color: #ffffff; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #3625b7; display: inline-block;">{% trans 'Confirm Account' %}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<!-- COPY -->
|
|
||||||
<tr>
|
|
||||||
<td bgcolor="#566572" align="left"
|
|
||||||
style="padding: 0px 30px 0px 30px; color: #E9ECEF; font-family: 'Metropolis', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
|
|
||||||
<p style="margin: 0;">
|
|
||||||
{% trans "If that doesn't work, copy and paste the following link in your browser:" %}</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<!-- COPY -->
|
|
||||||
<tr>
|
|
||||||
<td bgcolor="#566572" align="left"
|
|
||||||
style="padding: 20px 30px 20px 30px; color: #E9ECEF; font-family: 'Metropolis', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
|
|
||||||
<p style="margin: 0;"><a href="{{ url }}" target="_blank" style="color: #3625b7;">{{ url }}</a></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<!-- COPY -->
|
|
||||||
<tr>
|
|
||||||
<td bgcolor="#566572" align="left"
|
|
||||||
style="padding: 0px 30px 20px 30px; color: #E9ECEF; font-family: 'Metropolis', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
|
|
||||||
<p style="margin: 0;">
|
|
||||||
{% trans "If you have any questions, just reply to this email—we're always happy to help out." %}
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -37,5 +37,4 @@
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
16
swagger.yaml
16
swagger.yaml
|
@ -5903,6 +5903,22 @@ definitions:
|
||||||
format: email
|
format: email
|
||||||
maxLength: 254
|
maxLength: 254
|
||||||
minLength: 1
|
minLength: 1
|
||||||
|
token_expiry:
|
||||||
|
title: Token expiry
|
||||||
|
description: Time in minutes the token sent is valid.
|
||||||
|
type: integer
|
||||||
|
maximum: 2147483647
|
||||||
|
minimum: -2147483648
|
||||||
|
subject:
|
||||||
|
title: Subject
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
template:
|
||||||
|
title: Template
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- stages/email/for_email/password_reset.html
|
||||||
|
- stages/email/for_email/account_confirmation.html
|
||||||
IdentificationStage:
|
IdentificationStage:
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
|
|
Reference in New Issue