From 5bfe4e6c590bf0ade2312536f0f8e3ce055e2c75 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 22 Feb 2013 22:18:38 +0000 Subject: Added some to notes --- wqflask/cfg/zach_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask/cfg') diff --git a/wqflask/cfg/zach_settings.py b/wqflask/cfg/zach_settings.py index 8d3bf4ab..1970bd9c 100644 --- a/wqflask/cfg/zach_settings.py +++ b/wqflask/cfg/zach_settings.py @@ -2,4 +2,4 @@ LOGFILE = """/tmp/flask_gn_log""" TRAP_BAD_REQUEST_ERRORS = True -DB_URI = """mysql://webqtl:webqtl@localhost/db_webqtl_zas1024""" \ No newline at end of file +DB_URI = """mysql://webqtl:f2ZypIflRM@gn.cazhbciu2y1i.us-east-1.rds.amazonaws.com/db_webqtl""" -- cgit v1.2.3 From cd58c17faec400968cfe6a3595ebe02099edd691 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 22 Mar 2013 21:51:07 +0000 Subject: Removed zach_settings.py from git tracking Changed mysql password as a result of it being up on git before --- misc/notes.txt | 16 ++++++- wqflask/cfg/default_settings.py | 3 ++ wqflask/cfg/zach_settings.py | 5 -- wqflask/wqflask/my_pylmm/pylmmKinship.py | 2 +- wqflask/wqflask/templates/base.html | 82 ++++++++++++++++---------------- 5 files changed, 60 insertions(+), 48 deletions(-) delete mode 100644 wqflask/cfg/zach_settings.py (limited to 'wqflask/cfg') diff --git a/misc/notes.txt b/misc/notes.txt index 976573a6..cdd353ea 100644 --- a/misc/notes.txt +++ b/misc/notes.txt @@ -11,6 +11,9 @@ git add -A Get the default path being used when a command is typed: which _______ +Change default path python looks at when importing +export PYTHONPATH="/home/zas1024/gene/wqflask" + Get the paths checked when a user types a command: echo $PATH @@ -67,7 +70,11 @@ Deactivate virtual environment: deactivate (just type deactivate) To set WQFLASK_SETTINGS environment variable: -export WQFLASK_SETTINGS=~/gene/wqflask/cfg/zach_settings.py (or wherever file is located) +export WQFLASK_SETTINGS=~/zach_settings.py (or wherever file is located) + +zach_settings.py is the local config file with the DB_URI +default_settings.py is the config file with the configuration information that would apply +to any running instance of GeneNetwork To change screen environment variable (if man not working or to get color, for example): export TERM=screen @@ -84,6 +91,13 @@ python runserver.py =========================================== +Update user password: +use mysql; +UPDATE user SET password=PASSWORD('whatever') WHERE user='webqtl'; +FLUSH PRIVILEGES; + +=========================================== + Redis things Restart redis server: diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index 1811ccfd..53b5a96e 100644 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -3,3 +3,6 @@ LOGFILE = """/tmp/flask_gn_log""" #This is needed because Flask turns key errors into a #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 diff --git a/wqflask/cfg/zach_settings.py b/wqflask/cfg/zach_settings.py deleted file mode 100644 index 1970bd9c..00000000 --- a/wqflask/cfg/zach_settings.py +++ /dev/null @@ -1,5 +0,0 @@ -LOGFILE = """/tmp/flask_gn_log""" - -TRAP_BAD_REQUEST_ERRORS = True - -DB_URI = """mysql://webqtl:f2ZypIflRM@gn.cazhbciu2y1i.us-east-1.rds.amazonaws.com/db_webqtl""" diff --git a/wqflask/wqflask/my_pylmm/pylmmKinship.py b/wqflask/wqflask/my_pylmm/pylmmKinship.py index 403e739d..db1449a4 100644 --- a/wqflask/wqflask/my_pylmm/pylmmKinship.py +++ b/wqflask/wqflask/my_pylmm/pylmmKinship.py @@ -122,7 +122,7 @@ np.savetxt(outFile,K) if options.saveEig: if options.verbose: sys.stderr.write("Obtaining Eigendecomposition\n") - Kva,Kve = linalg.eigh(K) + Kva, Kve = linalg.eigh(K) if options.verbose: sys.stderr.write("Saving eigendecomposition to %s.[kva | kve]\n" % outFile) np.savetxt(outFile+".kva",Kva) diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 590f5789..71c12941 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -26,49 +26,49 @@ - {% block content %}{% endblock %} -- cgit v1.2.3 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/cfg') 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 From 34312cfacdcb5af450d33ac3b54d7c01a6a61788 Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Tue, 30 Apr 2013 22:15:38 +0000 Subject: Changed path to log file Added server port to configuration file --- wqflask/cfg/default_settings.py | 2 ++ wqflask/secure_server.py | 5 ++++- wqflask/wqflask/dataSharing/SharingInfo.py | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'wqflask/cfg') diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index a575a3bd..d0713e4d 100644 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -1,5 +1,7 @@ LOGFILE = """/tmp/flask_gn_log""" +SERVER_PORT = 5000 + #This is needed because Flask turns key errors into a #400 bad request response with no exception/log TRAP_BAD_REQUEST_ERRORS = True diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py index 425fce89..5448dbeb 100644 --- a/wqflask/secure_server.py +++ b/wqflask/secure_server.py @@ -49,16 +49,19 @@ security = Security(app, user_datastore) import logging -file_handler = logging.FileHandler("/tmp/flask_gn_log") +file_handler = logging.FileHandler(app.config['LOGFILE']) file_handler.setLevel(logging.DEBUG) app.logger.addHandler(file_handler) import logging_tree logging_tree.printout() +#print("app.config is:", app.config) + if __name__ == '__main__': #create_user() app.run(host='0.0.0.0', + port=app.config['SERVER_PORT'], use_debugger=False, threaded=True, use_reloader=True) diff --git a/wqflask/wqflask/dataSharing/SharingInfo.py b/wqflask/wqflask/dataSharing/SharingInfo.py index befc158a..41a75222 100755 --- a/wqflask/wqflask/dataSharing/SharingInfo.py +++ b/wqflask/wqflask/dataSharing/SharingInfo.py @@ -34,12 +34,12 @@ import requests from dbFunction import webqtlDatabaseFunction import SharingBody -import logging -logging.basicConfig(filename="/tmp/flask_gn_log", level=logging.INFO) - -_log = logging.getLogger("search") -_ch = logging.StreamHandler() -_log.addHandler(_ch) +#import logging +#logging.basicConfig(filename="/tmp/flask_gn_log", level=logging.INFO) +# +#_log = logging.getLogger("search") +#_ch = logging.StreamHandler() +#_log.addHandler(_ch) -- cgit v1.2.3 From 7eb9f5d12389df0ef7440a82df0be9bd1119847e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 23 May 2013 00:22:54 +0000 Subject: Lots of changes around users --- wqflask/cfg/default_settings.py | 4 +++- wqflask/utility/formatting.py | 13 ++++++++++ wqflask/wqflask/model.py | 28 +++++++++++++++++++++- wqflask/wqflask/templates/admin/user_manager.html | 6 ++++- .../security/email/confirmation_instructions.html | 4 +++- .../security/email/confirmation_instructions.txt | 4 +++- .../wqflask/templates/security/email/welcome.html | 4 +++- .../wqflask/templates/security/email/welcome.txt | 4 +++- wqflask/wqflask/user_manager.py | 14 ++++++++++- wqflask/wqflask/views.py | 9 +++++-- 10 files changed, 80 insertions(+), 10 deletions(-) (limited to 'wqflask/cfg') diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index d0713e4d..96f7f1a5 100644 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -3,7 +3,7 @@ LOGFILE = """/tmp/flask_gn_log""" SERVER_PORT = 5000 #This is needed because Flask turns key errors into a -#400 bad request response with no exception/log +#400 bad request response with no exception/log TRAP_BAD_REQUEST_ERRORS = True # http://pythonhosted.org/Flask-Security/configuration.html @@ -11,3 +11,5 @@ SECURITY_CONFIRMABLE = True SECURITY_TRACKABLE = True SECURITY_REGISTERABLE = True SECURITY_RECOVERABLE = True + +SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" diff --git a/wqflask/utility/formatting.py b/wqflask/utility/formatting.py index 52173417..e53dda22 100644 --- a/wqflask/utility/formatting.py +++ b/wqflask/utility/formatting.py @@ -10,6 +10,14 @@ def numify(number, singular=None, plural=None): >>> numify(9, 'book', 'books') 'nine books' + You can add capitalize to change the capitalization + >>> numify(9, 'book', 'books').capitalize() + 'Nine books' + + Or capitalize every word using title + >>> numify(9, 'book', 'books').title() + 'Nine Books' + >>> numify(15) '15' @@ -107,3 +115,8 @@ def commify(n): if cents: out += '.' + cents return out + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index 9f9267d9..296f1f0d 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -8,6 +8,30 @@ from wqflask import app # Create database connection object db = SQLAlchemy(app) +# Is this right? -Sam +#from sqlalchemy.ext.declarative import declarative_base +#Base = declarative_base() + +#@classmethod +#def get(cls, key): +# """Convenience get method using the primary key +# +# If record doesn't exist, returns None +# +# Allows the following: User.get('121') +# +# """ +# print("in get cls is:", cls) +# print(" key is {} : {}".format(type(key), key)) +# query = db.Model.query(cls) +# print("query is: ", query) +# record = query.get(key) +# return record +# +# +#print("db.Model is:", vars(db.Model)) +#db.Model.get = get + # Define models roles_users = db.Table('roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), @@ -38,5 +62,7 @@ class User(db.Model, UserMixin): user_datastore = SQLAlchemyUserDatastore(db, User, Role) security = Security(app, user_datastore) - db.metadata.create_all(db.engine) + + + diff --git a/wqflask/wqflask/templates/admin/user_manager.html b/wqflask/wqflask/templates/admin/user_manager.html index c49f0d94..14cd12e0 100644 --- a/wqflask/wqflask/templates/admin/user_manager.html +++ b/wqflask/wqflask/templates/admin/user_manager.html @@ -16,6 +16,7 @@ + @@ -23,7 +24,10 @@ {% for user in users %} - + + diff --git a/wqflask/wqflask/templates/security/email/confirmation_instructions.html b/wqflask/wqflask/templates/security/email/confirmation_instructions.html index 5082a9a8..239f670f 100644 --- a/wqflask/wqflask/templates/security/email/confirmation_instructions.html +++ b/wqflask/wqflask/templates/security/email/confirmation_instructions.html @@ -1,3 +1,5 @@ +

