assembl.models.notification module

Allow users to be notified of certain events happening in a discussion. Depends on subscribing to those events.

exception assembl.models.notification.MissingEmailException[source]

Bases: Exception

class assembl.models.notification.ModelEventWatcherNotificationSubscriptionDispatcher[source]

Bases: assembl.lib.model_watcher.BaseModelEventWatcher

Calls NotificationSubscription.process() on the appropriate NotificationSubscription subclass when a certain CRUD event is detected through the assembl.lib.model_watcher.IModelEventWatcher protocol

class assembl.models.notification.Notification(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

A notification to a user about some situation.

first_matching_subscription_id

An annonymous pointer to the database object that originated the event

get_applicable_subscriptions()[source]

Fist matching_subscription is guaranteed to always be on top

get_notification_subject()[source]

Typically for email

get_to_email_address()[source]
Raises

UnverifiedEmailException: If the prefered email isn’t validated

render_to_email_html_part()[source]

Override in child classes if your notification can be represented as email HTML part. Otherwise return a falsy string (len must be defined)

render_to_email_text_part()[source]

Override in child classes if your notification can be represented as email HTML part. Otherwise return a falsy string (len must be defined)

class assembl.models.notification.NotificationCreationOrigin[source]

Bases: assembl.lib.decl_enums.DeclEnum

class assembl.models.notification.NotificationDeliveryConfirmationType[source]

Bases: assembl.lib.decl_enums.DeclEnum

The type of event that caused the notification to be created

class assembl.models.notification.NotificationDeliveryStateType[source]

Bases: assembl.lib.decl_enums.DeclEnum

The delivery state of the notification. Essentially it’s licefycle

class assembl.models.notification.NotificationOnPost(**kwargs)[source]

Bases: assembl.models.notification.Notification

first_matching_subscription_id

An annonymous pointer to the database object that originated the event

class assembl.models.notification.NotificationOnPostCreated(**kwargs)[source]

Bases: assembl.models.notification.NotificationOnPost

first_matching_subscription_id

An annonymous pointer to the database object that originated the event

get_notification_subject()[source]

Typically for email

render_to_email_html_part()[source]

Override in child classes if your notification can be represented as email HTML part. Otherwise return a falsy string (len must be defined)

class assembl.models.notification.NotificationPushMethodType[source]

Bases: assembl.lib.decl_enums.DeclEnum

The type of event that caused the notification to be created

class assembl.models.notification.NotificationSubscription(**kwargs)[source]

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

A subscription to a specific type of notification.

Subclasses will implement the actual code.

classmethod findApplicableInstances(discussion_id, verb, object, user=None)[source]

Returns all subscriptions that would fire on the object, and verb given

This naive implementation instanciates every ACTIVE subscription for every user, and calls “would fire” for each. It is expected that most subclasses will override this with a more optimal implementation

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_human_readable_description()[source]

A human readable description of this notification subscription Default implementation, expected to be overriden by child classes

is_owner(user_id)[source]

The user owns this ressource, and has more permissions.

process(discussion_id, verb, objectInstance, otherApplicableSubscriptions)[source]

Process a CRUD event on a model, creating Notification as appropriate

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

Filter query according to object owners. Also allow to read subscriptions of templates.

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.

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.notification.NotificationSubscriptionClasses[source]

Bases: assembl.lib.decl_enums.DeclEnum

class assembl.models.notification.NotificationSubscriptionFollowAllMessages(**kwargs)[source]

Bases: assembl.models.notification.NotificationSubscriptionGlobal

get_human_readable_description()[source]

A human readable description of this notification subscription Default implementation, expected to be overriden by child classes

process(discussion_id, verb, objectInstance, otherApplicableSubscriptions)[source]

Process a CRUD event on a model, creating Notification as appropriate

class assembl.models.notification.NotificationSubscriptionFollowOwnMessageDirectReplies(**kwargs)[source]

Bases: assembl.models.notification.NotificationSubscriptionGlobal

get_human_readable_description()[source]

A human readable description of this notification subscription Default implementation, expected to be overriden by child classes

process(discussion_id, verb, objectInstance, otherApplicableSubscriptions)[source]

Process a CRUD event on a model, creating Notification as appropriate

class assembl.models.notification.NotificationSubscriptionFollowSyntheses(**kwargs)[source]

Bases: assembl.models.notification.NotificationSubscriptionGlobal

get_human_readable_description()[source]

A human readable description of this notification subscription Default implementation, expected to be overriden by child classes

process(discussion_id, verb, objectInstance, otherApplicableSubscriptions)[source]

Process a CRUD event on a model, creating Notification as appropriate

class assembl.models.notification.NotificationSubscriptionGlobal(**kwargs)[source]

Bases: assembl.models.notification.NotificationSubscription

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

Bases: assembl.models.notification.NotificationSubscriptionOnObject

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

Bases: assembl.models.notification.NotificationSubscriptionOnObject

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

Bases: assembl.models.notification.NotificationSubscription

class assembl.models.notification.NotificationSubscriptionOnPost(**kwargs)[source]

Bases: assembl.models.notification.NotificationSubscriptionOnObject

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

Bases: assembl.models.notification.NotificationSubscriptionOnObject

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.notification.NotificationSubscriptionStatus[source]

Bases: assembl.lib.decl_enums.DeclEnum

class assembl.models.notification.SafeMIMEText(text, subtype, charset)[source]

Bases: email.mime.text.MIMEText

exception assembl.models.notification.UnverifiedEmailException[source]

Bases: Exception