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 necessary information to have a full functional user implementation on your Django website.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- activation_key_expired()¶
Checks if activation key is expired.
Returns
True
when theactivation_key
of the user is expired andFalse
if the key is still valid.The key is expired when it’s set to the value defined in
USERENA_ACTIVATED
oractivation_key_created
is beyond the amount of days defined inUSERENA_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 verification URI in the email. This email gets send out bysend_verification_email
.- Parameters
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.
- 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 withUserenaUser.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 beadd_myprofile
etc. We want to be able to always checkadd_profile
,change_profile
etc.
- 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.- Parameters
user – A Django
User
instance.
- get_full_name_or_username()¶
Returns the full name of the user, or if none is supplied will return the username.
Also looks at
USERENA_WITHOUT_USERNAMES
settings to define if it should return the username or email address when the full name is not supplied.- Returns
String
containing the full name of the user. If no name is supplied it will return the username or email address depending on theUSERENA_WITHOUT_USERNAMES
setting.
- 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 toTrue
.- Returns
None
when Gravatar is not used and no default image is supplied byUSERENA_MUGSHOT_DEFAULT
.
UserenaLanguageBaseProfile¶
- class userena.models.UserenaLanguageBaseProfile(*args, **kwargs)¶
Extends the
UserenaBaseProfile
with a language choice.Use this model in combination with
UserenaLocaleMiddleware
automatically set the language of users when they are signed in.- class Meta¶