Views

signup

userena.views.signup(request, *args, **kwargs)

Signup of an account.

Signup requiring a username, email and password. After signup a user gets an email with an activation link used to activate their account. After successful signup redirects to success_url.

Keyword arguments

signup_form
Form that will be used to sign a user. Defaults to userena’s forms.SignupForm.
template_name
String containing the template name that will be used to display the signup form. Defaults to userena/signup_form.html.
success_url
String containing the URI which should be redirected to after a successfull signup. If not supplied will redirect to userena_signup_complete view.
extra_context
Dictionary containing variables which are added to the template context. Defaults to a dictionary with a form key containing the signup_form.

Context

form
Form supplied by signup_form.

activate

userena.views.activate(request, *args, **kwargs)

Activate a user with an activation key.

The key is a SHA1 string. When the SHA1 is found with an Account, the User of that account will be activated. After a successfull activation the view will redirect to succes_url. If the SHA1 is not found, the user will be shown the template_name template displaying a fail message.

Arguments

username
String of the username that wants to be activated.
activation_key
String of a SHA1 string of 40 characters long. A SHA1 is always 160bit long, with 4 bits per character this makes it –160/4– 40 characters long.

Keyword arguments

template_name
String containing the template name that is used when the activation_key is invalid and the activation failes. Defaults to userena/activation_fail.html.
success_url
Named URL where the user should be redirected to after a succesfull activation. If not specified, will direct to userena_profile_detail view.
extra_context
Dictionary containing variables which could be added to the template context. Default to an empty dictionary.

email_confirm

userena.views.email_confirm(request, *args, **kwargs)

Confirms an email address with a confirmation key.

Confirms a new email address by running User.objects.confirm_email method. If the method returns an User the user will have his new e-mail address set and redirected to success_url. If no User is returned the user will be represented with a fail message from template_name.

Arguments

username
String of the username whose email address needs to be confirmed.
confirmation_key
String with a SHA1 representing the confirmation key used to verify a new email address.

Keyword arguments

template_name
String containing the template name which should be rendered when confirmation fails. When confirmation is succesfull, no template is needed because the user will be redirected to success_url.
success_url
Named URL which is redirected to after a succesfull confirmation. Supplied argument must be able to be rendered by reverse function.
extra_context
Dictionary of variables that are passed on to the template supplied by template_name.

direct_to_user_template

userena.views.direct_to_user_template(request, username, template_name, extra_context=None)

Simple wrapper for Django’s direct_to_template view.

This view is used when you want to show a template to a specific user. A wrapper for direct_to_template where the template also has access to the user that is found with username. For ex. used after signup, activation and confirmation of a new e-mail.

Arguments

username
String defining the username of the user that made the action.
template_name
String defining the name of the template to use. Defaults to userena/signup_complete.html.

Keyword arguments

extra_context
A dictionary containing extra variables that should be passed to the rendered template. The account key is always the User that completed the action.

signin

userena.views.signin(request, *args, **kwargs)

Signin using email or username with password.

Signs a user in by combining email/username with password. If the combination is correct and the user is_active the redirect_signin_function is called with the arguments REDIRECT_FIELD_NAME and an instance of the User whois is trying the login. The returned value of the function will be the URL that is redirected to.

A user can also select to be remembered for USERENA_REMEMBER_DAYS.

Keyword arguments

auth_form
Form to use for signing the user in. Defaults to the AuthenticationForm supplied by userena.
template_name
String defining the name of the template to use. Defaults to userena/signin_form.html.
redirect_field_name
Form field name which contains the value for a redirect to the successing page. Defaults to next and is set in REDIRECT_FIELD_NAME setting.
redirect_signin_function
Function which handles the redirect. This functions gets the value of REDIRECT_FIELD_NAME and the User who has logged in. It must return a string which specifies the URI to redirect to.
extra_context
A dictionary containing extra variables that should be passed to the rendered template. The form key is always the auth_form.

