Forum¶
The forum application provides the ability to browse a tree of forums. It is based on a single
AbstractForum abstract model.
Abstract models¶
Forum abstract models¶
This module defines abstract models provided by the forum application.
-
class
machina.apps.forum.abstract_models.AbstractForum(*args, **kwargs)¶ Bases:
mptt.models.MPTTModel,machina.models.abstract_models.DatedModelThe main forum model.
The tree hierarchy of forums and categories is managed by the MPTTModel which is part of django-mptt.
-
clean()¶ Validates the forum instance.
-
get_image_upload_to(filename)¶ Returns the path to upload a new associated image to.
-
is_category¶ Returns
Trueif the forum is a category.
-
is_forum¶ Returns
Trueif the forum is a a default forum.
-
is_link¶ Returns
Trueif the forum is a link.
-
margin_level¶ Returns a margin value computed from the forum node’s level.
Used in templates or menus to create an easy-to-see left margin to contrast a forum from their parents.
-
save(*args, **kwargs)¶ Saves the forum instance.
-
update_trackers()¶ Updates the denormalized trackers associated with the forum instance.
-
-
machina.apps.forum.abstract_models.get_forum_image_upload_to(instance, filename)¶ Returns a valid upload path for an image file associated with a forum instance.
Views¶
Forum views¶
This module defines views provided by the forum application.
-
class
machina.apps.forum.views.ForumView(**kwargs)¶ Bases:
machina.apps.forum_permission.viewmixins.PermissionRequiredMixin,django.views.generic.list.ListViewDisplays a forum and its topics. If applicable, its sub-forums can also be displayed.
-
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_forum()¶ Returns the forum to consider.
-
get_queryset()¶ Returns the list of items for this view.
-
send_signal(request, response, forum)¶ Sends the signal associated with the view.
-
Visibility¶
The visibility module¶
This module provides helper classes to manage and compute values that should be displayed when considering a tree of forums. This includes post counts, topic counts, siblings, …
-
class
machina.apps.forum.visibility.ForumVisibilityContentNode(obj)¶ Bases:
objectRepresents a forum object and its “visibility content”.
This class provides common properties that should help computing values such as posts counts or topics counts for a specific forum instance.
-
last_post¶ Returns the latest post associated with the node or one of its descendants.
-
last_post_on¶ Returns the latest post date associated with the node or one of its descendants.
-
next_sibling¶ Returns the next sibling of the current node.
The next sibling is searched in the parent node if we are not considering a top-level node. Otherwise it is searched inside the list of nodes (which should be sorted by tree ID) that is associated with the considered tree instance.
-
posts_count¶ Returns the number of posts associated with the current node and its descendants.
-
previous_sibling¶ Returns the previous sibling of the current node.
The previous sibling is searched in the parent node if we are not considering a top-level node. Otherwise it is searched inside the list of nodes (which should be sorted by tree ID) that is associated with the considered tree instance.
-
topics_count¶ Returns the number of topics associated with the current node and its descendants.
-
-
class
machina.apps.forum.visibility.ForumVisibilityContentTree(nodes=None)¶ Bases:
objectRepresents a tree of
ForumVisibilityContentNodeinstances.Such a tree can be used to easily compute sums or “global” values associated with a given set of forum instances. It can be useful to display forum information to a user (eg. in a list of forums, etc.).
-
as_dict¶ Returns a dictionary of forum ID / related node.
-
forums¶ Returns a list of
Foruminstances associated with the underlying nodes.
-
classmethod
from_forums(forums)¶ Initializes a
ForumVisibilityContentTreeinstance from a list of forums.
-
root_level¶ Returns the root level of the considered tree.
-
top_nodes¶ Returns only the node without immediate parent.
-
visible_forums¶ Returns only the forum instances associated with the current tree.
-
visible_nodes¶ Returns only the visible nodes associated with the current tree.
-