Les membres (member/)

Module situé dans zds/member/.

Modèles (models.py)

class zds.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 zds.member.models.BannedEmailProvider(*args, **kwargs)

A email provider which has been banned by a staff member. It cannot be used for registration.

class zds.member.models.KarmaNote(*args, **kwargs)

Karma notes are a way of annotating members profiles. They are only visible to the staff.

Fields are: - target user and the moderator leaving the note - a textual note - some amount of karma, negative values being… negative

class zds.member.models.NewEmailProvider(*args, **kwargs)

A new-used email provider which should be checked by a staff member.

class zds.member.models.Profile(*args, **kwargs)

A user profile. Complementary data of standard Django auth.user.

get_absolute_url()

Absolute URL to the profile page.

get_active_alerts_count()
Returns:The number of currently active alerts created by this user.
get_article_count()
Returns:the count of articles with this user as author. Count all articles, no only published one.
get_articles()
Returns:All articles with this user as author.
get_avatar_url()

Get the avatar URL for this profile. If the user has defined a custom URL, use it. If not, use Gravatar. :return: The avatar URL for this profile :rtype: str

get_beta_articles()
Returns:All articles in beta with this user as author.
get_beta_contents(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:All tutorials in beta with this user as author.
get_beta_tutos()
Returns:All tutorials in beta with this user as author.
get_city()

Uses geo-localization to get physical localization of a profile through its last IP address. This works relatively well with IPv4 addresses (~city level), but is very imprecise with IPv6 or exotic internet providers. :return: The city and the country name of this profile.

get_content_count(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:the count of contents with this user as author. Count all contents no only published one.
get_contents(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:All contents with this user as author.
get_draft_articles()

Return all draft article with this user as author. A draft article is a article which is not published or in validation. :return: All draft article with this user as author.

get_draft_contents(_type=None)

Return all draft contents with this user as author. A draft content is a content which is not published, in validation or in beta.

Parameters:_type – if provided, request a specific type of content
Returns:All draft tutorials with this user as author.
get_draft_opinions()

Return all draft opinion with this user as author. A draft opinion is a opinion which is not published or in validation. :return: All draft opinion with this user as author.

get_draft_tutos()

Return all draft tutorials with this user as author. A draft tutorial is a tutorial which is not published, in validation or in beta. :return: All draft tutorials with this user as author.

get_followed_topics()
Returns:All forum topics followed by this user.
get_hats()

Return all hats the user is allowed to use.

get_opinion_count()
Returns:the count of opinions with this user as author. Count all opinions, no only published one.
get_opinions()
Returns:All opinions with this user as author.
get_post_count()
Returns:The forum post count. Doesn’t count comments on articles or tutorials.
get_post_count_as_staff()

Number of messages posted (view as staff).

get_public_articles()
Returns:All published articles with this user as author.
get_public_contents(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:All published contents with this user as author.
get_public_opinions()
Returns:All published opinions with this user as author.
get_public_tutos()
Returns:All published tutorials with this user as author.
get_requested_hats()

Return all current hats requested by this user.

get_solved_hat_requests()

Return old hats requested by this user.

get_topic_count()
Returns:the number of topics created by this user.
get_tuto_count()
Returns:the count of tutorials with this user as author. Count all tutorials, no only published one.
get_tutos()
Returns:All tutorials with this user as author.
get_user_contents_queryset(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:Queryset of contents with this user as author.
get_user_public_contents_queryset(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:Queryset of contents with this user as author.
get_validate_articles()
Returns:All articles in validation with this user as author.
get_validate_contents(_type=None)
Parameters:_type – if provided, request a specific type of content
Returns:All contents in validation with this user as author.
get_validate_tutos()
Returns:All tutorials in validation with this user as author.
has_hat()

Checks if this user can at least use one hat.

is_dev()

Checks whether user is part of group settings.ZDS_APP[‘member’][‘dev_group’].

is_private()

can the user can display their stats

class zds.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 zds.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.
zds.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;

zds.member.models.remove_hats_linked_to_group(sender, instance, **kwargs)

When a user is saved, their hats are checked to be sure that none of them is linked to a group. In this case, the relevant hat will be removed from the user.

Remove the Clem smileys cookie by immediate expiration

Parameters:response – the HTTP response
Type:django.http.response.HttpResponse
zds.member.models.remove_token_github_on_removing_from_dev_group(sender, instance, **kwargs)

This signal receiver removes the GitHub token of a user if he’s not in the dev group

Set the Clem smileys cookie according to profile (and if allowed)

Parameters:
  • response – the HTTP response
  • profile (Profile) – the profile
Type:

django.http.response.HttpResponse

Vues (views.py)

class zds.member.views.AddBannedEmailProvider(**kwargs)

Add an email provider to the banned list.

model

alias of BannedEmailProvider

class zds.member.views.BannedEmailProvidersList(**kwargs)

List the banned email providers.

model

alias of BannedEmailProvider

class zds.member.views.HatsList(**kwargs)

Display the list of hats.

class zds.member.views.MemberDetail(**kwargs)

Display details about a profile.

model

alias of User

class zds.member.views.MemberList(**kwargs)

Display the list of registered users.

class zds.member.views.MembersWithProviderList(**kwargs)

List users using a banned email provider.

model

alias of User

class zds.member.views.RegisterView(**kwargs)

Create a profile.

form_class

alias of RegisterForm

class zds.member.views.SendValidationEmailView(**kwargs)

Send a validation email on demand.

class zds.member.views.UpdateAvatarMember(**kwargs)

Update the avatar of a logged in user.

form_class

alias of ImageAsAvatarForm

class zds.member.views.UpdateGitHubToken(**kwargs)

Update the GitHub token.

form_class

alias of GitHubTokenForm

class zds.member.views.UpdateMember(**kwargs)

Update a profile.

form_class

alias of ProfileForm

class zds.member.views.UpdatePasswordMember(**kwargs)

Password-related user settings.

class zds.member.views.UpdateUsernameEmailMember(**kwargs)

Settings related to username and email.

form_class

alias of ChangeUserForm

zds.member.views.activate_account(request)

Activate an account with a token.

zds.member.views.add_hat(request, user_pk)

Add a hat to a user. Creates the hat if it doesn’t exist.

zds.member.views.check_new_email_provider(request, provider_pk)

Remove an alert about a new provider.

zds.member.views.forgot_password(request)

If the user has forgotten his password, they can get a new one.

zds.member.views.generate_token_account(request)

Generate a token for an account.

zds.member.views.get_client_ip(request)

Retrieve the real IP address of the client.

zds.member.views.login_view(request)

Logs user in.

zds.member.views.logout_view(request)

Log user out.

zds.member.views.member_from_ip(request, ip_address)

List users connected from a particular IP.

zds.member.views.modify_karma(request)

Add a Karma note to a user profile.

zds.member.views.new_password(request)

Create a new password for a user.

zds.member.views.remove_banned_email_provider(request, provider_pk)

Unban an email provider.

zds.member.views.remove_github_token(request)

Remove the current user token.

zds.member.views.remove_hat(request, user_pk, hat_pk)

Remove a hat from a user.

zds.member.views.settings_promote(request, user_pk)

Manage groups and activation status of a user. Only superusers are allowed to use this.

zds.member.views.solve_hat_request(request, request_pk)

Solve a hat request by granting or denying the requested hat according to moderator’s decision.

zds.member.views.unregister(request)

Allow members to unregister.

zds.member.views.warning_unregister(request)

Display a warning page showing what will happen when the user unregisters.

Les utilitaires (utils.py)

class zds.member.utils.ZDSCustomizeSocialAuthExceptionMiddleware

For more information, see http://python-social-auth.readthedocs.io/en/latest/configuration/django.html#exceptions-middleware.

Les objets commun pour l’authentification avec API (commons.py)

class zds.member.commons.BanSanction(array_infos)

State of the sanction ban.

class zds.member.commons.DeleteBanSanction(array_infos)

State of the un-sanction ban.

class zds.member.commons.DeleteReadingOnlySanction(array_infos)

State of the un-sanction reading only.

class zds.member.commons.MemberSanctionState(array_infos)

Super class of the enumeration to know which sanction it is.

apply_sanction(profile, ban)

Applies the sanction with the ban object on a member with the profile object and saves these objects.

Parameters:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Returns:

nothing

Return type:

None

get_detail()

Gets detail of a sanction.

Returns:detail of the sanction.
Return type:ugettext_lazy
get_message_sanction()

Gets the message for a sanction.

Returns:message of the sanction.
Return type:ugettext_lazy
get_message_unsanction()

Gets the message for an un-sanction.

Returns:message of the un-sanction.
Return type:ugettext_lazy
get_sanction(moderator, user)

Gets the sanction according to the type of the sanction.

Parameters:
  • moderator (User object) – Moderator who applies the sanction.
  • user (User object) – User sanctioned.
Returns:

sanction

Return type:

Ban object

get_text()

Gets the text of a sanction.

Returns:text of the sanction.
Return type:string
get_type()

Gets the type of a sanction.

Returns:type of the sanction.
Return type:ugettext_lazy
notify_member(ban, msg)

Notify the member sanctioned with a MP.

Parameters:
  • ban (Ban object) – Sanction.
  • msg (string object) – message send at the user sanctioned.
Returns:

nothing

Return type:

None

class zds.member.commons.ReadingOnlySanction(array_infos)

State of the sanction reading only.

class zds.member.commons.TemporaryBanSanction(array_infos)

State of the sanction ban temporary.

class zds.member.commons.TemporaryReadingOnlySanction(array_infos)

State of the sanction reading only temporary.