core.mixins package¶
core.mixins for the core of Eonvelope project.
- class core.mixins.DownloadMixin[source]¶
Bases:
objectMixin providing a property to check whether a model instance provides a download.
Designed for use in combination with
core.mixins.FilePathModelMixin.
- class core.mixins.FavoriteModelMixin(*args, **kwargs)[source]¶
Bases:
ModelMixin adding a favorite functionality to a model class.
- is_favorite¶
Flags favorite accounts. False by default.
- class Meta[source]¶
Bases:
objectMetadata class for the mixin, abstract to avoid makemigrations picking it up.
- abstract = False¶
- _meta = <Options for FavoriteModelMixin>¶
- class core.mixins.FilePathModelMixin(*args, **kwargs)[source]¶
Bases:
ModelMixin adding functionality for managing a single storage file for a model class.
- file_path¶
The relative path in the storage where the file is stored. Can be null if no file has been saved (null does not collide with the unique constraint.).
- class Meta[source]¶
Bases:
objectMetadata class for the mixin, abstract to avoid makemigrations picking it up.
- abstract = False¶
- save(*args, **kwargs)[source]¶
Extended :django:
django.models.Model.save()method.Saves the data to storage if configured.
- open_file(mode='rb')[source]¶
Opens and returns the stored file as a filestream.
Note
Use inside a with block.
- Parameters:
mode (
str) – The mode the file is opened in.- Return type:
- Returns:
The filestream of the file.
- Raises:
FileNotFoundError – If the file_path is not set or the file is not found in the storage.
- delete_file()[source]¶
Deletes the file and sets file_path to None.
Intended for use in a signal.
- Return type:
- _meta = <Options for FilePathModelMixin>¶
- class core.mixins.HealthModelMixin(*args, **kwargs)[source]¶
Bases:
ModelMixin adding a health functionality to a model class.
- is_healthy¶
Flags whether the model instance is subject to errors. None by default.
- last_error¶
The latest error in connection with the model instance.
- last_error_occurred_at¶
The time of occurrence of the latest error.
- class Meta[source]¶
Bases:
objectMetadata class for the mixin, abstract to avoid makemigrations picking it up.
- abstract = False¶
- _meta = <Options for HealthModelMixin>¶
- class core.mixins.ThumbnailMixin[source]¶
Bases:
objectMixin providing a property to check whether a model instance provides a thumbail image.
Designed for use in combination with
core.mixins.FilePathModelMixin.
- class core.mixins.TimestampModelMixin(*args, **kwargs)[source]¶
Bases:
ModelMixin adding creation and update timestamps to a model class.
- created¶
The datetime the model instance was created. Is set automatically.
- updated¶
The datetime the model instance entry was last updated. Is set automatically.
- class Meta[source]¶
Bases:
objectMetadata class for the mixin, abstract to avoid makemigrations picking it up.
- abstract = False¶
- get_latest_by = 'created'¶
- _meta = <Options for TimestampModelMixin>¶
- get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)¶
- get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)¶
- get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)¶
- class core.mixins.URLMixin[source]¶
Bases:
objectMixin to add url features to a
django.db.models.Model.- BASENAME = ''¶
- get_absolute_url()[source]¶
Gets the detail webview url for the model instance.
Note
Used by
django.views.generics.ModelFormMixinfor redirection.- Return type:
- Returns:
The detail webview url for the model instance.
- get_absolute_edit_url()[source]¶
Gets the edit webview url for the model instance.
- Return type:
- Returns:
The edit webview url for the model instance.
- get_absolute_list_url()[source]¶
Gets the list webview url for the model instance.
- Return type:
- Returns:
The list webview url for the model instance.
- get_absolute_table_url()[source]¶
Gets the table webview url for the model instance.
- Return type:
- Returns:
The table webview url for the model instance.
- get_absolute_api_list_url()[source]¶
Gets the list api url for the model instance.
- Return type:
- Returns:
The list api url for the model instance.
- classmethod get_list_web_url_name()[source]¶
Gets the list webview urlname for the model.
- Return type:
- Returns:
The list webview urlname for the model.
- classmethod get_table_web_url_name()[source]¶
Gets the list webview urlname for the model.
- Return type:
- Returns:
The list webview urlname for the model.
- class core.mixins.UploadMixin[source]¶
Bases:
objectMixin providing url methods for the upload page of the model.
- classmethod get_upload_web_url_name()[source]¶
Gets the edit webview urlname for the model.
- Return type:
- Returns:
The edit webview urlname for the model.
- get_absolute_upload_url()[source]¶
Gets the upload webview url for the model instance.
- Return type:
- Returns:
The upload webview url for the model instance.
- Parameters:
self (Uploadable)