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.

exception DoesNotExist
exception MultipleObjectsReturned
class zds.member.models.BannedEmailProvider(*args, **kwargs)

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

exception DoesNotExist
exception MultipleObjectsReturned
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

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

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

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

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

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()

Absolute URL to the profile page.

get_active_alerts_count()
Renvoie:The number of currently active alerts created by this user.
get_article_count()
Renvoie:the count of articles with this user as author. Count all articles, no only published one.
get_articles()
Renvoie: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()
Renvoie:All articles in beta with this user as author.
get_beta_contents(_type=None)
Paramètres:_type – if provided, request a specific type of content
Renvoie:All tutorials in beta with this user as author.
get_beta_tutos()
Renvoie: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)
Paramètres:_type – if provided, request a specific type of content
Renvoie:the count of contents with this user as author. Count all contents no only published one.
get_contents(_type=None)
Paramètres:_type – if provided, request a specific type of content
Renvoie: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.

Paramètres:_type – if provided, request a specific type of content
Renvoie: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()
Renvoie:All forum topics followed by this user.
get_hats()

Return all hats the user is allowed to use.

get_opinion_count()
Renvoie:the count of opinions with this user as author. Count all opinions, no only published one.
get_opinions()
Renvoie:All opinions with this user as author.
get_post_count()
Renvoie: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()
Renvoie:All published articles with this user as author.
get_public_contents(_type=None)
Paramètres:_type – if provided, request a specific type of content
Renvoie:All published contents with this user as author.
get_public_opinions()
Renvoie:All published opinions with this user as author.
get_public_tutos()
Renvoie: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()
Renvoie:the number of topics created by this user.
get_tuto_count()
Renvoie:the count of tutorials with this user as author. Count all tutorials, no only published one.
get_tutos()
Renvoie:All tutorials with this user as author.
get_user_contents_queryset(_type=None)
Paramètres:_type – if provided, request a specific type of content
Renvoie:Queryset of contents with this user as author.
get_user_public_contents_queryset(_type=None)
Paramètres:_type – if provided, request a specific type of content
Renvoie:Queryset of contents with this user as author.
get_validate_articles()
Renvoie:All articles in validation with this user as author.
get_validate_contents(_type=None)
Paramètres:_type – if provided, request a specific type of content
Renvoie:All contents in validation with this user as author.
get_validate_tutos()
Renvoie: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 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.

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()
Renvoie: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.

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()
Renvoie: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

Paramètres: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)

Paramètres:
  • response – the HTTP response
  • profile (Profile) – the profile
Type:

django.http.response.HttpResponse

zds.member.models.user_readable_forums(user)

Returns a set of forums to which a user can access.

Vues (views.py)

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

Add an email provider to the banned list.

form_class

alias de zds.member.forms.BannedEmailProviderForm

form_valid(form)

If the form is valid, save the associated model.

model

alias de zds.member.models.BannedEmailProvider

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

List the banned email providers.

model

alias de zds.member.models.BannedEmailProvider

class zds.member.views.HatDetail(**kwargs)
get_context_data(**kwargs)

Insert the single object into the context dict.

model

alias de zds.utils.models.Hat

class zds.member.views.HatRequestDetail(**kwargs)
get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

model

alias de zds.utils.models.HatRequest

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

Display the list of hats.

class zds.member.views.HatsSettings(**kwargs)
form_class

alias de zds.member.forms.HatRequestForm

form_valid(form)

If the form is valid, save the associated model.

get_initial()

Return the initial data to use for forms on this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

model

alias de zds.utils.models.HatRequest

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

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

Display details about a profile.

get_context_data(**kwargs)

Insert the single object into the context dict.

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

model

alias de django.contrib.auth.models.User

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

Display the list of registered users.

get_queryset()

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

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

List users using a banned email provider.

get_context_data(**kwargs)

Get the context for this view. This method is surcharged to modify the paginator and information given at the template.

get_queryset()

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

model

alias de django.contrib.auth.models.User

class zds.member.views.NewEmailProvidersList(**kwargs)
model

alias de zds.member.models.NewEmailProvider

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

Create a profile.

form_class

alias de zds.member.forms.RegisterForm