Context

form
Form used for authentication supplied by auth_form.

email_change

userena.views.email_change(request, *args, **kwargs)

Change email address

Arguments

username
String of the username which specifies the current account.

Keyword arguments

form
Form that will be used to change the email address. Defaults to ChangeEmailForm supplied by userena.
template_name
String containing the template to be used to display the email form. Defaults to userena/email_form.html.
success_url
Named URL where the user will get redirected to when succesfully changing their email address. When not suplied will redirect to userena_email_complete URL.
extra_context
Dictionary containing extra variables that can be used to render the template. The form key is always the form supplied by the keyword argument form and the user key by the user whose email address is being changed.

Context

form
Form that is used to change the email address supplied by form.
account
Instance of the Account whose email address is about to be changed.

Todo

Need to have per-object permissions, which enables users with the correct permissions to alter the email address of others.

password_change

userena.views.password_change(request, *args, **kwargs)

Change password of user.

This view is almost a mirror of the view supplied in contrib.auth.views.password_change, with the minor change that in this view we also use the username to change the password. This was needed to keep our URLs logical (and REST) accross the entire application. And that in a later stadium administrators can also change the users password through the web application itself.

Arguments

username

String supplying the username of the user who’s password is about to be changed.

Keyword arguments

template_name
String of the name of the template that is used to display the password change form. Defaults to userena/password_form.html.
pass_form
Form used to change password. Default is the form supplied by Django itself named PasswordChangeForm.
success_url
Named URL that is passed onto a reverse function with username of the active user. Defaults to the userena_password_complete URL.
extra_context
Dictionary of extra variables that are passed on the the template. The form key is always used by the form supplied by pass_form.

Context

form
Form used to change the password.
account
The current active account.

profile_edit

userena.views.profile_edit(request, *args, **kwargs)

Edit profile.

Edits a profile selected by the supplied username. First checks permissions if the user is allowed to edit this account, if denied will show a 404. When the account is succesfully edited will redirect to success_url.

Arguments

username
Username of the user which account should be edited.

Keyword arguments

edit_profile_form
Form that is used to edit the account. The save method of this form will be called when the form is_valid. Defaults to AccountEditForm from userena.
template_name
String of the template that is used to render the edit_profile_form. Defaults to userena/edit_profile_form.html.
success_url
Named URL which be passed on to a django reverse function after the form is successfully saved. Defaults to the userena_detail url.
extra_context
Dictionary containing variables that are passed on to the template_name template. form key will always be the form used to edit the account, and the account key is always the edited account.

Context

form
Form that is used to alter the account.
account
Instance of the Account that is edited.

profile_detail

userena.views.profile_detail(request, username, template_name='userena/profile_detail.html', extra_context=None)

Detailed view of an user.

Arguments

username
String of the username of which the account should be viewed.

Keyword arguments

template_name
String representing the template name that should be used to display the account.
extra_context
Dictionary of variables which should be supplied to the template. The account key is always the current account.

Context

account
Instance of the currently edited Account.

profile_list

userena.views.profile_list(request, page=1, template_name='userena/profile_list.html', paginate_by=50, extra_context=None, **kwargs)

Returns a list of all profiles that are public.

It’s possible to disable this by changing USERENA_DISABLE_PROFILE_LIST to True in your settings.

Keyword arguments

page
Integer of the active page used for pagination. Defaults to the first page.
template_name
String defining the name of the template that is used to render the list of all users. Defaults to userena/list.html.
paginate_by
Integer defining the amount of displayed accounts per page. Defaults to 50 accounts per page.
extra_context
Dictionary of variables that are passed on to the template_name template.

Context

account_list
A list of accounts.
is_paginated
A boolean representing whether the results are paginated.

If the result is paginated. It will also contain the following variables:

paginator
An instance of django.core.paginator.Paginator.
page_obj
An instance of django.core.paginator.Page.

Table Of Contents

Previous topic

Utils

This Page