marsha.core package

Submodules

marsha.core.admin module

Admin of the core app of the Marsha project.

class marsha.core.admin.AudioTrackInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for audio tracks of a video.

media
model

alias of marsha.core.models.AudioTrack

class marsha.core.admin.AuthorOrganizationsInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for organizations the user is an author of.

media
model

alias of marsha.core.models.Authoring

verbose_name = 'authoring organization'
verbose_name_plural = 'authoring organizations'
class marsha.core.admin.BaseModelAdmin(model, admin_site)[source]

Bases: safedelete.admin.SafeDeleteAdmin

Base for all our model admins.

media
class marsha.core.admin.BaseTabularInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.TabularInline

Base for all our tabular inlines.

media
class marsha.core.admin.ConsumerSiteAdmin(model, admin_site)[source]

Bases: marsha.core.admin.BaseModelAdmin

Admin class for the ConsumerSite model.

inlines = [<class 'marsha.core.admin.SiteAdminsInline'>, <class 'marsha.core.admin.SiteOrganizationsInline'>]
list_display = ('name',)
media
class marsha.core.admin.ManagedOrganizationsInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for organizations managed by a user.

media
model

alias of marsha.core.models.OrganizationManager

verbose_name = 'managed organization'
verbose_name_plural = 'managed organizations'
class marsha.core.admin.MarshaAdminSite(name='admin')[source]

Bases: django.contrib.admin.sites.AdminSite

Admin site for Marsha.

site_header = 'Marsha'
site_title = 'Marsha administration'
class marsha.core.admin.OrganizationAdmin(model, admin_site)[source]

Bases: marsha.core.admin.BaseModelAdmin

Admin class for the Organization model.

inlines = [<class 'marsha.core.admin.OrganizationManagersInline'>, <class 'marsha.core.admin.OrganizationSitesInline'>, <class 'marsha.core.admin.OrganizationAuthorsInline'>]
list_display = ('name',)
media
class marsha.core.admin.OrganizationAuthorsInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for authors in an organization.

media
model

alias of marsha.core.models.Authoring

verbose_name = 'author'
verbose_name_plural = 'authors'
class marsha.core.admin.OrganizationManagersInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for managers in an organization.

media
model

alias of marsha.core.models.OrganizationManager

verbose_name = 'manager'
verbose_name_plural = 'managers'
class marsha.core.admin.OrganizationSitesInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for sites for an organization.

media
model

alias of marsha.core.models.SiteOrganization

verbose_name = 'site'
verbose_name_plural = 'sites'
class marsha.core.admin.PlaylistAdmin(model, admin_site)[source]

Bases: marsha.core.admin.BaseModelAdmin

Admin class for the Playlist model.

exclude = ('duplicated_from',)
inlines = [<class 'marsha.core.admin.PlaylistVideosInline'>, <class 'marsha.core.admin.PlaystlistAccessesInline'>]
list_display = ('name', 'organization', 'author', 'is_public')
media
class marsha.core.admin.PlaylistVideosInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for videos in a playlist.

media
model

alias of marsha.core.models.PlaylistVideo

verbose_name = 'video'
verbose_name_plural = 'videos'
class marsha.core.admin.PlaystlistAccessesInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for with right to write access to a playlist.

media
model

alias of marsha.core.models.PlaylistAccess

verbose_name = 'user access'
verbose_name_plural = 'users accesses'
class marsha.core.admin.SignTrackInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for sign tracks of a video.

media
model

alias of marsha.core.models.SignTrack

class marsha.core.admin.SiteAdminsInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for admins of a site.

media
model

alias of marsha.core.models.SiteAdmin

verbose_name = 'admin'
verbose_name_plural = 'admins'
class marsha.core.admin.SiteOrganizationsInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for organizations in a site.

media
model

alias of marsha.core.models.SiteOrganization

verbose_name = 'organization'
verbose_name_plural = 'organizations'
class marsha.core.admin.SubtitleTrackInline(parent_model, admin_site)[source]

Bases: marsha.core.admin.BaseTabularInline

Inline for subtitle tracks of a video.

media
model

alias of marsha.core.models.SubtitleTrack

class marsha.core.admin.UserAdmin(model, admin_site)[source]

Bases: django.contrib.auth.admin.UserAdmin

Admin class for the User model.

