From 1cf6894c7416f879fcd114ae7358bb7d4169a677 Mon Sep 17 00:00:00 2001
From: Sam
Date: Thu, 9 May 2013 22:28:22 +0000
Subject: Working on user registration
---
wqflask/secure_server.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'wqflask/secure_server.py')
diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py
index 5448dbeb..60f6db44 100644
--- a/wqflask/secure_server.py
+++ b/wqflask/secure_server.py
@@ -7,6 +7,11 @@ from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin
+# Setup mail
+from flask.ext.mail import Mail
+mail = Mail(app)
+
+
# Create database connection object
db = SQLAlchemy(app)
@@ -26,13 +31,13 @@ class User(db.Model, UserMixin):
password = db.Column(db.String(255))
active = db.Column(db.Boolean())
confirmed_at = db.Column(db.DateTime())
-
+
last_login_at = db.Column(db.DateTime())
current_login_at = db.Column(db.DateTime())
last_login_ip_= db.Column(db.String(39))
current_login_ip = db.Column(db.String(39))
login_count = db.Column(db.Integer())
-
+
roles = db.relationship('Role', secondary=roles_users,
backref=db.backref('users', lazy='dynamic'))
--
cgit v1.2.3
From 8ff6e6a1b7f4e435eb06130b82cce579bcd32dcc Mon Sep 17 00:00:00 2001
From: Sam
Date: Fri, 10 May 2013 01:31:50 +0000
Subject: Have the beginnings of a user_manager working
---
wqflask/secure_server.py | 35 +------------------
wqflask/wqflask/model.py | 39 ++++++++++++++++++++++
wqflask/wqflask/templates/admin/user_manager.html | 38 +++++++++++++++++++++
wqflask/wqflask/templates/base.html | 25 ++++++++------
wqflask/wqflask/templates/security/_macros.html | 2 +-
wqflask/wqflask/templates/security/login_user.html | 7 +++-
wqflask/wqflask/user_manager.py | 22 ++++++++++++
wqflask/wqflask/views.py | 25 +++++++++-----
8 files changed, 138 insertions(+), 55 deletions(-)
create mode 100644 wqflask/wqflask/model.py
create mode 100644 wqflask/wqflask/templates/admin/user_manager.html
create mode 100644 wqflask/wqflask/user_manager.py
(limited to 'wqflask/secure_server.py')
diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py
index 60f6db44..3487f35b 100644
--- a/wqflask/secure_server.py
+++ b/wqflask/secure_server.py
@@ -3,8 +3,6 @@ from __future__ import print_function, division, absolute_import
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
# Setup mail
@@ -12,38 +10,7 @@ from flask.ext.mail import Mail
mail = Mail(app)
-# Create database connection object
-db = SQLAlchemy(app)
-
-# Define models
-roles_users = db.Table('roles_users',
- db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
- db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
-
-class Role(db.Model, RoleMixin):
- id = db.Column(db.Integer(), primary_key=True)
- name = db.Column(db.String(80), unique=True)
- description = db.Column(db.String(255))
-
-class User(db.Model, UserMixin):
- id = db.Column(db.Integer(), primary_key=True)
- email = db.Column(db.String(255), unique=True)
- password = db.Column(db.String(255))
- active = db.Column(db.Boolean())
- confirmed_at = db.Column(db.DateTime())
-
- last_login_at = db.Column(db.DateTime())
- current_login_at = db.Column(db.DateTime())
- last_login_ip_= db.Column(db.String(39))
- current_login_ip = db.Column(db.String(39))
- login_count = db.Column(db.Integer())
-
- roles = db.relationship('Role', secondary=roles_users,
- backref=db.backref('users', lazy='dynamic'))
-
-# Setup Flask-Security
-user_datastore = SQLAlchemyUserDatastore(db, User, Role)
-security = Security(app, user_datastore)
+from wqflask.model import *
# Create a user to test with
##@app.before_first_request
diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py
new file mode 100644
index 00000000..be86ce77
--- /dev/null
+++ b/wqflask/wqflask/model.py
@@ -0,0 +1,39 @@
+from __future__ import print_function, division, absolute_import
+
+from flask.ext.sqlalchemy import SQLAlchemy
+from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin
+
+from wqflask import app
+
+# Create database connection object
+db = SQLAlchemy(app)
+
+# Define models
+roles_users = db.Table('roles_users',
+ db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
+ db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
+
+class Role(db.Model, RoleMixin):
+ id = db.Column(db.Integer(), primary_key=True)
+ name = db.Column(db.String(80), unique=True)
+ description = db.Column(db.String(255))
+
+class User(db.Model, UserMixin):
+ id = db.Column(db.Integer(), primary_key=True)
+ email = db.Column(db.String(255), unique=True)
+ password = db.Column(db.String(255))
+ active = db.Column(db.Boolean())
+ confirmed_at = db.Column(db.DateTime())
+
+ last_login_at = db.Column(db.DateTime())
+ current_login_at = db.Column(db.DateTime())
+ last_login_ip = db.Column(db.String(39))
+ current_login_ip = db.Column(db.String(39))
+ login_count = db.Column(db.Integer())
+
+ roles = db.relationship('Role', secondary=roles_users,
+ backref=db.backref('users', lazy='dynamic'))
+
+# Setup Flask-Security
+user_datastore = SQLAlchemyUserDatastore(db, User, Role)
+security = Security(app, user_datastore)
diff --git a/wqflask/wqflask/templates/admin/user_manager.html b/wqflask/wqflask/templates/admin/user_manager.html
new file mode 100644
index 00000000..c49f0d94
--- /dev/null
+++ b/wqflask/wqflask/templates/admin/user_manager.html
@@ -0,0 +1,38 @@
+{% extends "base.html" %}
+{% block title %}User Manager{% endblock %}
+{% block content %}
+
+ User Manager
+
Confirmed at | +Active | +|
---|---|---|
{{ user.email }} | +{{ user.confirmed_at }} | +{{ user.active }} | +
{{ field(**kwargs)|safe }}
-{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/wqflask/wqflask/templates/security/login_user.html b/wqflask/wqflask/templates/security/login_user.html index d781ce08..b5fcbfdc 100644 --- a/wqflask/wqflask/templates/security/login_user.html +++ b/wqflask/wqflask/templates/security/login_user.html @@ -5,8 +5,13 @@ {{ login_user_form.hidden_tag() }} {{ render_field_with_errors(login_user_form.email) }} {{ render_field_with_errors(login_user_form.password) }} + + {% if security.recoverable %} + Forgot your password?