diff --git a/ereuse_devicehub/forms.py b/ereuse_devicehub/forms.py index 2b2bce2d..6a537d6c 100644 --- a/ereuse_devicehub/forms.py +++ b/ereuse_devicehub/forms.py @@ -2,14 +2,7 @@ from flask import current_app as app from flask import g, render_template from flask_wtf import FlaskForm from werkzeug.security import generate_password_hash -from wtforms import ( - BooleanField, - EmailField, - PasswordField, - StringField, - TelField, - validators, -) +from wtforms import BooleanField, EmailField, PasswordField, StringField, validators from ereuse_devicehub.db import db from ereuse_devicehub.mail.sender import send_email @@ -117,14 +110,15 @@ class UserNewRegisterForm(FlaskForm): email = EmailField( 'Email Address', [validators.DataRequired(), validators.Length(min=6, max=35)] ) - password = PasswordField('Password', [validators.DataRequired()]) - password2 = PasswordField('Password', [validators.DataRequired()]) + password = PasswordField( + 'Password', [validators.DataRequired(), validators.Length(min=6, max=35)] + ) + password2 = PasswordField( + 'Password', [validators.DataRequired(), validators.Length(min=6, max=35)] + ) name = StringField( 'Name', [validators.DataRequired(), validators.Length(min=3, max=35)] ) - telephone = TelField( - 'Telephone', [validators.DataRequired(), validators.Length(min=9, max=35)] - ) error_messages = { 'invalid_login': ( @@ -171,7 +165,8 @@ class UserNewRegisterForm(FlaskForm): user = User(email=self.email.data, password=self.password.data, active=False) person = Person( - email=self.email.data, name=self.name.data, telephone=self.telephone.data + email=self.email.data, + name=self.name.data, ) user.individuals.add(person) @@ -189,17 +184,23 @@ class UserNewRegisterForm(FlaskForm): token = self._token url = f'https://{ host }/validate_user/{ token }' template = 'ereuse_devicehub/email_validation.txt' - message = render_template(template, url=url) - subject = "Validate email for register in Usody.com" + template_html = 'ereuse_devicehub/email_validation.html' + context = { + 'name': self.name.data, + 'host': host, + 'url': url, + } + subject = "Please activate your Usody account" + message = render_template(template, **context) + message_html = render_template(template_html, **context) - send_email(subject, [self.email.data], message) + send_email(subject, [self.email.data], message, html_body=message_html) def send_mail_admin(self, user): person = next(iter(user.individuals)) context = { 'email': person.email, 'name': person.name, - 'telephone': person.telephone, } template = 'ereuse_devicehub/email_admin_new_user.txt' message = render_template(template, **context) diff --git a/ereuse_devicehub/templates/ereuse_devicehub/email_admin_new_user.txt b/ereuse_devicehub/templates/ereuse_devicehub/email_admin_new_user.txt index 96759431..4b6344a2 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/email_admin_new_user.txt +++ b/ereuse_devicehub/templates/ereuse_devicehub/email_admin_new_user.txt @@ -1,4 +1,4 @@ -A new user has been registered. These are your data +A new user has been registered: + Name: {{ name }} -Telephone: {{ telephone }} Email: {{ email }} diff --git a/ereuse_devicehub/templates/ereuse_devicehub/email_validation.txt b/ereuse_devicehub/templates/ereuse_devicehub/email_validation.txt index daeaf7fd..760a1878 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/email_validation.txt +++ b/ereuse_devicehub/templates/ereuse_devicehub/email_validation.txt @@ -1,2 +1,7 @@ -Hello, you are register in Usody.com -Please for activate your account click in the next address: {{ url }} +Welcome to Usody.com, {{ name }}! + +Please confirm your account by clicking on the following link: {{ url }} + +-- +Plaça Eusebi Güell 6-7, Edifici Vèrtex (UPC), planta 0, Barcelona 08034, Spain +Associació Pangea – Coordinadora Comunicació per a la Cooperació - NIF: G-60437761 diff --git a/ereuse_devicehub/templates/ereuse_devicehub/user_registration.html b/ereuse_devicehub/templates/ereuse_devicehub/user_registration.html index 1e969a97..74df13a4 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/user_registration.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/user_registration.html @@ -1,6 +1,6 @@ {% extends "ereuse_devicehub/base.html" %} -{% block page_title %}Login{% endblock %} +{% block page_title %}Create your account{% endblock %} {% block body %}
@@ -12,8 +12,8 @@
@@ -22,9 +22,8 @@
-
Register as a new User
+
Create your account
{% if not form._token %} -

Enter an Email & password for to do a new register.

{% if form.form_errors %}

{% for error in form.form_errors %} @@ -38,8 +37,18 @@ {{ form.csrf_token }}

- - + + {% if form.name.errors %} +

+ {% for error in form.name.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+
Please enter your email.
{% if form.email.errors %}

@@ -51,23 +60,29 @@

- - +
+ + +
Please enter a password!
+ {% if form.password.errors %} +

+ {% for error in form.password.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %}
- - +
+ + +
Please enter a password again!
-
- -
- - - {% if form.name.errors %} + {% if form.password2.errors %}

- {% for error in form.name.errors %} + {% for error in form.password2.errors %} {{ error }}
{% endfor %}

@@ -75,29 +90,29 @@
- - - {% if form.telephone.errors %} -

- {% for error in form.telephone.errors %} - {{ error }}
- {% endfor %} -

- {% endif %} + Password must be at least 6 characters.
- + + I accept the + terms and + privacy policy + +
+ +
+

- You have account? do Login + Already have an account? Sign in

{% else %}
-
+
We have sent you a validation email.
Please check your email.
@@ -107,7 +122,9 @@
- Designed by BootstrapMade + Help | + Privacy | + Terms
@@ -118,4 +135,38 @@
-{% endblock body %} +{% endblock body %} diff --git a/ereuse_devicehub/templates/ereuse_devicehub/user_validation.html b/ereuse_devicehub/templates/ereuse_devicehub/user_validation.html index dde06b84..c48ac592 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/user_validation.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/user_validation.html @@ -12,8 +12,8 @@
- +
@@ -25,9 +25,9 @@
User is valid
-
- Your new user is activate.
- Now you can do Login and entry. +
+ You have successfully activated your account!
+ Sign in.
{% else %} @@ -51,7 +51,9 @@
- Designed by BootstrapMade + Help | + Privacy | + Terms