Skip to content

Commit

Permalink
asynchronous email #20 & better login page
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyphantom committed Mar 24, 2019
1 parent 589c9bc commit 36243cb
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 54 deletions.
8 changes: 6 additions & 2 deletions app/email.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from flask import render_template
from flask_mail import Message
from threading import Thread
from app import app, mail # mail = flask_mail.Mail(app)

def send_async_email(app, msg):
with app.app_context():
mail.send(msg)

def send_email(subject, sender, recipients, text_body, html_body):
msg = Message(subject, sender=sender, recipients=recipients)
msg.body = text_body
msg.html = html_body
mail.send(msg)
Thread(target=send_async_email, args=(app, msg)).start()

def send_pw_reset_email(user):
token = user.get_reset_password_token()
Expand All @@ -18,4 +23,3 @@ def send_pw_reset_email(user):
html_body=render_template('email/reset_password.html',
user=user, token=token))


18 changes: 18 additions & 0 deletions app/static/css/pedagogy.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,22 @@ input[type=range]::-moz-range-thumb {

textarea#comments {
height: 120px;
}

/* List items*/

dt {
color: #273f52;
}

dd {
color: white;
}

#submit {
background: rgb(2, 73, 109);
border-radius: 8%;
border: none;
padding: 1% 2.5%;
color: white;
}
83 changes: 59 additions & 24 deletions app/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,67 @@

{% block content %}
<div class="jumbotron">
<h1>Sign In</h1>
<form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<p>
{{ form.email.label }}<br/>
{{ form.email(size=32) }}
<div class="row">
<h1 class="display-4">Sign In</h1>
</div>
<div class="row">
<div class="col-md-10 col-lg-6 col-sm-10 mt-4">
<form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<p>
{{ form.email.label }}<br/>
{{ form.email(size=42) }}

{% for error in form.email.errors %}
<span style="color:red">{{ error }}</span>
{% endfor %}
</p>
<p>
{{ form.password.label }}<br/>
{{ form.password(size=42) }}

{% for error in form.password.errors %}
<span style="color:red">{{ error }}</span>
{% endfor %}
</p>
<p>{{ form.remember_me() }} {{ form.remember_me.label() }}</p>
<p>{{ form.submit() }}</p>
</form>
<p>Forgot your password?
<a href="{{ url_for('reset_password_request') }}" class="text-warning">Reset password here</a>
</p>
</div>
<div class="col-md-10 col-lg-5 col-sm-10">
<h4>Feedback-driven performance management</h4>
<p style="margin-right:2%">
Join algoritma's production team (consultants / instructors) to gain full access to Pedagogy.
<dl>
<dt>Regional</dt>
<dd>Work with 50+ companies across SEA: Indonesia, Singapore, and Thailand. Broaden
your skill set and perspective by immersing in a culturally diverse team.
</dd>

{% for error in form.email.errors %}
<span style="color:red">{{ error }}</span>
{% endfor %}
</p>
<p>
{{ form.password.label }}<br/>
{{ form.password(size=32) }}
<dt>Develop</dt>
<dd>Through intensive training, exposure, and holistic training programs, continue to
hone and develop the necessary skill to be a highly effective public consultant and data professional.
</dd>

<dt>Freedom</dt>
<dd>Choose your own progression path, your growth
direction, your week-to-week activities and focus. Our environment doesn't just <i>allow</i> that. We
<i>support</i> it.
</dd>
</dl>
</p>
<small>
Got a feature request? Encountered a bug? <a href="http://github.com/onlyphantom/pedagogy/issues" class="text-warning">Open an issue on the GitHub repo.</a>
</small>
</div>
</div>




{% for error in form.password.errors %}
<span style="color:red">{{ error }}</span>
{% endfor %}
</p>
<p>{{ form.remember_me() }} {{ form.remember_me.label() }}</p>
<p>{{ form.submit() }}</p>
</form>
<p>
Forgot your password?
<a href="{{ url_for('reset_password_request') }}" class="text-warning">Reset password here</a>
</p>
</div>

{% endblock %}
Expand Down
86 changes: 58 additions & 28 deletions app/templates/register.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,66 @@
{% extends "base.html" %}

{% block content %}
<div class="jumbotron jumbo-mini">
<h1>Register Form</h1>
<form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<p>
{{ form.email.label }}<br/>
{{ form.email(size=32) }}
<div class="jumbotron">
<div class="row">
<h1 class="display-4">Account Registration</h1>
</div>
<div class="row">
<div class="col-md-10 col-lg-6 col-sm-10 mt-4">
<form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<p>
{{ form.email.label }}<br/>
{{ form.email(size=32) }}

{% for error in form.email.errors %}
{{ error }}
{% endfor %}
</p>
<p>
{{ form.password.label }}<br/>
{{ form.password(size=32) }}

{% for error in form.password.errors %}
{{ error }}
{% endfor %}
</p>
<p>
{{ form.password2.label }}<br/>
{{ form.password2(size=32) }}

{% for error in form.password2.errors %}
{{ error }}
{% endfor %}
</p>
<p>{{ form.submit() }}</p>
</form>
</div>
<div class="col-md-10 col-lg-5 col-sm-10">
<h4>Feedback-driven performance management</h4>
<p style="margin-right:2%">
Join algoritma's production team (consultants / instructors) to gain full access to Pedagogy.
<dl>
<dt>Regional</dt>
<dd>Work with 50+ companies across SEA: Indonesia, Singapore, and Thailand. Broaden
your skill set and perspective by immersing in a culturally diverse team.
</dd>

{% for error in form.email.errors %}
{{ error }}
{% endfor %}
</p>
<p>
{{ form.password.label }}<br/>
{{ form.password(size=32) }}
<dt>Develop</dt>
<dd>Through intensive training, exposure, and holistic training programs, continue to
hone and develop the necessary skill to be a highly effective public consultant and data professional.
</dd>

{% for error in form.password.errors %}
{{ error }}
{% endfor %}
</p>
<p>
{{ form.password2.label }}<br/>
{{ form.password2(size=32) }}

{% for error in form.password2.errors %}
{{ error }}
{% endfor %}
</p>
<p>{{ form.submit() }}</p>
</form>
<dt>Freedom</dt>
<dd>Choose your own progression path, your growth
direction, your week-to-week activities and focus. Our environment doesn't just <i>allow</i> that. We
<i>support</i> it.
</dd>
</dl>
</p>
</div>
</div>

</div>
{% endblock %}

0 comments on commit 36243cb

Please sign in to comment.