swh.deposit.models module#

class swh.deposit.models.JSONField(verbose_name=None, name=None, encoder=None, decoder=None, **kwargs)[source]#

Bases: JSONField

deconstruct()[source]#

Return enough information to recreate the field as a 4-tuple:

  • The name of the field on the model, if contribute_to_class() has been run.

  • The import path of the field, including the class, e.g. django.db.models.IntegerField. This should be the most portable version, so less specific may be better.

  • A list of positional arguments.

  • A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):

  • None, bool, str, int, float, complex, set, frozenset, list, tuple, dict

  • UUID

  • datetime.datetime (naive), datetime.date

  • top-level classes, top-level functions - will be referenced by their full import path

  • Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.

There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.

class swh.deposit.models.Dbversion(*args, **kwargs)[source]#

Bases: Model

Db version

version#

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

release#

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

description#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

objects = <django.db.models.manager.Manager object>#
swh.deposit.models.DEPOSIT_STATUS = [('partial', 'partial'), ('expired', 'expired'), ('deposited', 'deposited'), ('verified', 'verified'), ('rejected', 'rejected'), ('loading', 'loading'), ('done', 'done'), ('failed', 'failed')]#

Possible status and the detailed meaning.

class swh.deposit.models.DepositClient(*args, **kwargs)[source]#

Bases: User

Deposit client

collections#

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

objects = <django.contrib.auth.models.UserManager object>#
provider_url#

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

domain#

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

oidc_user: OIDCUser | None = None#
exception DoesNotExist#

Bases: DoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

deposit_set#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

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

Parent.children is a ReverseManyToOneDescriptor instance.

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

user_ptr#

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

user_ptr_id#
class swh.deposit.models.Deposit(*args, **kwargs)[source]#

Bases: Model

Deposit reception table

id#

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

reception_date#

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

complete_date#

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

collection#

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.

external_id#

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

origin_url#

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

client#

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.

swhid#

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

swhid_context#

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

status#

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

status_detail#

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

parent#

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.

check_task_id#

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

load_task_id#

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

type#

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

software_version#

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

release_notes#

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

raw_metadata: str | None = None#
set_raw_metadata(raw_metadata: str) None[source]#

Set the metadata raw out of a ‘metadata’ typed deposit request. This is specifically used during listing.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

client_id#
collection_id#
deposit_set#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

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

Parent.children is a ReverseManyToOneDescriptor instance.

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

depositrequest_set#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

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

Parent.children is a ReverseManyToOneDescriptor instance.

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

get_next_by_reception_date(*, field=<django.db.models.fields.DateTimeField: reception_date>, is_next=True, **kwargs)#
get_previous_by_reception_date(*, field=<django.db.models.fields.DateTimeField: reception_date>, is_next=False, **kwargs)#
get_status_display(*, field=<django.db.models.fields.TextField: status>)#
get_type_display(*, field=<django.db.models.fields.CharField: type>)#
objects = <django.db.models.manager.Manager object>#
parent_id#
swh.deposit.models.client_directory_path(instance: DepositRequest, filename: str) str[source]#
Callable to determine the upload archive path. This defaults to

MEDIA_ROOT/client_<user_id>/%Y%m%d-%H%M%S.%f/<filename>.

The format “%Y%m%d-%H%M%S.%f” is the reception date of the associated deposit formatted using strftime.

Parameters:
  • instance – DepositRequest concerned by the upload

  • filename – Filename of the uploaded file

Returns:

The upload archive path.

class swh.deposit.models.DepositRequest(*args, **kwargs)[source]#

Bases: Model

Deposit request associated to one deposit.

id#

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

deposit#

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.

date#

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

metadata#

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

raw_metadata#

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

archive#

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
type#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

deposit_id#
get_next_by_date(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)#
get_previous_by_date(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)#
get_type_display(*, field=<django.db.models.fields.CharField: type>)#
objects = <django.db.models.manager.Manager object>#
class swh.deposit.models.DepositCollection(id, name)[source]#

Bases: Model

id#

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

name#

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

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

deposit_set#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

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

Parent.children is a ReverseManyToOneDescriptor instance.

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

objects = <django.db.models.manager.Manager object>#