From 2138e6b9d91bd3a109e202b9ad2029a737f374e6 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Aug 2013 16:57:19 -0500 Subject: Working on user registration and added nginx conf for my branch --- wqflask/other_config/nginx_conf/sam.conf | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 wqflask/other_config/nginx_conf/sam.conf (limited to 'wqflask') diff --git a/wqflask/other_config/nginx_conf/sam.conf b/wqflask/other_config/nginx_conf/sam.conf new file mode 100644 index 00000000..3cc443a8 --- /dev/null +++ b/wqflask/other_config/nginx_conf/sam.conf @@ -0,0 +1,42 @@ +server { + # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/ + listen 80; + + server_name sam.genenetwork.org; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + location ^~ /css/ { + root /gene/wqflask/wqflask/static/; + } + + location ^~ /javascript/ { + root /gene/wqflask/wqflask/static/; + } + +# location ^~ /image/ { +# root /gene/wqflask/wqflask/static/; +# } + + location ^~ /images/ { + root /gene/wqflask/wqflask/static/; + } + + ### New - added by Sam + #location ^~ /static/ { + # root /gene/wqflask/wqflask/static/; + #} + + location / { + proxy_pass http://127.0.0.1:5555/; + proxy_redirect off; + + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_read_timeout 40m; + } +} + -- cgit v1.2.3 From f2e41174a7e2091e7e835b137c6c7e2874feda04 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Aug 2013 17:38:55 -0500 Subject: Finally figured out where to put flask_security into the code Various registration template changes --- wqflask/flask_security/__init__.py | 4 ++-- wqflask/secure_server.py | 3 +++ wqflask/wqflask/model.py | 14 +++++++++++++- wqflask/wqflask/templates/admin/ind_user_manager.html | 10 ++++++++++ wqflask/wqflask/templates/security/register_user.html | 16 +++++++++++++++- 5 files changed, 43 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/flask_security/__init__.py b/wqflask/flask_security/__init__.py index 297033c9..81e6c89e 100644 --- a/wqflask/flask_security/__init__.py +++ b/wqflask/flask_security/__init__.py @@ -12,8 +12,6 @@ __version__ = '1.6.0' -print "using internal flask security" - from .core import Security, RoleMixin, UserMixin, AnonymousUser, current_user from .datastore import SQLAlchemyUserDatastore, MongoEngineUserDatastore, PeeweeUserDatastore from .decorators import auth_token_required, http_auth_required, \ @@ -23,3 +21,5 @@ from .forms import ForgotPasswordForm, LoginForm, RegisterForm, \ from .signals import confirm_instructions_sent, password_reset, \ reset_password_instructions_sent, user_confirmed, user_registered from .utils import login_user, logout_user, url_for_security + +print "Using our own flask.ext.security" \ No newline at end of file diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py index 2abfdb05..04b85663 100644 --- a/wqflask/secure_server.py +++ b/wqflask/secure_server.py @@ -25,6 +25,9 @@ app.logger.addHandler(file_handler) import logging_tree logging_tree.printout() +import sys +print("At startup, path is:", sys.path) + #print("app.config is:", app.config) if __name__ == '__main__': diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index 5beba9ff..1f873545 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -3,6 +3,9 @@ from __future__ import print_function, division, absolute_import from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin +from flask_security.forms import TextField +from flask_security.forms import RegisterForm + from wqflask import app # Create database connection object @@ -46,6 +49,10 @@ 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)) + + name = db.Column(db.Unicode(255)) + organization = db.Column(db.Unicode(255)) + active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) @@ -60,7 +67,12 @@ class User(db.Model, UserMixin): # Setup Flask-Security user_datastore = SQLAlchemyUserDatastore(db, User, Role) -security = Security(app, user_datastore) + +class ExtendedRegisterForm(RegisterForm): + name = TextField('name') + organization = TextField('organization') + +security = Security(app, user_datastore, register_form=ExtendedRegisterForm) db.metadata.create_all(db.engine) diff --git a/wqflask/wqflask/templates/admin/ind_user_manager.html b/wqflask/wqflask/templates/admin/ind_user_manager.html index 9776af0b..2fe4a002 100644 --- a/wqflask/wqflask/templates/admin/ind_user_manager.html +++ b/wqflask/wqflask/templates/admin/ind_user_manager.html @@ -30,6 +30,16 @@