inlines = [<class 'marsha.core.admin.ManagedOrganizationsInline'>, <class 'marsha.core.admin.AuthorOrganizationsInline'>]
media
class marsha.core.admin.VideoAdmin(model, admin_site)[source]

Bases: marsha.core.admin.BaseModelAdmin

Admin class for the Video model.

exclude = ('duplicated_from',)
inlines = [<class 'marsha.core.admin.AudioTrackInline'>, <class 'marsha.core.admin.SubtitleTrackInline'>, <class 'marsha.core.admin.SignTrackInline'>]
list_display = ('name', 'author', 'language')
media

marsha.core.apps module

Defines the django app config for the core app.

class marsha.core.apps.CoreConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

Django app config for the core app.

name = 'marsha.core'
verbose_name = 'Marsha'

marsha.core.base_models module

Base models for the core app of the Marsha project.

class marsha.core.base_models.BaseModel(*args, **kwargs)[source]

Bases: safedelete.models.SafeDeleteModel

Base model for all our models.

It is based on SafeDeleteModel to easily manage how we want the instances to be deleted/soft-deleted, with or without its relationships. The default safedelete policy is SOFT_DELETE_CASCADE, ie the object to delete and its relations will be soft deleted: their deleted field will be filled with the current date-time (the opposite, None, is the same as “not deleted”)

Also it adds some checks run with django check:
  • check that all fields are correctly annotated.
  • same for fields pointing to other models: final models must have all related

names properly annotated. - check that every ManyToManyField use a defined through table. - check that every model have a db_table defined, not prefixed with the name of the app or the project.

Parameters:deleted (DateTimeField) – Deleted
classmethod check(**kwargs) → List[django.core.checks.messages.CheckMessage][source]

Add checks for related names.

Parameters:kwargs (Any) – Actually not used but asked by django to be present “for possible future usage”.
Returns:A list of the check messages representing problems found on the model.
Return type:List[checks.CheckMessage]
validate_unique(exclude: List[str] = None) → None[source]

Add validation for our NonDeletedUniqueIndex replacing unique_together.

For the parameters, see django.db.models.base.Model.validate_unique.

class marsha.core.base_models.NonDeletedUniqueIndex(fields: Sequence, name: str = None) → None[source]

Bases: psqlextra.indexes.conditional_unique_index.ConditionalUniqueIndex

A special ConditionalUniqueIndex for non deleted objects.

__init__(fields: Sequence, name: str = None) → None[source]

Override default init to pass our predefined condition.

For the parameters, see ConditionalUniqueIndex.__init__.

condition = '"deleted" IS NULL'
deconstruct()[source]

Remove condition as an argument to be defined in migrations.

marsha.core.managers module

This module holds the managers for the marsha models.

class marsha.core.managers.UserManager(queryset_class=None, *args, **kwargs)[source]

Bases: django.contrib.auth.models.UserManager, safedelete.managers.SafeDeleteManager

Extends the default manager for users with the one for soft-deletion.

marsha.core.models module

This module holds the models for the marsha project.

class marsha.core.models.AudioTrack(*args, **kwargs)[source]

Bases: marsha.core.models.BaseTrack

Model representing an additional audio track for a video.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • video (ForeignKey to Video) – video for which this track is
  • language (CharField) – language of this track
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

get_language_display(*, field=<django.db.models.fields.CharField: language>)

Autogenerated: Shows the label of the language

id

Model field: ID

video

Model field: video, accesses the Video model.

