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.BlockedIP(*args, **kwargs)
IP addresses blocked from signing up or logging in.
- 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_avatar_url()
Gets the avatar URL of this profile. :return: The absolute URL of this profile’s avatar :rtype: str or None
- 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_articles()
- Renvoie:
All articles with this user as author.
- 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. The result is cached on an instance level because this method is called a lot in the profile. :return: The city and the country name of this profile.
- 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_topic_count()
- Renvoie:
the number of topics followeded by this user.
- get_followed_topics()
- Renvoie:
All forum topics followed by this user.
- get_hats()
Return all hats the user is allowed to use.
- 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_tutos()
- Renvoie:
All tutorials with this user as author.
- get_user_beta_contents_queryset(_type=None)
- Paramètres:
_type – if provided, request a specific type of content
- Renvoie:
Queryset of contents in beta 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_draft_contents_queryset(_type=None)
- Paramètres:
_type – if provided, request a specific type of content
- Renvoie:
Queryset of draft 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 public contents with this user as author.
- get_user_validate_contents_queryset(_type=None)
- Paramètres:
_type – if provided, request a specific type of content
- Renvoie:
Queryset of contents in validation 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_banned()
Return True if the user is permanently or temporarily banned.
- 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.
- 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
- zds.member.models.user_readable_forums(user)
Returns a set of forums to which a user can access.
Vues (views.py
)
Les utilitaires (utils.py
)
- class zds.member.utils.ZDSCustomizeSocialAuthExceptionMiddleware(get_response)
For more information, see http://python-social-auth.readthedocs.io/en/latest/configuration/django.html#exceptions-middleware.
- zds.member.utils.get_anonymous_account() User
Get the anonymous account. Used for example as a replacement for unregistered users.
- zds.member.utils.get_bot_account() User
Get the bot account. Used for example to send automated private messages.
- zds.member.utils.get_client_ip(request)
Retrieve the real IP address of the client.
- zds.member.utils.get_external_account() User
Get the external account. Used for example to mark publications by authors not registered on the site.
- zds.member.utils.get_geo_location_from_ip(ip: str) str
Uses geo-localization to get physical localization of an 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 IP.
- zds.member.utils.get_info_from_user_agent(user_agent)
Parse the user agent and extract information about the device, OS and browser.
- zds.member.utils.get_network_ip(ip_address)
Retrieve the network address of this IP address
- zds.member.utils.get_network_ip_filter(ip_address)
Retrieves the network address of this IP address without the last colon, so we can filter IP addresses on this network
- zds.member.utils.is_ipv6(ip_address)
Checks if this IP address is an IPv6
- zds.member.utils.is_valid_ip(ip_address)
Checks if this input is a valid IP address.
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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_lazy
- get_message_sanction()
Gets the message for a sanction.
- Renvoie:
message of the sanction.
- Type renvoyé:
gettext_lazy
- get_message_unsanction()
Gets the message for an un-sanction.
- Renvoie:
message of the un-sanction.
- Type renvoyé:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_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é:
gettext_lazy