Forum conversation

The forum_conversation application handles all the conversations that can happen in forums. It provides some of the main features of a forum application: posting messages, writing answers, voting in polls, …

Abstract models

Forum conversation abstract models

This module defines abstract models provided by the forum_conversation application.

class machina.apps.forum_conversation.abstract_models.AbstractPost(*args, **kwargs)

Bases: machina.models.abstract_models.DatedModel

Represents a forum post. A forum post is always linked to a topic.

clean()

Validates the post instance.

delete(using=None)

Deletes the post instance.

is_alone

Returns True if the post is the only single post of the topic.

is_topic_head

Returns True if the post is the first post of the topic.

is_topic_tail

Returns True if the post is the last post of the topic.

position

Returns an integer corresponding to the position of the post in the topic.

save(*args, **kwargs)

Saves the post instance.

class machina.apps.forum_conversation.abstract_models.AbstractTopic(*args, **kwargs)

Bases: django.db.models.base.Model

Represents a forum topic.

clean()

Validates the topic instance.

delete(using=None)

Deletes the forum instance.

has_subscriber(user)

Returns True if the given user is a subscriber of this topic.

is_announce

Returns True if the topic is an announce.

is_locked

Returns True if the topic is locked.

is_sticky

Returns True if the topic is a sticky topic.

is_topic

Returns True if the topic is a default topic.

save(*args, **kwargs)

Saves the topic instance.

update_trackers()

Updates the denormalized trackers associated with the topic instance.

Views

Forum conversation views

This module defines views provided by the forum_conversation application.

class machina.apps.forum_conversation.views.BasePostFormView(**kwargs)

Bases: django.views.generic.edit.FormView

A base view for handling post forms.

attachment_formset_class

alias of django.forms.formsets.AttachmentFormFormSet

form_invalid(post_form, attachment_formset, **kwargs)

Processes invalid forms.

Called if one of the forms is invalid. Re-renders the context data with the data-filled forms and errors.

form_valid(post_form, attachment_formset, **kwargs)

Processes valid forms.

Called if all forms are valid. Creates a Post instance along with associated attachments if required and then redirects to a success page.

get(request, *args, **kwargs)

Handles GET requests.

get_attachment_formset(formset_class)

Returns an instance of the attachment formset to be used in the view.

get_attachment_formset_class()

Returns the attachment formset class to use to initialize the attachment formset.

get_attachment_formset_kwargs()

Returns the keyword arguments for instantiating the attachment formset.

get_attachments_cache_key(request)

Returns the key used to store attachment files states into the file based cache.

get_context_data(**kwargs)

Returns the context data to provide to the template.

get_forum()

Returns the considered forum.

get_post()

Returns the considered post if applicable.

get_post_form(form_class)

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

get_post_form_class()

Returns the post form class to use for instantiating the form.

get_post_form_kwargs()

Returns the keyword arguments for instantiating the post form.

get_topic()

Returns the considered topic if applicable.

init_attachment_cache()

Initializes the attachment cache for the current view.

post(request, *args, **kwargs)

Handles POST requests.

post_form_class

alias of machina.apps.forum_conversation.forms.PostForm

class machina.apps.forum_conversation.views.BaseTopicFormView(**kwargs)

Bases: machina.apps.forum_conversation.views.BasePostFormView

A base view for handling topic forms.

form_invalid(post_form, attachment_formset, poll_option_formset, **kwargs)

Processes invalid forms.

form_valid(post_form, attachment_formset, poll_option_formset, **kwargs)

Processes valid forms.

get(request, *args, **kwargs)

Handles GET requests.

get_context_data(**kwargs)

Returns the context data to provide to the template.

get_poll_option_formset(formset_class)

Returns an instance of the poll option formset to be used in the view.

get_poll_option_formset_class()

Returns the poll option formset class to use to initialize the poll option formset.

get_poll_option_formset_kwargs()

Returns the keyword arguments for instantiating the poll option formset.

poll_option_formset_class

alias of django.forms.formsets.TopicPollOptionFormFormSet

post(request, *args, **kwargs)

Handles POST requests.

post_form_class

alias of machina.apps.forum_conversation.forms.TopicForm

