swh.web.alter.models module#
- class swh.web.alter.models.BaseModel(*args, **kwargs)[source]#
Bases:
Model
An abstract base model to provide UUID pks and timestamps.
- id#
UUID primary key
- created_at#
Creation date
- updated_at#
Last update
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)#
- class swh.web.alter.models.OriginOutcome(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
TextChoices
- VALIDATING = 'validating'#
- REJECTED = 'rejected'#
- MAILMAP = 'mailmap'#
- MASK = 'mask'#
- TAKEDOWN = 'takedown'#
- BLOCK = 'block'#
- class swh.web.alter.models.OriginOwnership(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
TextChoices
- UNKNOWN = 'unknown'#
- OWNER = 'owner'#
- FORK = 'fork'#
- OTHER = 'other'#
- class swh.web.alter.models.Origin(*args, **kwargs)[source]#
Bases:
BaseModel
Origins concerned by an Alteration.
- url#
Origin’s URL
- alteration#
Alteration FK
- outcome#
Outcome for this origin
- reason#
Outcome’s reason
- code_license#
License found in / guessed from the source code
- available#
URL is still available
- ownership#
Is Requester the owner of this origin or is it a fork
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- alteration_id#
- created_at#
Creation date
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)#
- get_outcome_display(*, field=<django.db.models.fields.CharField: outcome>)#
- get_ownership_display(*, field=<django.db.models.fields.CharField: ownership>)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)#
- id#
UUID primary key
- objects = <django.db.models.manager.Manager object>#
- updated_at#
Last update
- class swh.web.alter.models.AlterationManager(*args, **kwargs)[source]#
Bases:
Manager
Custom
Alteration
manager.
- class swh.web.alter.models.AlterationStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
TextChoices
- VALIDATING = 'validating'#
- PLANNING = 'planning'#
- EXECUTING = 'executing'#
- PROCESSED = 'processed'#
- REJECTED = 'rejected'#
- CLOSED = 'closed'#
- ARCHIVED = 'archived'#
- class swh.web.alter.models.AlterationCategory(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
TextChoices
- COPYRIGHT = 'copyright'#
- PII = 'pii'#
- LEGAL = 'legal'#
- class swh.web.alter.models.Alteration(*args, **kwargs)[source]#
Bases:
BaseModel
An alteration request.
- status#
Progression indicator
- category#
The category/type of this alteration
- reasons#
The alteration request reasons
- expected_outcome#
The Requester expectations
- email#
Requester’s email
- objects = <swh.web.alter.models.AlterationManager object>#
- classmethod create_from_assistant(session: SessionBase) Alteration [source]#
Create an alteration request from the alteration request assistant.
Email notifications are sent to the requester & operators.
- Parameters:
session – django’s session store
- Returns:
an Alteration instance
- Raises:
DatabaseError – something went wrong while creating objects in the database
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- created_at#
Creation date
- events#
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- get_category_display(*, field=<django.db.models.fields.CharField: category>)#
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)#
- get_status_display(*, field=<django.db.models.fields.CharField: status>)#
- id#
UUID primary key
- origins#
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- tokens#
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 aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- updated_at#
Last update
- class swh.web.alter.models.EventRecipient(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
TextChoices
- REQUESTER = 'requester'#
- SUPPORT = 'support'#
- MANAGER = 'manager'#
- LEGAL = 'legal'#
- TECHNICAL = 'technical'#
- class swh.web.alter.models.EventCategory(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
TextChoices
- LOG = 'log'#
- MESSAGE = 'message'#
- class swh.web.alter.models.EventManager(*args, **kwargs)[source]#
Bases:
Manager
Custom
Event
manager.
- class swh.web.alter.models.Event(*args, **kwargs)[source]#
Bases:
BaseModel
An event on an Alteration.
An event could be * a log of a status change or a modification of any another field / Origin * a message between recipients
- alteration#
Alteration FK
- category#
Category/type of event
- author#
The name of the author of this event
- recipient#
The role targeted by this event, a value is required to send notifications
- content#
The event’s textual content
- internal#
Internal actions are not visible to the Requester
- objects = <django.db.models.manager.Manager object>#
- public_objects = <swh.web.alter.models.EventManager object>#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- alteration_id#
- created_at#
Creation date
- get_category_display(*, field=<django.db.models.fields.CharField: category>)#
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)#
- get_recipient_display(*, field=<django.db.models.fields.CharField: recipient>)#
- id#
UUID primary key
- updated_at#
Last update
- swh.web.alter.models.TOKEN_TTL = 900#
Token expiration delay in seconds
- swh.web.alter.models.TOKEN_NBYTES = 20#
Token length, must be less than ~1.3 x Token.value max length
- class swh.web.alter.models.Token(*args, **kwargs)[source]#
Bases:
BaseModel
Ephemeral auth tokens to access an Alteration or validate an email.
- alteration#
Alteration FK
- email#
An email address to validate
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- alteration_id#
- created_at#
Creation date
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_next_by_expires_at(*, field=<django.db.models.fields.DateTimeField: expires_at>, is_next=True, **kwargs)#
- get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_previous_by_expires_at(*, field=<django.db.models.fields.DateTimeField: expires_at>, is_next=False, **kwargs)#
- get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)#
- id#
UUID primary key
- updated_at#
Last update
- value#
Token value
- expires_at#
Token expiration date
- objects = <django.db.models.manager.Manager object>#
- classmethod create_for(obj: Alteration | str) Token [source]#
Create a token for an Alteration request or an email verification.
- Parameters:
obj – an Alteration instance or an email
- Returns:
A Token instance
- Raises:
ValueError – obj is neither an Alteration nor an email
IntegrityError – if we’re not able to create a token after 5 attempts
- swh.web.alter.models.validate_email_or_domain(value: Any) None [source]#
Check if value is a valid email or a domain name.
- Parameters:
value – a string
- Raises:
ValidationError – value is neither an email address nor a domain name
- Returns:
True is value is an email or a domain
- class swh.web.alter.models.LowerCharField(*args, db_collation=None, **kwargs)[source]#
Bases:
CharField
A lowercased CharField.
- class swh.web.alter.models.BlockList(*args, **kwargs)[source]#
Bases:
BaseModel
Email or domain block list.
Email addresses or domains found in this table are not allowed to initiate an Alteration request.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- created_at#
Creation date
- get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)#
- get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)#
- get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)#
- get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)#
- id#
UUID primary key
- objects = <django.db.models.manager.Manager object>#
- updated_at#
Last update
- email_or_domain#
An email address or a domain
- reason#
Reason for the ban (ie. added by an admin or requested by a user)
- classmethod is_blocked(email: str) bool [source]#
Check if email or its domain is blocked.
We use email or domains stored in this table and optionally domains from disposable-email-domains/disposable-email-domains
- Parameters:
value – an email address
- Returns:
True if the address is blocked
- Raises:
ValueError – email is an invalid email address