assembl.models.permissions module

All classes relative to permissions.

class assembl.models.permissions.AbstractLocalUserRole(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase, assembl.lib.sqla.PrivateObjectMixin

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

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

filter query according to object owners

class assembl.models.permissions.DiscussionPermission(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase

Which permissions are given to which roles for a given discussion.

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.

class assembl.models.permissions.LocalUserRole(**kwargs)[source]

Bases: assembl.models.permissions.AbstractLocalUserRole

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

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

Return a list of SQLA expressions that will filter out instances of this class

Mostly used to exclude archived versions; see assembl.lib.history_mixin The exclusion pattern is used by the traversal API, and by the RDF mapping.

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.

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.

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.

classmethod user_can_cls(user_id, operation, permissions)[source]

Whether the user, with the given permissions, can perform the given Crud operation on instances of this class.

class assembl.models.permissions.Permission(**kwargs)[source]

Bases: assembl.models.NamedClassMixin, sqlalchemy.ext.declarative.api.Base

A permission that a user may have

class assembl.models.permissions.Role(**kwargs)[source]

Bases: assembl.models.NamedClassMixin, sqlalchemy.ext.declarative.api.Base

A role that a user may have in a discussion

class assembl.models.permissions.UserRole(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, assembl.lib.sqla.PrivateObjectMixin

roles that a user has globally (eg admin.)

container_url()[source]

What is the URL where we expect to find this resource

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

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

filter query according to object owners

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.

class assembl.models.permissions.UserTemplate(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase, assembl.models.auth.User

A fake user with default permissions and Notification Subscriptions.

classmethod get_applicable_notification_subscriptions_classes()[source]

The classes of notifications subscriptions that make sense to put in a template user.

Right now, that is all concrete classes that are global to the discussion.

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.

get_notification_subscriptions()[source]

the notification subscriptions for this user and discussion. Includes materialized subscriptions from the template.

get_notification_subscriptions_and_changed(on_thread=True)[source]

the notification subscriptions for this template. Materializes applicable subscriptions..