From 05f4cfc55a6473cb438ce0059d6d37f913abcb01 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 22 Mar 2013 23:29:55 +0000 Subject: Began creating templates for login/registration --- wqflask/cfg/default_settings.py | 7 +++- wqflask/secure_server.py | 24 +++--------- wqflask/wqflask/templates/security/_macros.html | 16 ++++++++ wqflask/wqflask/templates/security/_menu.html | 15 ++++++++ wqflask/wqflask/templates/security/_messages.html | 9 +++++ .../wqflask/templates/security/register_user.html | 45 ++++++++++++++++++++++ 6 files changed, 96 insertions(+), 20 deletions(-) create mode 100644 wqflask/wqflask/templates/security/_macros.html create mode 100644 wqflask/wqflask/templates/security/_menu.html create mode 100644 wqflask/wqflask/templates/security/_messages.html create mode 100644 wqflask/wqflask/templates/security/register_user.html (limited to 'wqflask') diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index 53b5a96e..a575a3bd 100644 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -4,5 +4,8 @@ LOGFILE = """/tmp/flask_gn_log""" #400 bad request response with no exception/log TRAP_BAD_REQUEST_ERRORS = True -#SECURITY_CONFIRMABLE = True -SECURITY_TRACKABLE = True \ No newline at end of file +# http://pythonhosted.org/Flask-Security/configuration.html +SECURITY_CONFIRMABLE = True +SECURITY_TRACKABLE = True +SECURITY_REGISTERABLE = True +SECURITY_RECOVERABLE = True diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py index 49e0b433..425fce89 100644 --- a/wqflask/secure_server.py +++ b/wqflask/secure_server.py @@ -4,15 +4,8 @@ from wqflask import app from flask import Flask, render_template from flask.ext.sqlalchemy import SQLAlchemy -from flask.ext.security import Security, SQLAlchemyUserDatastore, \ - UserMixin, RoleMixin +from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin -# Create app -#app = Flask(__name__) -app.config['SECRET_KEY'] = 'LjfrbDOlvdFMT5cCi9qrJqStxK4NcmxW' -app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://webqtl:f2ZypIflRM@gn.cazhbciu2y1i.us-east-1.rds.amazonaws.com/db_webqtl' -#app.config['SECURITY_CONFIRMABLE'] = True -app.config['SECURITY_TRACKABLE'] = True # Create database connection object db = SQLAlchemy(app) @@ -48,19 +41,14 @@ user_datastore = SQLAlchemyUserDatastore(db, User, Role) security = Security(app, user_datastore) # Create a user to test with -#@app.before_first_request -def create_user(): - db.create_all() - user_datastore.create_user(email='matt@example.com', password='notebook') - db.session.commit() +##@app.before_first_request +#def create_user(): +# db.create_all() +# user_datastore.create_user(email='matt@example.com', password='notebook') +# db.session.commit() -## Views -#@app.route('/') -#def home(): -# return render_template('index.html') import logging -#from themodule import TheHandlerYouWant file_handler = logging.FileHandler("/tmp/flask_gn_log") file_handler.setLevel(logging.DEBUG) app.logger.addHandler(file_handler) diff --git a/wqflask/wqflask/templates/security/_macros.html b/wqflask/wqflask/templates/security/_macros.html new file mode 100644 index 00000000..8575f3db --- /dev/null +++ b/wqflask/wqflask/templates/security/_macros.html @@ -0,0 +1,16 @@ +{% macro render_field_with_errors(field) %} +

+ {{ field.label }} {{ field(**kwargs)|safe }} + {% if field.errors %} +

+ {% endif %} +

+{% endmacro %} + +{% macro render_field(field) %} +

{{ field(**kwargs)|safe }}

+{% endmacro %} \ No newline at end of file diff --git a/wqflask/wqflask/templates/security/_menu.html b/wqflask/wqflask/templates/security/_menu.html new file mode 100644 index 00000000..5291f809 --- /dev/null +++ b/wqflask/wqflask/templates/security/_menu.html @@ -0,0 +1,15 @@ +{% if security.registerable or security.recoverable or security.confirmabled %} +

Menu

+ +{% endif %} diff --git a/wqflask/wqflask/templates/security/_messages.html b/wqflask/wqflask/templates/security/_messages.html new file mode 100644 index 00000000..179d0636 --- /dev/null +++ b/wqflask/wqflask/templates/security/_messages.html @@ -0,0 +1,9 @@ +{%- with messages = get_flashed_messages(with_categories=true) -%} + {% if messages %} + + {% endif %} +{%- endwith %} \ No newline at end of file diff --git a/wqflask/wqflask/templates/security/register_user.html b/wqflask/wqflask/templates/security/register_user.html new file mode 100644 index 00000000..af87f810 --- /dev/null +++ b/wqflask/wqflask/templates/security/register_user.html @@ -0,0 +1,45 @@ +{% from "security/_macros.html" import render_field_with_errors, render_field %} +{% extends "base.html" %} +{% include "security/_messages.html" %} +{% block content %} + +
+
+
+ +
+
+
+ + +{% include "security/_menu.html" %} + +{% endblock %} + + \ No newline at end of file -- cgit v1.2.3