Users are allowed to register now
This includes sending a welcome email.
This commit is contained in:
parent
2e0fc3b772
commit
1240a3c64b
|
@ -7,5 +7,6 @@ RUN pip3 install -r /requirements.txt; \
|
|||
ADD app /app
|
||||
|
||||
VOLUME ["/data"]
|
||||
VOLUME ["/app/config]
|
||||
EXPOSE 5000
|
||||
ENTRYPOINT python3 /app/main.py
|
||||
|
|
12
README.md
12
README.md
|
@ -3,6 +3,14 @@
|
|||
## build
|
||||
`docker build --tag=$(basename $PWD) .`
|
||||
|
||||
## general configuration
|
||||
|
||||
Look at *app/config/email.py.example** for the configuration of the
|
||||
parameters required for sending emails. Copy the file as *email.py* to
|
||||
a folder that will serve as configuration directory and fill in the
|
||||
information. The directory will be used as volume during container
|
||||
operation.
|
||||
|
||||
## run in development
|
||||
|
||||
Include the development version of the code as volume, so the app gets
|
||||
|
@ -10,7 +18,7 @@ reloaded automatically. The sqlite file will be stored in *tmp* so it
|
|||
can be inspected with tools like *sqlite3*. The switch *DEBUG* enables
|
||||
debugging during development.
|
||||
|
||||
`docker run --name rollerverbrauch -ti -v `pwd`/app:/app -v /tmp/pitstops/:/data -e DEBUG=True -p 5000:5000 rollerverbrauch`
|
||||
`docker run --rm --name rollerverbrauch -ti -v `pwd`/app:/app -v `pwd`/../rollerverbrauch_config:/app/config -v /tmp/pitstops/:/data -e DEBUG=True -p 5000:5000 rollerverbrauch`
|
||||
|
||||
## run in production
|
||||
`docker run --name pitstops -d -v /data/pitstops/:/data -p 80:5000 rollerverbrauch`
|
||||
`docker run --name pitstops -d -v /data/pitstops/:/data -v /configs/pitstops/:/app/config -p 80:5000 rollerverbrauch`
|
||||
|
|
10
app/main.py
10
app/main.py
|
@ -1,5 +1,4 @@
|
|||
from datetime import date
|
||||
from datetime import datetime
|
||||
from flask import Flask
|
||||
from flask import render_template, make_response
|
||||
from flask import request, redirect, g
|
||||
|
@ -7,9 +6,7 @@ from flask import url_for
|
|||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask.ext.security import Security, SQLAlchemyUserDatastore, \
|
||||
UserMixin, RoleMixin, login_required, utils
|
||||
import uuid
|
||||
import hashlib
|
||||
from functools import wraps
|
||||
from flask.ext.mail import Mail, Message
|
||||
from flask_wtf import Form
|
||||
from wtforms import DateField, IntegerField, DecimalField
|
||||
from wtforms.validators import DataRequired, ValidationError
|
||||
|
@ -23,8 +20,12 @@ db = SQLAlchemy(app)
|
|||
app.config['SECRET_KEY'] = 'development key'
|
||||
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
|
||||
app.config['SECURITY_PASSWORD_SALT'] = 'xxxxxxxxxxxxxxxxxxxxxx'
|
||||
app.config['SECURITY_REGISTERABLE'] = True
|
||||
app.config['SECURITY_EMAIL_SENDER'] = 'pitstops@lusiardi.de'
|
||||
app.config.from_object('config.email')
|
||||
app.config.from_object(__name__)
|
||||
|
||||
mail = Mail(app)
|
||||
|
||||
roles_users = db.Table('roles_users',
|
||||
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
|
||||
|
@ -77,6 +78,7 @@ class Pitstop(db.Model):
|
|||
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
|
||||
security = Security(app, user_datastore)
|
||||
|
||||
|
||||
@app.before_first_request
|
||||
def before_first_request():
|
||||
db.create_all()
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
{% macro navigation() -%}
|
||||
<li><a href='{{ url_for('create_pit_stop_form') }}'>Create Pitstop</a></li>
|
||||
<li><a href='{{ url_for('get_statistics') }}'>Statistics</a></li>
|
||||
<li><a href='{{ url_for('get_manual') }}'>Manual</a></li>
|
||||
{% if current_user.email %}
|
||||
<li><a href='{{ url_for('create_pit_stop_form') }}'>Create Pitstop</a></li>
|
||||
<li><a href='{{ url_for('get_statistics') }}'>Statistics</a></li>
|
||||
<li><a href='{{ url_for('get_manual') }}'>Manual</a></li>
|
||||
<li><a href='{{ url_for('security.logout') }}'>Logout</a></li>
|
||||
{% else %}
|
||||
<li><a href='{{ url_for('security.login') }}'>Login</a></li>
|
||||
<li><a href='{{ url_for('security.register') }}'>Register</a></li>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
|
|
@ -10,5 +10,4 @@
|
|||
{{ render_field(login_user_form.next) }}
|
||||
{{ render_field(login_user_form.submit) }}
|
||||
</form>
|
||||
{% include "security/_menu.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{% extends "layout.html" %}
|
||||
{% from "security/_macros.html" import render_field_with_errors, render_field %}
|
||||
|
||||
{% block body %}
|
||||
<form class='form-horizontal' action="{{ url_for_security('register') }}" method="POST" name="register_user_form">
|
||||
{{ register_user_form.hidden_tag() }}
|
||||
{{ render_field_with_errors(register_user_form.email) }}
|
||||
{{ render_field_with_errors(register_user_form.password) }}
|
||||
{% if register_user_form.password_confirm %}
|
||||
{{ render_field_with_errors(register_user_form.password_confirm) }}
|
||||
{% endif %}
|
||||
{{ render_field(register_user_form.submit) }}
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue