assembl.models.auth module

All classes relative to users and their online identities.

class assembl.models.auth.AbstractAgentAccount(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

An abstract class for online accounts that identify AgentsProfiles

The main subclasses are EmailAccount and social_auth.SocialAuthAccount.

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

signature()[source]

Identity of signature implies identity of underlying account

update_from_json(json, user_id=None, context=None, object_importer=None, permissions=None, parse_def_name='default_reverse')[source]

Update (patch) an object from its JSON representation.

user_can(user_id, operation, permissions)[source]

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

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.auth.AgentProfile(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

An agent identified on the platform.

Agents can be User or simply the author of an imported message; they could also be a group, bot or computer. Agents have at least one AbstractAgentAccount.

count_posts_in_current_discussion()[source]

CAN ONLY BE CALLED FROM API V2

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

login_expiry(discussion=None)[source]

When will this account’s login expire, maybe in the context of a specific discussion.

login_expiry_req()[source]

Get login expiry date. May be None.

merge(other_profile)[source]

Merge another profile on this profile, because they are the same entity.

This identity is usually found out after an email account is verified, or a social account is added to another account. All foreign keys that refer to the other agent profile must now refer to this one.

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.

successful_login(social=False)[source]

A successful email login

class assembl.models.auth.AgentStatusInDiscussion(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase

Information about a user’s activity in a discussion

Whether the user has logged in and is subscribed to notifications.

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.

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

class assembl.models.auth.AnonymousUser(**kwargs)[source]

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

A fake anonymous user bound to a source.

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.auth.EmailAccount(**kwargs)[source]

Bases: assembl.models.auth.AbstractAgentAccount

An email account

merge(other)[source]

Merge another EmailAccount on this one, because they are the same email.

signature()[source]

Identity of signature implies identity of underlying account

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.auth.IdentityProvider(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

An identity provider (or sometimes a category of identity providers.)

This is a service that provides online identities, expressed as social_auth.SocialAuthAccount.

class assembl.models.auth.LanguagePreferenceCollection[source]

Bases: object

A collection of UserLanguagePreference, allowing to decide on which languages to display.

class assembl.models.auth.LanguagePreferenceCollectionWithDefault(locale_code)[source]

Bases: assembl.models.auth.LanguagePreferenceCollection

A LanguagePreferenceCollection with a fallback language.

class assembl.models.auth.LanguagePreferenceOrder[source]

Bases: enum.IntEnum

An enumeration.

class assembl.models.auth.PartnerOrganization(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase

A corporate entity that we want to display in the discussion’s page

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.

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.

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.auth.User(**kwargs)[source]

Bases: assembl.models.NamedClassMixin, assembl.lib.history_mixin.OriginMixin, assembl.models.auth.AgentProfile

A user of the platform.

get_notification_subscriptions(discussion_id, reset_defaults=False, request=None, on_thread=True)[source]

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

get_notification_subscriptions_for_current_discussion()[source]

CAN ONLY BE CALLED WITH A CURRENT REQUEST

merge(other_user)[source]

Merge another user on this one, because they are the same entity.

This identity is usually found out after an email account is verified, or a social account is added to another account. All foreign keys that refer to the other user must now refer to this one.

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

invoke the modelWatcher on creation/modification

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.auth.UserLanguagePreference(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Does this user wants data in this language to be displayed or translated?

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

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.auth.UserLanguagePreferenceCollection(user_id)[source]

Bases: assembl.models.auth.LanguagePreferenceCollection

A LanguagePreferenceCollection that represent one user’s preferences.