beat.web.common.models module

class beat.web.common.models.ShareableManager[source]

Bases: django.db.models.manager.Manager

for_user(user, add_public=False)[source]
public()[source]
beat.web.common.models.AccessibilityInfo

alias of beat.web.common.models.Accessibility

class beat.web.common.models.Shareable(*args, **kwargs)[source]

Bases: django.db.models.base.Model

PRIVATE = 'P'
SHARED = 'S'
PUBLIC = 'A'
USABLE = 'U'
SHARING_STATUS = (('P', 'Private'), ('S', 'Shared'), ('A', 'Public'), ('U', 'Usable'))
sharing

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

shared_with

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

shared_with_team

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects
class Meta[source]

Bases: object

abstract = False
model_name()[source]
save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

get_verbose_name()[source]
get_verbose_name_plural()[source]
modifiable()[source]
deletable()[source]
accessibility_for(user_or_team, without_usable=False)[source]

Returns a tuple (<has_access>, <accessibility>), with <accessibility> being either ‘public’, ‘private’, ‘confidential’

is_accessible(users=None, teams=None)[source]
share(users=None, teams=None)[source]
sharing_preferences()[source]
all_shared_with_users()[source]

Returns a list of users this object is shared with

users_with_access()[source]

Returns a set of users that have access to this environment

get_sharing_display(*, field=<django.db.models.fields.CharField: sharing>)
class beat.web.common.models.VersionableManager[source]

Bases: beat.web.common.models.ShareableManager

is_last_version(object)[source]
create_object(name, short_description='', description='', declaration=None, version=1, previous_version=None, fork_of=None)[source]
class beat.web.common.models.Versionable(*args, **kwargs)[source]

Bases: beat.web.common.models.Shareable

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

version

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

short_description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

creation_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

hash

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

previous_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

fork_of

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

objects
class Meta[source]

Bases: beat.web.common.models.Meta

abstract = False
ordering = ['name', '-version']
static sanitize_name(name)[source]

Makes sure that the name is valid

static filter_latest_versions(versionables)[source]
delete(*args, **kwargs)[source]
modifiable()[source]
history(for_user)[source]

Calculates its own history and returns it in a dictionary.

The history shows all related objects which are accessible either forwards or backwards to this own. Accessibility is calculated based on the user passed. The user can be anonymous.

api_history(for_user)[source]

The same as history(), but providing an implementation compatible with our V1 API

json_history(for_user)[source]

The same as API history, but serializes the result into a JSON

fork_of_id
get_next_by_creation_date(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=True, **kwargs)
get_previous_by_creation_date(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=False, **kwargs)
get_sharing_display(*, field=<django.db.models.fields.CharField: sharing>)
previous_version_id
shared_with

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

shared_with_team

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class beat.web.common.models.ContributionManager[source]

Bases: beat.web.common.models.VersionableManager

get_by_natural_key(username, name, version)[source]
is_last_version(object)[source]
from_author(user, author_name, add_public=False)[source]
from_author_and_public(user, author_name)[source]
class beat.web.common.models.Contribution(*args, **kwargs)[source]

Bases: beat.web.common.models.Versionable

author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

objects
class Meta[source]

Bases: beat.web.common.models.Meta

abstract = False
ordering = ['author__username', 'name', 'version']
unique_together = ('author', 'name', 'version')
natural_key()[source]
fullname()[source]
static filter_latest_versions(contributions)[source]
author_id
fork_of

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

get_next_by_creation_date(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=True, **kwargs)
get_previous_by_creation_date(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=False, **kwargs)
get_sharing_display(*, field=<django.db.models.fields.CharField: sharing>)
previous_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

shared_with

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

shared_with_team

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class beat.web.common.models.StoredContributionManager[source]

Bases: beat.web.common.models.ContributionManager

create_object(author, name, short_description='', description='', declaration=None, version=1, previous_version=None, fork_of=None)[source]
beat.web.common.models.get_contribution_declaration_filename(obj, path)[source]
beat.web.common.models.get_contribution_description_filename(obj, path)[source]
beat.web.common.models.set_declaration(instance, value)[source]
beat.web.common.models.get_declaration(instance)[source]
beat.web.common.models.get_declaration_string(instance)[source]
beat.web.common.models.set_description(instance, value)[source]
beat.web.common.models.get_description(instance)[source]
class beat.web.common.models.StoredContribution(*args, **kwargs)[source]

Bases: beat.web.common.models.Contribution

objects
class Meta[source]

Bases: beat.web.common.models.Meta

abstract = False
hashed_path(extension='')[source]

Relative path of a file belonging to the object on the respective storage

declaration_filename()[source]

Relative path of the declaration file on the storage

description_filename()[source]

Relative path of the description file on the storage

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

property description
property declaration
property declaration_string
author

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

fork_of

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

get_next_by_creation_date(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=True, **kwargs)
get_previous_by_creation_date(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=False, **kwargs)
get_sharing_display(*, field=<django.db.models.fields.CharField: sharing>)
previous_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

shared_with

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

shared_with_team

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.