Les messages privés (mp/)

Module situé dans zds/mp/.

Modèles (models.py)

class zds.mp.models.PrivatePost(*args, **kwargs)

A private post written by a user.

exception DoesNotExist
exception MultipleObjectsReturned
get_absolute_url()

URL of a single PrivatePost object.

Returns:PrivatePost object URL
Return type:str
is_author(user)

Check if the user given is the author of the message.

Parameters:user – Potential author of the message.
Returns:true if the user is the author.
is_last_message(private_topic=None)

Check if the current message is the last one of its private topic.

Parameters:private_topic – Potential private topic of the message.
Returns:true if the current message is the last.
class zds.mp.models.PrivateTopic(*args, **kwargs)

Topic private, containing private posts.

exception DoesNotExist
exception MultipleObjectsReturned
alone()

Check if there just one participant in the conversation (PrivateTopic).

Returns:True if there just one participant in PrivateTopic
Return type:bool
first_post()

Get the first answer in the PrivateTopic written by topic’s author, if exists.

Returns:PrivateTopic object first answer (PrivatePost)
Return type:PrivatePost object or None
first_unread_post(user=None)

Get the first PrivatePost the user has unread.

Parameters:user (User object) – The user is reading the PrivateTopic. If None, the current user is used.
Returns:first PrivatePost unread
Return type:PrivatePost object or None
get_absolute_url()

URL of a single PrivateTopic object.

Returns:PrivateTopic object URL
Return type:str
get_last_answer()

Get the last answer in the PrivateTopic written by topic’s author, if exists.

Returns:PrivateTopic object last answer (PrivatePost)
Return type:PrivatePost object or None
get_post_count()

Get the number of private posts in a single PrivateTopic object.

Returns:number of post in PrivateTopic object
Return type:int
is_author(user)

Check if the user given is the author of the private topic.

Parameters:user – User given.
Returns:true if the user is the author.
is_participant(user)

Check if the user given is in participants or author of the private topic.

Parameters:user – User given.
Returns:true if the user is in participants
is_unread(user=None)

Check if a user has never read the current PrivateTopic.

Parameters:user (User object) – a user as Django User object. If None, the current user is used.
Returns:True if the PrivateTopic was never read
Return type:bool
last_read_post(user=None)

Get the last PrivatePost the user has read.

Parameters:user (User object) – The user is reading the PrivateTopic. If None, the current user is used.
Returns:last PrivatePost read
Return type:PrivatePost object or None
slug()

PrivateTopic doesn’t have a slug attribute of a private topic. To be compatible with older private topic, the slug is always re-calculate when we need one. :return: title slugify.

class zds.mp.models.PrivateTopicRead(*args, **kwargs)

Small model which keeps track of the user viewing private topics.

It remembers the topic he looked and what was the last private Post at this time.

exception DoesNotExist
exception MultipleObjectsReturned
zds.mp.models.is_privatetopic_unread(privatetopic, user=None)

Check if a private topic has been read by a user since it last post was added.

Parameters:
  • privatetopic (PrivateTopic object) – a PrivateTopic to check
  • user (User object) – a user as Django User object. If None, the current user is used
Returns:

True if the PrivateTopic was never read

Return type:

bool

zds.mp.models.mark_read(privatetopic, user=None)

Mark a private topic as read for the user.

Parameters:
  • privatetopic (PrivateTopic object) – a PrivateTopic to check
  • user (User object) – a user as Django User object. If None, the current user is used
Returns:

nothing is returned

Return type:

None

Vues (views.py)

class zds.mp.views.PrivatePostAnswer(**kwargs)

Creates a post to answer on a MP.

form_class

alias of zds.mp.forms.PrivatePostForm

form_valid(form)

If the form is valid, save the associated model.

get_form(form_class=<class 'zds.mp.forms.PrivatePostForm'>)

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

model_quote

alias of zds.mp.models.PrivatePost

class zds.mp.views.PrivatePostEdit(**kwargs)

Edits a post on a MP.

form_class

alias of zds.mp.forms.PrivatePostForm

form_valid(form)

If the form is valid, save the associated model.

get(request, *args, **kwargs)

Handles GET requests and instantiates a blank version of the form.

get_form(form_class=<class 'zds.mp.forms.PrivatePostForm'>)

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

get_object(queryset=None)

Returns the object the view is displaying.

By default this requires self.queryset and a pk or slug argument in the URLconf, but subclasses can override this to return any object.

post(request, *args, **kwargs)

Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity.

class zds.mp.views.PrivatePostList(**kwargs)

Display a thread and its posts using a pager.

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.

class zds.mp.views.PrivateTopicAddParticipant(**kwargs)
get_object(queryset=None)

Returns the object the view is displaying.

By default this requires self.queryset and a pk or slug argument in the URLconf, but subclasses can override this to return any object.

class zds.mp.views.PrivateTopicEdit(**kwargs)

Update mp informations

form_class

alias of zds.mp.forms.PrivateTopicEditForm

get_object(queryset=None)

Returns the object the view is displaying.

By default this requires self.queryset and a pk or slug argument in the URLconf, but subclasses can override this to return any object.

model

alias of zds.mp.models.PrivateTopic

class zds.mp.views.PrivateTopicLeaveDetail(**kwargs)

Leaves a MP.

class zds.mp.views.PrivateTopicLeaveList(**kwargs)

Leaves a list of MP.

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.mp.views.PrivateTopicList(**kwargs)

Displays the list of private topics of a member given.

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.mp.views.PrivateTopicNew(**kwargs)

Creates a new MP.

form_class

alias of zds.mp.forms.PrivateTopicForm

form_valid(form)

If the form is valid, save the associated model.

get(request, *args, **kwargs)

Handles GET requests and instantiates a blank version of the form.

get_form(form_class=<class 'zds.mp.forms.PrivateTopicForm'>)

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

post(request, *args, **kwargs)

Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity.