API Docs

Extension

User profiles module for Invenio.

class invenio_userprofiles.ext.InvenioUserProfiles(app=None)[source]

Invenio-UserProfiles extension.

Extension initialization.

init_app(app)[source]

Flask application initialization.

init_config(app)[source]

Initialize configuration.

Admin

API

API for user profiles.

invenio_userprofiles.api.current_userprofile

Proxy to the user profile of the currently logged in user.

Models

Database models for user profiles.

class invenio_userprofiles.models.AnonymousUserProfile[source]

Anonymous user profile.

is_anonymous

Return whether this UserProfile is anonymous.

class invenio_userprofiles.models.UserProfile(**kwargs)[source]

User profile model.

Stores a username, display name (case sensitive version of username) and a full name for a user.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

full_name

Full name of person.

classmethod get_by_userid(user_id)[source]

Get profile by user identifier.

Parameters:user_id – Identifier of a User.
Returns:A UserProfile instance or None.
classmethod get_by_username(username)[source]

Get profile by username.

Parameters:username – A username to query for (case insensitive).
is_anonymous

Return whether this UserProfile is anonymous.

user

User relationship.

user_id

Foreign key to User.

username

Get username.

invenio_userprofiles.models.on_user_init(target, args, kwargs)[source]

Provide hook on User initialization.

Automatically convert a dict to a UserProfile instance. This is needed during e.g. user registration where Flask-Security will initialize a user model with all the form data (which when Invenio-UserProfiles is enabled includes a profile key). This will make the user creation fail unless we convert the profile dict into a UserProfile instance.

Forms

Forms for user profiles.

class invenio_userprofiles.forms.EmailProfileForm(formdata=<object object>, **kwargs)[source]

Form to allow editing of email address.

class invenio_userprofiles.forms.ProfileForm(formdata=<object object>, **kwargs)[source]

Form for editing user profile.

validate_username(field)[source]

Wrap username validator for WTForms.

class invenio_userprofiles.forms.VerificationForm(formdata=<object object>, **kwargs)[source]

Form to render a button to request email confirmation.

invenio_userprofiles.forms.confirm_register_form_factory(Form)[source]

Factory for creating a confirm register form.

invenio_userprofiles.forms.current_user_email(form, field)[source]

Field validator to stop validation if email wasn’t changed.

invenio_userprofiles.forms.register_form_factory(Form)[source]

Factory for creating an extended user registration form.

invenio_userprofiles.forms.strip_filter(text)[source]

Filter for trimming whitespace.

Parameters:text – The text to strip.
Returns:The stripped text.

Validators

Validators for user profiles.

invenio_userprofiles.validators.USERNAME_RULES = l'Username must start with a letter, be at least three characters long and only contain alphanumeric characters, dashes and underscores.'

Description of username validation rules.

Note

Used for both form help text and for form validation error.

invenio_userprofiles.validators.username_regex = re.compile('^[a-zA-Z][a-zA-Z0-9-_]{2}[a-zA-Z0-9-_]*$')

Username rules.

invenio_userprofiles.validators.validate_username(username)[source]

Validate the username.

See username_regex to know which rules are applied.

Parameters:username – A username.
Raises:ValueError – If validation fails.

Views

Invenio module that adds userprofiles to the platform.

invenio_userprofiles.views.handle_profile_form(form)[source]

Handle profile update form.

invenio_userprofiles.views.handle_verification_form(form)[source]

Handle email sending verification form.

invenio_userprofiles.views.init_common(app)[source]

Post initialization.

invenio_userprofiles.views.profile()[source]

View for editing a profile.

invenio_userprofiles.views.profile_form_factory()[source]

Create a profile form.

invenio_userprofiles.views.userprofile(value)[source]

Retrieve user profile for a given user id.