Welcome to GeneNetwork!

+

Please confirm your email through the link below:

-

Confirm my account

\ No newline at end of file +

Confirm my account

diff --git a/wqflask/wqflask/templates/security/email/confirmation_instructions.txt b/wqflask/wqflask/templates/security/email/confirmation_instructions.txt index fb435b55..babedd8b 100644 --- a/wqflask/wqflask/templates/security/email/confirmation_instructions.txt +++ b/wqflask/wqflask/templates/security/email/confirmation_instructions.txt @@ -1,3 +1,5 @@ +Welcome to GeneNetwork! + Please confirm your email through the link below: -{{ confirmation_link }} \ No newline at end of file +{{ confirmation_link }} diff --git a/wqflask/wqflask/templates/security/email/welcome.html b/wqflask/wqflask/templates/security/email/welcome.html index 55eaed61..3cb01ce0 100644 --- a/wqflask/wqflask/templates/security/email/welcome.html +++ b/wqflask/wqflask/templates/security/email/welcome.html @@ -1,7 +1,9 @@

Welcome {{ user.email }}!

+

We hope you find GeneNetwork an amazing resource!

+ {% if security.confirmable %}

You can confirm your email through the link below:

Confirm my account

-{% endif %} \ No newline at end of file +{% endif %} diff --git a/wqflask/wqflask/templates/security/email/welcome.txt b/wqflask/wqflask/templates/security/email/welcome.txt index fb6ee5b5..9a400686 100644 --- a/wqflask/wqflask/templates/security/email/welcome.txt +++ b/wqflask/wqflask/templates/security/email/welcome.txt @@ -1,7 +1,9 @@ Welcome {{ user.email }}! +We hope you find GeneNetwork an amazing resource! + {% if security.confirmable %} You can confirm your email through the link below: {{ confirmation_link }} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index 4d608dc7..97ba18a3 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -11,12 +11,24 @@ from wqflask import model from flask import Flask, g +from pprint import pformat as pf + #from app import db print("globals are:", globals()) -class UserManager(object): +class UsersManager(object): def __init__(self): self.users = model.User.query.all() print("Users are:", self.users) + + +class UserManager(object): + def __init__(self, kw): + self.user_id = int(kw['user_id']) + print("In UserManager locals are:", pf(locals())) + #self.user = model.User.get(user_id) + #print("user is:", user) + self.user = model.User.query.get(self.user_id) + print("user is:", self.user) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 63781c73..b59c3b34 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -239,11 +239,16 @@ def get_temp_data(): temp_uuid = request.args['key'] return flask.jsonify(temp_data.TempData(temp_uuid).get_all()) -@app.route("/users") +@app.route("/manage/users") def manage_users(): - template_vars = user_manager.UserManager() + template_vars = user_manager.UsersManager() return render_template("admin/user_manager.html", **template_vars.__dict__) +@app.route("/manage/user") +def manage_user(): + template_vars = user_manager.UserManager(request.args) + return render_template("admin/ind_user_manager.html", **template_vars.__dict__) + def json_default_handler(obj): '''Based on http://stackoverflow.com/a/2680060/1175849''' -- cgit v1.2.3
ID Email Confirmed at Active
{{ user.email }} + {{ user.id }} + {{ user.email }} {{ user.confirmed_at }} {{ user.active }}