pyfarm.models.user module

User and Role Models

Stores users and their roles in the database.

class pyfarm.models.user.User(**kwargs)[source]

Bases: flask_sqlalchemy.Model, flask_login.UserMixin, pyfarm.models.core.mixins.ReprMixin

Stores information about a user including the roles they belong to

REPR_COLUMNS = ('id', 'username')
active

Enables or disables a particular user across the entire system

check_password(password)[source]

checks the password provided against the stored password

classmethod create(username, password, email=None, roles=None)[source]
email

Contact email for registration and possible notifications

expiration

User expiration. If this value is set then the user will no longer be able to access PyFarm past the expiration.

classmethod get(id_or_username)[source]

Get a user model either by id or by the user’s username

get_auth_token()[source]
get_id()[source]
has_roles(allowed=None, required=None)[source]

checks the provided arguments against the roles assigned

classmethod hash_password(value)[source]
id
is_active()[source]

returns true if the user and the roles it belongs to are active

jobgroups
jobs
last_login

The last date that this user was logged in.

onetime_code

SHA256 one time use code which can be used for unique urls such as for password resets.

password

The password used to login

roles
subscribed_jobs
username

The username used to login.

class pyfarm.models.user.Role(**kwargs)[source]

Bases: flask_sqlalchemy.Model

Stores role information that can be used to give a user access to individual resources.

active

Enables or disables a role. Disabling a role will prevent any users of this role from accessing PyFarm

classmethod create(name, description=None)[source]

Creates a role by the given name or returns an existing role if it already exists.

description

Human description of the role.

expiration

Role expiration. If this value is set then the role, and anyone assigned to it, will no longer be able to access PyFarm past the expiration.

id
is_active()[source]
name

The name of the role

users