class machina.apps.forum_conversation.views.PostCreateView(**kwargs)

Bases: machina.apps.forum_permission.viewmixins.PermissionRequiredMixin, machina.apps.forum_conversation.views.PostFormView

Allows users to create forum posts.

get(request, *args, **kwargs)

Handles GET requests.

get_context_data(**kwargs)

Returns the context data to provide to the template.

get_controlled_object()

Returns the controlled object.

get_success_url()

Returns the URL to redirect the user to upon valid form processing.

model

alias of machina.core.db.models.Post

perform_permissions_check(user, obj, perms)

Performs the permission check.

post(request, *args, **kwargs)

Handles POST requests.

class machina.apps.forum_conversation.views.PostDeleteView(**kwargs)

Bases: machina.apps.forum_permission.viewmixins.PermissionRequiredMixin, django.views.generic.edit.DeleteView

Allows users to delete forum topics.

get_context_data(**kwargs)

Returns the context data to provide to the template.

get_controlled_object()

Returns the controlled object.

get_success_url()

Returns the URL to redirect the user to upon valid form processing.

model

alias of machina.core.db.models.Post

perform_permissions_check(user, obj, perms)

Performs the permission check.

class machina.apps.forum_conversation.views.PostFormView(**kwargs)

Bases: django.views.generic.detail.SingleObjectMixin, machina.apps.forum_conversation.views.BasePostFormView

A base view for manipulating post forms.

class machina.apps.forum_conversation.views.PostUpdateView(**kwargs)

Bases: machina.apps.forum_permission.viewmixins.PermissionRequiredMixin, machina.apps.forum_conversation.views.PostFormView

Allows users to update forum topics.

get(request, *args, **kwargs)

Handles GET requests.

get_controlled_object()

Returns the controlled object.

get_object(queryset=None)

Returns the considered object.

get_success_url()

Returns the URL to redirect the user to upon valid form processing.

model

alias of machina.core.db.models.Post

perform_permissions_check(user, obj, perms)

Performs the permission check.

post(request, *args, **kwargs)

Handles POST requests.

class machina.apps.forum_conversation.views.TopicCreateView(**kwargs)

Bases: machina.apps.forum_permission.viewmixins.PermissionRequiredMixin, machina.apps.forum_conversation.views.TopicFormView

Allows users to create forum topics.

get(request, *args, **kwargs)

Handles GET requests.

get_controlled_object()

Returns the controlled object.

get_success_url()

Returns the URL to redirect the user to upon valid form processing.

model

alias of tests._testsite.apps.forum_conversation.models.Topic

post(request, *args, **kwargs)

Handles POST requests.

class machina.apps.forum_conversation.views.TopicFormView(**kwargs)

Bases: django.views.generic.detail.SingleObjectMixin, machina.apps.forum_conversation.views.BaseTopicFormView

A base view for manipulating topic forms.

class machina.apps.forum_conversation.views.TopicUpdateView(**kwargs)

Bases: machina.apps.forum_permission.viewmixins.PermissionRequiredMixin, machina.apps.forum_conversation.views.TopicFormView

Allows users to update forum topics.

get(request, *args, **kwargs)

Handles GET requests.

get_controlled_object()

Returns the controlled object.

get_object(queryset=None)

Returns the considered object.

get_post()

Returns the considered post if applicable.

get_success_url()

Returns the URL to redirect the user to upon valid form processing.

model

alias of tests._testsite.apps.forum_conversation.models.Topic

perform_permissions_check(user, obj, perms)

Performs the permission check.

post(request, *args, **kwargs)

Handles POST requests.

class machina.apps.forum_conversation.views.TopicView(**kwargs)

Bases: machina.apps.forum_permission.viewmixins.PermissionRequiredMixin, django.views.generic.list.ListView

Displays a forum topic.

get(request, **kwargs)

Handles GET requests.

get_context_data(**kwargs)

Returns the context data to provide to the template.

get_controlled_object()

Returns the controlled object.

get_queryset()

Returns the list of items for this view.

get_topic()

Returns the topic to consider.

poll_form_class

alias of machina.apps.forum_conversation.forum_polls.forms.TopicPollVoteForm

send_signal(request, response, topic)

Sends the signal associated with the view.