form_valid(form)

If the form is valid, save the associated model.

get_form(form_class=<class 'zds.member.forms.RegisterForm'>)

Return an instance of the form to be used in this view.

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

class zds.member.views.RequestedHatsList(**kwargs)
model

alias de zds.utils.models.HatRequest

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

Send a validation email on demand.

form_class

alias de zds.member.forms.UsernameAndEmailForm

form_valid(form)

If the form is valid, redirect to the supplied URL.

get_form(form_class=<class 'zds.member.forms.UsernameAndEmailForm'>)

Return an instance of the form to be used in this view.

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

class zds.member.views.SolvedHatRequestsList(**kwargs)
model

alias de zds.utils.models.HatRequest

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

Update the avatar of a logged in user.

form_class

alias de zds.gallery.forms.ImageAsAvatarForm

get_form(form_class=<class 'zds.gallery.forms.ImageAsAvatarForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

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

Update the GitHub token.

form_class

alias de zds.member.forms.GitHubTokenForm

form_valid(form)

If the form is valid, save the associated model.

get_form(form_class=<class 'zds.member.forms.GitHubTokenForm'>)

Return an instance of the form to be used in this view.

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()

Return the URL to redirect to after processing a valid form.

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

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

Update a profile.

form_class

alias de zds.member.forms.ProfileForm

form_valid(form)

If the form is valid, save the associated model.

get_form(form_class=<class 'zds.member.forms.ProfileForm'>)

Return an instance of the form to be used in this view.

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()

Return the URL to redirect to after processing a valid form.

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

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

Password-related user settings.

form_class

alias de zds.member.forms.ChangePasswordForm

get_form(form_class=<class 'zds.member.forms.ChangePasswordForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

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

Settings related to username and email.

form_class

alias de zds.member.forms.ChangeUserForm

get_form(form_class=<class 'zds.member.forms.ChangeUserForm'>)

Return an instance of the form to be used in this view.

get_success_url()

Return the URL to redirect to after processing a valid form.

post(request, *args, **kwargs)

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

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(get_response=None)

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.

apply_sanction(profile, ban)

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

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy
class zds.member.commons.DeleteBanSanction(array_infos)

State of the un-sanction ban.

apply_sanction(profile, ban)

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

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy
class zds.member.commons.DeleteReadingOnlySanction(array_infos)

State of the un-sanction reading only.

apply_sanction(profile, ban)

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

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy
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.

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_message_sanction()

Gets the message for a sanction.

Renvoie:message of the sanction.
Type renvoyé:ugettext_lazy
get_message_unsanction()

Gets the message for an un-sanction.

Renvoie:message of the un-sanction.
Type renvoyé:ugettext_lazy
get_sanction(moderator, user)

Gets the sanction according to the type of the sanction.

Paramètres:
  • moderator (User object) – Moderator who applies the sanction.
  • user (User object) – User sanctioned.
Renvoie:

sanction

Type renvoyé:

Ban object

get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy
notify_member(ban, msg)

Notify the member sanctioned with a MP.

Paramètres:
  • ban (Ban object) – Sanction.
  • msg (string object) – message send at the user sanctioned.
Renvoie:

nothing

Type renvoyé:

None

class zds.member.commons.ReadingOnlySanction(array_infos)

State of the sanction reading only.

apply_sanction(profile, ban)

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

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy
class zds.member.commons.TemporaryBanSanction(array_infos)

State of the sanction ban temporary.

apply_sanction(profile, ban)

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

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy
class zds.member.commons.TemporaryReadingOnlySanction(array_infos)

State of the sanction reading only temporary.

apply_sanction(profile, ban)

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

Paramètres:
  • profile (Profile object) – Member concerned by the sanction.
  • ban (Ban object) – Sanction.
Renvoie:

nothing

Type renvoyé:

None

get_detail()

Gets detail of a sanction.

Renvoie:detail of the sanction.
Type renvoyé:ugettext_lazy
get_text()

Gets the text of a sanction.

Renvoie:text of the sanction.
Type renvoyé:string
get_type()

Gets the type of a sanction.

Renvoie:type of the sanction.
Type renvoyé:ugettext_lazy