Utils

get_gravatar

userena.utils.get_gravatar(email, size=80, default='identicon')

Get’s a Gravatar for a email address.

Parameters:
  • size – The size in pixels of one side of the Gravatar’s square image. Optional, if not supplied will default to 80.
  • default

    Defines what should be displayed if no image is found for this user. Optional argument which defaults to identicon. The argument can be a URI to an image or one of the following options:

    404
    Do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response.
    mm
    Mystery-man, a simple, cartoon-style silhouetted outline of a person (does not vary by email hash).
    identicon
    A geometric pattern based on an email hash.
    monsterid
    A generated ‘monster’ with different colors, faces, etc.
    wavatar
    Generated faces with differing features and backgrounds
Returns:

The URI pointing to the Gravatar.

signin_redirect

userena.utils.signin_redirect(redirect=None, user=None)

Redirect user after successful sign in.

First looks for a requested_redirect. If not supplied will fall-back to the user specific account page. If all fails, will fall-back to the standard Django LOGIN_REDIRECT_URL setting. Returns a string defining the URI to go next.

Parameters:
  • redirect – A value normally supplied by next form field. Gets preference before the default view which requires the user.
  • user – A User object specifying the user who has just signed in.
Returns:

String containing the URI to redirect to.

generate_sha1

userena.utils.generate_sha1(string, salt=None)

Generates a sha1 hash for supplied string. Doesn’t need to be very secure because it’s not used for password checking. We got Django for that.

Parameters:
  • string – The string that needs to be encrypted.
  • salt – Optionally define your own salt. If none is supplied, will use a random string of 5 characters.
Returns:

Tuple containing the salt and hash.

get_profile_model

userena.utils.get_profile_model()

Return the model class for the currently-active user profile model, as defined by the AUTH_PROFILE_MODULE setting.

Returns:The model that is used as profile.