API Docs¶
Extension¶
User profiles module for Invenio.
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 orNone
.
-
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.
-
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 aprofile
key). This will make the user creation fail unless we convert the profile dict into aUserProfile
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.
-
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.
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.