class marsha.core.models.Authoring(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing authors in an organization.

through model between Organization.authors and User.authoring.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • user (ForeignKey to User) – user having authoring access in this organization
  • organization (ForeignKey to Organization) – organization on which the user is an author
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

Model field: ID

organization

Model field: organization, accesses the Organization model.

organization_id

Model field: organization

user

Model field: author, accesses the User model.

user_id

Model field: author

class marsha.core.models.BaseTrack(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Base model for different kinds of tracks tied to a video.

Parameters:
  • deleted (DateTimeField) – Deleted
  • video (ForeignKey to Video) – video for which this track is
  • language (CharField) – language of this track
get_language_display(*, field=<django.db.models.fields.CharField: language>)

Autogenerated: Shows the label of the language

language

Model field: track language

video

Model field: video, accesses the Video model.

video_id

Model field: video

class marsha.core.models.ConsumerSite(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing an external site with access to the Marsha instance.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • name (CharField) – Name of the site
  • admins (ManyToManyField) – users able to manage this site
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

admins

Model field: administrators, accesses the M2M ConsumerSite model.

id

Model field: ID

name

Model field: name

organizations

Model field: sites, accesses the M2M Organization model.

Model field: site, accesses the M2M SiteOrganization model.

sites_admins

Model field: site, accesses the M2M SiteAdmin model.

class marsha.core.models.Organization(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing an organization to manage its playlists on one or many sites.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • name (CharField) – name of the organization
  • sites (ManyToManyField) – sites where this organization is present
  • managers (ManyToManyField) – users able to manage this organization
  • authors (ManyToManyField) – users able to manage playlists in this organization
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

authoring

Model field: organization, accesses the M2M Authoring model.

authors

Model field: authors, accesses the M2M Organization model.

id

Model field: ID

managers

Model field: managers, accesses the M2M Organization model.

Model field: organization, accesses the M2M OrganizationManager model.

name

Model field: name

playlists

Model field: organization, accesses the M2M Playlist model.

sites

Model field: sites, accesses the M2M Organization model.

Model field: organization, accesses the M2M SiteOrganization model.

class marsha.core.models.OrganizationManager(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing managers of organizations.

through model between Organization.managers and User.managed_organizations.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • user (ForeignKey to User) – user managing this organization
  • organization (ForeignKey to Organization) – organization managed by this user
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

Model field: ID

organization

Model field: organization, accesses the Organization model.

organization_id

Model field: organization

user

Model field: manager, accesses the User model.

user_id

Model field: manager

class marsha.core.models.Playlist(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing a playlist which is a list of videos.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • name (CharField) – name of the playlist
  • organization (ForeignKey to Organization) – Organization
  • author (ForeignKey to User) – Author
  • is_public (BooleanField) – if this playlist can be viewed without any access control
  • duplicated_from (ForeignKey to Playlist) – original playlist this one was duplicated from
  • editors (ManyToManyField) – users allowed to manage this playlist
  • videos (ManyToManyField) – videos in this playlist
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

author

Model field: author, accesses the User model.

author_id

Model field: author

duplicated_from

Model field: duplicate from, accesses the Playlist model.

duplicated_from_id

Model field: duplicate from

duplicates

Model field: duplicate from, accesses the M2M Playlist model.

editors

Model field: editors, accesses the M2M Playlist model.

id

Model field: ID

is_public

Model field: is public

name

Model field: name

organization

Model field: organization, accesses the Organization model.

organization_id

Model field: organization

users_accesses

Model field: playlist, accesses the M2M PlaylistAccess model.

videos

Model field: videos, accesses the M2M Playlist model.

Model field: playlist, accesses the M2M PlaylistVideo model.

class marsha.core.models.PlaylistAccess(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing a user having right to manage a playlist.

through model between Playlist.editors and User.managed_playlists.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • user (ForeignKey to User) – user having rights to manage this playlist
  • playlist (ForeignKey to Playlist) – playlist the user has rights to manage
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

Model field: ID

playlist

Model field: playlist, accesses the Playlist model.

playlist_id

Model field: playlist

user

Model field: user, accesses the User model.

user_id

Model field: user

class marsha.core.models.PlaylistVideo(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing a video in a playlist.

through model between Playlist.videos and Video.playlists.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • video (ForeignKey to Video) – video contained in this playlist
  • playlist (ForeignKey to Playlist) – playlist containing this video
  • order (PositiveIntegerField) – video order in the playlist
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

Model field: ID

order

Model field: order

playlist

Model field: playlist, accesses the Playlist model.

playlist_id

Model field: playlist

video

Model field: video, accesses the Video model.

video_id

Model field: video

class marsha.core.models.SignTrack(*args, **kwargs)[source]

Bases: marsha.core.models.BaseTrack

Model representing a signs language track for a video.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • video (ForeignKey to Video) – video for which this track is
  • language (CharField) – language of this track
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

get_language_display(*, field=<django.db.models.fields.CharField: language>)

Autogenerated: Shows the label of the language

id

Model field: ID

video

Model field: video, accesses the Video model.

class marsha.core.models.SiteAdmin(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing users with access to manage a site.

through model between ConsumerSite.admins and User.administrated_sites.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • user (ForeignKey to User) – user with access to the site
  • site (ForeignKey to ConsumerSite) – site to which the user has access
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

Model field: ID

site

Model field: site, accesses the ConsumerSite model.

site_id

Model field: site

user

Model field: user, accesses the User model.

user_id

Model field: user

class marsha.core.models.SiteOrganization(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing organizations in sites.

through model between Organization.sites and ConsumerSite.organizations.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • site (ForeignKey to ConsumerSite) – site having this organization
  • organization (ForeignKey to Organization) – organization in this site
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

Model field: ID

organization

Model field: organization, accesses the Organization model.

organization_id

Model field: organization

site

Model field: site, accesses the ConsumerSite model.

site_id

Model field: site

class marsha.core.models.SubtitleTrack(*args, **kwargs)[source]

Bases: marsha.core.models.BaseTrack

Model representing a subtitle track for a video.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • video (ForeignKey to Video) – video for which this track is
  • language (CharField) – language of this track
  • has_closed_captioning (BooleanField) – if closed captioning (for death or hard of hearing viewers) is on for this subtitle track
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

get_language_display(*, field=<django.db.models.fields.CharField: language>)

Autogenerated: Shows the label of the language

has_closed_captioning

Model field: closed captioning

id

Model field: ID

video

Model field: video, accesses the Video model.

class marsha.core.models.User(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel, django.contrib.auth.models.AbstractUser

Model representing a user that can be authenticated to act on the Marsha instance.

Parameters:
  • id (AutoField) – Id
  • password (CharField) – Password
  • last_login (DateTimeField) – Last login
  • is_superuser (BooleanField) – Designates that this user has all permissions without explicitly assigning them.
  • username (CharField) – Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • email (EmailField) – Email address
  • is_staff (BooleanField) – Designates whether the user can log into this admin site.
  • is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
  • date_joined (DateTimeField) – Date joined
  • deleted (DateTimeField) – Deleted
  • groups (ManyToManyField) – The groups this user belongs to. A user will get all permissions granted to each of their groups.
  • user_permissions (ManyToManyField) – Specific permissions for this user.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

administrated_sites

Model field: administrators, accesses the M2M ConsumerSite model.

author_organizations

Model field: authors, accesses the M2M Organization model.

authored_videos

Model field: author, accesses the M2M Video model.

authoring

Model field: author, accesses the M2M Authoring model.

created_playlists

Model field: author, accesses the M2M Playlist model.

get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)

Autogenerated: Finds next instance based on date_joined.

get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)

Autogenerated: Finds previous instance based on date_joined.

groups

Model field: groups, accesses the M2M User model.

id

Model field: ID

logentry_set

Model field: user, accesses the M2M LogEntry model.

managed_organizations

Model field: managers, accesses the M2M Organization model.

Model field: manager, accesses the M2M OrganizationManager model.

managed_playlists

Model field: editors, accesses the M2M Playlist model.

objects = <marsha.core.managers.UserManager object>
playlists_accesses

Model field: user, accesses the M2M PlaylistAccess model.

sites_admins

Model field: user, accesses the M2M SiteAdmin model.

user_permissions

Model field: user permissions, accesses the M2M User model.

class marsha.core.models.Video(*args, **kwargs)[source]

Bases: marsha.core.base_models.BaseModel

Model representing a video, by an author.

Parameters:
  • id (AutoField) – Id
  • deleted (DateTimeField) – Deleted
  • name (CharField) – name of the video
  • description (TextField) – description of the video
  • author (ForeignKey to User) – author of the video
  • language (CharField) – language of the video
  • duplicated_from (ForeignKey to Video) – original video this one was duplicated from
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

audiotracks

Model field: video, accesses the M2M AudioTrack model.

author

Model field: author, accesses the User model.

author_id

Model field: author

description

Model field: description

duplicated_from

Model field: duplicate from, accesses the Video model.

duplicated_from_id

Model field: duplicate from

duplicates

Model field: duplicate from, accesses the M2M Video model.

get_language_display(*, field=<django.db.models.fields.CharField: language>)

Autogenerated: Shows the label of the language

id

Model field: ID

language

Model field: language

name

Model field: name

playlists

Model field: videos, accesses the M2M Playlist model.

Model field: video, accesses the M2M PlaylistVideo model.

signtracks

Model field: video, accesses the M2M SignTrack model.

subtitletracks

Model field: video, accesses the M2M SubtitleTrack model.

marsha.core.views module

Views of the core app of the Marsha project.

Module contents

The core app of the Marsha project.