aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/cfg/default_settings.py4
-rw-r--r--wqflask/utility/formatting.py13
-rw-r--r--wqflask/wqflask/model.py28
-rw-r--r--wqflask/wqflask/templates/admin/user_manager.html6
-rw-r--r--wqflask/wqflask/templates/security/email/confirmation_instructions.html4
-rw-r--r--wqflask/wqflask/templates/security/email/confirmation_instructions.txt4
-rw-r--r--wqflask/wqflask/templates/security/email/welcome.html4
-rw-r--r--wqflask/wqflask/templates/security/email/welcome.txt4
-rw-r--r--wqflask/wqflask/user_manager.py14
-rw-r--r--wqflask/wqflask/views.py9
10 files changed, 80 insertions, 10 deletions
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 @@
<table class="table table-hover">
<thead>
<tr>
+ <th>ID</th>
<th>Email</th>
<th>Confirmed at</th>
<th>Active</th>
@@ -23,7 +24,10 @@
</thead>
{% for user in users %}
<tr>
- <td title="{{ user.__dict__ }}">{{ user.email }}</td>
+ <td title="{{ user.__dict__ }}">
+ <a href="{{ url_for('manage_user', user_id=user.id) }}">{{ user.id }}</a>
+ </td>
+ <td>{{ user.email }}</td>
<td>{{ user.confirmed_at }}</td>
<td>{{ user.active }}</td>
</tr>
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 @@
+<p>Welcome to GeneNetwork!</p>
+
<p>Please confirm your email through the link below:</p>
-<p><a href="{{ confirmation_link }}">Confirm my account</a></p> \ No newline at end of file
+<p><a href="{{ confirmation_link }}">Confirm my account</a></p>
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 @@
<p>Welcome {{ user.email }}!</p>
+<p>We hope you find GeneNetwork an amazing resource!</p>
+
{% if security.confirmable %}
<p>You can confirm your email through the link below:</p>
<p><a href="{{ confirmation_link }}">Confirm my account</a></p>
-{% 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'''