Doc polish and such

This commit is contained in:
Matt Wright
2012-03-28 11:44:48 -04:00
parent 201ee5b708
commit 245914cc9a
4 changed files with 45 additions and 2 deletions
+8
View File
@@ -3,6 +3,14 @@ Flask-Security Changelog
Here you can see the full list of changes between each Flask-Security release.
Version 1.2.1
-------------
Released March 28th, 2012
- Added optional user model mixin parameter for datastores
- Added CreateRoleCommand to available Flask-Script commands
Version 1.2.0
-------------
+20
View File
@@ -28,6 +28,7 @@ Contents
* :ref:`overview`
* :ref:`installation`
* :ref:`getting-started`
* :ref:`additional-user-fields`
* :ref:`flask-script-commands`
* :ref:`api`
* :doc:`Changelog </changelog>`
@@ -153,6 +154,22 @@ specific role::
{$ endif %}
.. _additional-user-fields:
Additional User Fields
----------------------
If you'd like to add additional fields to the user model you can use a mixin
class that specifies your additional fields. The following is an example of
how you might do this::
db = SQLAlchemy(app)
class UserAccountMixin():
first_name = db.Column(db.String(120))
last_name = db.Column(db.String(120))
Security(app, SQLAlchemyUserDatastore(db, UserAccountMixin))
.. _flask-script-commands:
Flask-Script Commands
@@ -160,6 +177,7 @@ Flask-Script Commands
Flask-Security comes packed with a few Flask-Script commands. They are:
* :class:`flask.ext.security.script.CreateUserCommand`
* :class:`flask.ext.security.script.CreateRoleCommand`
* :class:`flask.ext.security.script.AddRoleCommand`
* :class:`flask.ext.security.script.RemoveRoleCommand`
* :class:`flask.ext.security.script.DeactivateUserCommand`
@@ -236,9 +254,11 @@ Datastores
.. autoclass:: flask_security.datastore.sqlalchemy.SQLAlchemyUserDatastore
:members:
:inherited-members:
.. autoclass:: flask_security.datastore.mongoengine.MongoEngineUserDatastore
:members:
:inherited-members:
Models
+4 -2
View File
@@ -19,8 +19,10 @@ class UserDatastore(object):
:attr:`_do_find_user`, and :attr:`_do_find_role` methods.
:param db: An instance of a configured databse manager from a Flask
extension such as Flask-SQLAlchemy or Flask-MongoEngine"""
extension such as Flask-SQLAlchemy or Flask-MongoEngine
:param user_account_mixin: An optional mixin class that specifies additional
fields to be added to the user model
"""
def __init__(self, db, user_account_mixin=None):
self.db = db
self.user_account_mixin = user_account_mixin or object
+13
View File
@@ -46,6 +46,19 @@ class CreateUserCommand(Command):
pprint(kwargs)
class CreateRoleCommand(Command):
"""Create a role"""
option_list = (
Option('-n', '--name', dest='name', default=None),
Option('-d', '--desc', dest='description', default=None),
)
def run(self, **kwargs):
role = user_datastore.create_role(**kwargs)
print 'Role "%(name)s" created successfully.' % kwargs
class _RoleCommand(Command):
option_list = (
Option('-u', '--user', dest='user_identifier'),