Models

Return to API Reference.

upload_to_mugshot

userena.models.upload_to_mugshot(instance, filename)

Uploads a mugshot for a user to the USERENA_MUGSHOT_PATH and saving it under unique hash for the image. This is for privacy reasons so others can’t just browse through the mugshot directory.

UserenaSignup

class userena.models.UserenaSignup(*args, **kwargs)

Userena model which stores all the nescessary information to have a full functional user implementation on your Django website.

activation_key_expired()

Checks if activation key is expired.

Returns True when the activation_key of the user is expired and False if the key is still valid.

The key is expired when it’s set to the value defined in USERENA_ACTIVATED or activation_key_created is beyond the amount of days defined in USERENA_ACTIVATION_DAYS.

change_email(email)

Changes the email address for a user.

A user needs to verify this new email address before it becomes active. By storing the new email address in a temporary field – temporary_email – we are able to set this email address after the user has verified it by clicking on the verfication URI in the email. This email get’s send out by send_verification_email.

Arguments

email
The new email address that the user wants to use.
send_activation_email()

Sends a activation email to the user.

This email is send when the user wants to activate their newly created user. Also checks if the protocol is secured by looking at USERENA_USE_HTTPS value.

send_confirmation_email()

Sends an email to confirm the new email address.

This method sends out two emails. One to the new email address that contains the email_confirmation_key which is used to verify this this email address with UserenaUser.objects.confirm_email.

The other email is to the old email address to let the user know that a request is made to change this email address.

UserenaBaseProfile

class userena.models.UserenaBaseProfile(*args, **kwargs)

Base model needed for extra profile functionality

class Meta

Meta options making the model abstract and defining permissions.

The model is abstract because it only supplies basic functionality to a more custom defined model that extends it. This way there is not another join needed.

We also define custom permissions because we don’t know how the model that extends this one is going to be called. So we don’t know what permissions to check. For ex. if the user defines a profile model that is called MyProfile, than the permissions would be add_myprofile etc. We want to be able to always check add_profile, change_profile etc.

UserenaBaseProfile.can_view_profile(user)

Can the user view this profile?

Returns a boolean if a user has the rights to view the profile of this user.

Users are divided into four groups:

Open
Everyone can view your profile
Closed
Nobody can view your profile.
Registered
Users that are registered on the website and signed in only.
Admin
Special cases like superadmin and the owner of the profile.

Through the privacy field a owner of an profile can define what they want to show to whom.

Arguments

user
A django User instance.
UserenaBaseProfile.get_mugshot_url()

Returns the image containing the mugshot for the user.

The mugshot can be a uploaded image or a Gravatar.

Gravatar functionality will only be used when USERENA_MUGSHOT_GRAVATAR is set to True.

Returns None when Gravatar is not used and no default image is supplied by USERENA_MUGSHOT_DEFAULT.

UserenaLanguageBaseProfile

class userena.models.UserenaLanguageBaseProfile(*args, **kwargs)

Extends the UserenaBaseProfile with a language choice.

Use this model in combination with UserenaLocaleMiddleware automaticly set the language of users when they are signed in.

Table Of Contents

Previous topic

Managers

Next topic

Utils

This Page