diff options
author | Sam | 2013-05-23 00:22:54 +0000 |
---|---|---|
committer | Sam | 2013-05-23 00:22:54 +0000 |
commit | 7eb9f5d12389df0ef7440a82df0be9bd1119847e (patch) | |
tree | 3e81009fa50e1de0bdb10064695cb6179eb94be6 /wqflask/wqflask | |
parent | 66e8d76ea34b6784a451abe3223eb13107d4307f (diff) | |
download | genenetwork2-7eb9f5d12389df0ef7440a82df0be9bd1119847e.tar.gz |
Lots of changes around users
Diffstat (limited to 'wqflask/wqflask')
-rw-r--r-- | wqflask/wqflask/model.py | 28 | ||||
-rw-r--r-- | wqflask/wqflask/templates/admin/user_manager.html | 6 | ||||
-rw-r--r-- | wqflask/wqflask/templates/security/email/confirmation_instructions.html | 4 | ||||
-rw-r--r-- | wqflask/wqflask/templates/security/email/confirmation_instructions.txt | 4 | ||||
-rw-r--r-- | wqflask/wqflask/templates/security/email/welcome.html | 4 | ||||
-rw-r--r-- | wqflask/wqflask/templates/security/email/welcome.txt | 4 | ||||
-rw-r--r-- | wqflask/wqflask/user_manager.py | 14 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 9 |
8 files changed, 64 insertions, 9 deletions
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''' |