Django Back-end¶
Documented files:
Models¶
-
class
member.models.Ban(*args, **kwargs)¶ This model stores all sanctions (not only bans). It stores sanctioned user, the moderator, the type of sanctions, the reason and the date. Note this stores also un-sanctions.
-
class
member.models.KarmaNote(*args, **kwargs)¶ A karma note is a tool for staff to store data about a member. Data are:
- A note (negative values are bad)
- A comment about the member
- A date
This helps the staff to react and stores history of stupidities of a member.
-
class
member.models.Profile(*args, **kwargs)¶ A user profile. Complementary data of standard Django auth.user.
-
can_read_now()¶ Check if you can read a web site content as user. If you can’t read, you can’t login on website. This happens when you have been banned (temporarily or definitively)
Returns: Falseif you are banned,Trueelse.Return type: bool
-
can_write_now()¶ Check if you can write something on a web site as user. This happens when you have been reading only (temporarily or definitively)
Returns: Falseif you are read only,Trueelse.Return type: bool
-
get_absolute_url()¶ Absolute URL to the profile page.
-
get_avatar_url()¶ Get the avatar URL for this profile. If the user has defined a custom URL, use it. If not, use Gravatar.
Returns: The avatar URL for this profile Return type: str
-
-
class
member.models.TokenForgotPassword(*args, **kwargs)¶ When a user forgot its password, the website sends it an email with a token (embedded in a URL). If the user has the correct token, it can choose a new password on the dedicated page. This model stores the tokens for the users that have forgot their passwords, with an expiration date.
-
get_absolute_url()¶ Returns: The absolute URL of the “New password” page, including the correct token.
-
-
class
member.models.TokenRegister(*args, **kwargs)¶ On registration, a token is send by mail to the user. It must use this token (by clicking on a link) to activate its account (and prove the email address is correct) and connect itself. This model stores the registration token for each user, with an expiration date.
-
get_absolute_url()¶ Returns: the absolute URL of the account validation page, including the token.
-
-
member.models.auto_delete_token_on_unregistering(sender, instance, **kwargs)¶ This signal receiver deletes forgotten password tokens and registering tokens for the un-registering user;
-
member.models.logout_user(username)¶ Logout the member.
Parameters: username – the name of the user to logout.
Views¶
-
class
member.views.MemberList(**kwargs)¶ Displays the list of registered users.
-
class
member.views.SendValidationEmailView(**kwargs)¶ Send a validation email on demand.
-
class
member.views.UpdatePasswordMember(**kwargs)¶ User’s settings about his password.
-
class
member.views.UpdateUsernameEmailMember(**kwargs)¶ User’s settings about his username and email.
-
form_class¶ alias of
ChangeUserForm
-
-
member.views.active_account(request)¶ Active token for a user.
-
member.views.forgot_password(request)¶ If the user forgot his password, he can have a new one.
-
member.views.generate_token_account(request)¶ Generate token for account.
-
member.views.get_client_ip(request)¶ Retrieve the real IP address of the client.
-
member.views.login_view(request)¶ Log in user.
-
member.views.logout_view(request, *args, **kwargs)¶ Log out user.
-
member.views.member_from_ip(request, *args, **kwargs)¶ Get list of user connected from a particular ip
-
member.views.modify_karma(request, *args, **kwargs)¶ Add a Karma note to the user profile
-
member.views.new_password(request)¶ Create a new password for a user.
-
member.views.settings_promote(request, *args, **kwargs)¶ Manage the admin right of user. Only super user can access
-
member.views.unregister(request, *args, **kwargs)¶ allow members to unregister
-
member.views.warning_unregister(request, *args, **kwargs)¶ Displays a warning page showing what will happen when user unregisters.
Forms¶
-
class
member.forms.ChangeUserForm(*args, **kwargs)¶ Update username and email
-
class
member.forms.LoginForm(next=None, *args, **kwargs)¶ The login form, including the “remember me” checkbox.
-
class
member.forms.MiniProfileForm(*args, **kwargs)¶ Updates some profile data: biography, website, avatar URL, signature.
-
class
member.forms.NewPasswordForm(identifier, *args, **kwargs)¶ Defines a new password (when the current one has been forgotten)
-
class
member.forms.ProfileForm(*args, **kwargs)¶ Updates main profile rules:
- Display email address to everybody
- Display signatures
- Display menus on hover
- Receive an email when receiving a personal message
-
class
member.forms.PromoteMemberForm(*args, **kwargs)¶ Promotes a user to an arbitrary group
-
class
member.forms.RegisterForm(*args, **kwargs)¶ Form to register a new member.
-
clean()¶ Cleans the input data and performs following checks:
- Both passwords are the same
- Username doesn’t exist in database
- Username is not empty
- Username doesn’t contain any comma (this will break the personal message system)
- Username doesn’t begin or ends with spaces
- Password is different of username
- Email address is unique through all users
- Email provider is not a forbidden one
Forbidden email providers are stored in forbidden_email_providers.txt on project root.
Returns: Cleaned data, and the error messages if they exist.
-