assembl.models.idea module

Defining the idea and links between ideas.

class assembl.models.idea.AppendingVisitor[source]

Bases: assembl.models.idea.IdeaVisitor

A Visitor that appends visit results to a list

class assembl.models.idea.Idea(**kwargs)[source]

Bases: assembl.lib.history_mixin.HistoryMixinWithOrigin, assembl.lib.sqla.TimestampedMixin, assembl.models.DiscussionBoundBase

An idea (or concept) distilled from the conversation flux.

copy(tombstone=None, db=None, **kwargs)[source]

Clone object, optionally as tombstone (aka snapshot) reuse base_id. Redefine in subclasses to define arguments

classmethod get_discussion_conditions(discussion_id, alias_maker=None)[source]

Returns a list of SQLA expressions that constrain a query on this class to a given discussion.

get_discussion_id()[source]

Get the ID of an associated discussion object, if any.

classmethod get_idea_ids_showing_post(post_id)[source]

Given a post, give the ID of the ideas that show this message

classmethod idea_read_counts(discussion_id, post_id, user_id)[source]

Given a post and a user, give the total and read count of posts for each affected idea

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

live

The live version of this object, if any.

namespaced_kv_class

alias of assembl.models.user_key_values.IdeaNamespacedKeyValue

populate_from_context(context)[source]

If object created in this context, populate some relations from that context.

This is the magic fallback, ideally define the relationships you want populated explicitly in subclasses of this.

classmethod restrict_to_owners_condition(query, user_id, alias=None, alias_maker=None)[source]

filter query according to object owners

send_to_changes(connection=None, operation=<CrudOperation.UPDATE: 0>, discussion_id=None, view_def='changes')[source]

invoke the modelWatcher on creation

classmethod special_quad_patterns(alias_maker, discussion_id)[source]

Returns a list of quad map patterns for RDF mapping, beyond those defined by introspection.

Important: If defined somewhere, override in subclasses to avoid inheritance.

Bases: assembl.lib.history_mixin.HistoryMixinWithOrigin, assembl.models.DiscussionBoundBase

A generic link between two ideas

If a parent-child relation, the parent is the source, the child the target. Note: it’s reversed in the RDF model.

classmethod base_conditions(alias=None, alias_maker=None)[source]

By default exclude tombstones

copy(tombstone=None, db=None, **kwargs)[source]

Clone object, optionally as tombstone (aka snapshot) reuse base_id. Redefine in subclasses to define arguments

classmethod get_discussion_conditions(discussion_id, alias_maker=None)[source]

Returns a list of SQLA expressions that constrain a query on this class to a given discussion.

get_discussion_id()[source]

Get the ID of an associated discussion object, if any.

live

The live version of this object, if any.

populate_from_context(context)[source]

If object created in this context, populate some relations from that context.

This is the magic fallback, ideally define the relationships you want populated explicitly in subclasses of this.

send_to_changes(connection=None, operation=<CrudOperation.UPDATE: 0>, discussion_id=None, view_def='changes')[source]

Ask for this object to be sent on the changes websocket.

See assembl.tasks.changes_router.

classmethod special_quad_patterns(alias_maker, discussion_id)[source]

Returns a list of quad map patterns for RDF mapping, beyond those defined by introspection.

Important: If defined somewhere, override in subclasses to avoid inheritance.

user_can(user_id, operation, permissions)[source]

Whether the user, with the given permissions, can perform the given Crud operation on this instance.

class assembl.models.idea.IdeaLinkVisitor[source]

Bases: object

A Visitor for the structure of IdeaLink

class assembl.models.idea.IdeaLocalUserRole(**kwargs)[source]

Bases: assembl.models.permissions.AbstractLocalUserRole

The role that a user has in the context of a discussion

container_url()[source]

What is the URL where we expect to find this resource

classmethod get_discussion_conditions(discussion_id, alias_maker=None)[source]

Returns a list of SQLA expressions that constrain a query on this class to a given discussion.

get_discussion_id()[source]

Get the ID of an associated discussion object, if any.

unique_query()[source]

returns a couple (query, usable), with a sqla query for conflicting similar objects. usable is true if the query has to be enforced; sometimes it makes sense to return un-usable query that will be used to construct queries of subclasses. Note that when a duplicate is found, you’ll often want to expunge the original.

class assembl.models.idea.IdeaVisitor[source]

Bases: object

A Visitor for the structure of Idea

The visit is started by Idea.visit_ideas_depth_first(), Idea.visit_ideas_breadth_first() or Idea.visit_idea_ids_depth_first()

class assembl.models.idea.RootIdea(*args, **kwargs)[source]

Bases: assembl.models.idea.Idea

The root idea. It represents the discussion.

It has implicit links to all content and posts in the discussion.

live

The live version of this object, if any.

num_contributors

In the root idea, num_posts is the count of contributors to all non-deleted mesages in the discussion

num_orphan_posts

The number of posts unrelated to any idea in the current discussion

num_posts

In the root idea, num_posts is the count of all non-deleted mesages in the discussion

num_read_posts

In the root idea, num_posts is the count of all non-deleted read mesages in the discussion

num_synthesis_posts

In the root idea, this is the count of all published and non-deleted SynthesisPost of the discussion

class assembl.models.idea.WordCountVisitor(langs, count_posts=True)[source]

Bases: assembl.models.idea.IdeaVisitor

A Visitor that counts words related to an idea

class assembl.models.idea.defaultdictlist[source]

Bases: collections.defaultdict

A defaultdict of lists.