Modèle Ticket

Module contenant le modèle Ticket pour la gestion des billets.

Ce module définit la structure de données pour les tickets achetés par les clients pour les événements des Jeux Olympiques. Chaque ticket est associé à un client, un événement et une offre spécifique, et possède une clé unique générée automatiquement.

class api.models.ticket.Ticket(*args, **kwargs)

Bases : Model

Modèle représentant un ticket pour un événement sportif.

Un ticket est associé à un client, un événement et une offre spécifique. Chaque ticket possède un statut et une clé unique générée automatiquement pour garantir l’unicité.

Variables:
  • client – Le client possédant le ticket

  • evenement – L’événement associé au ticket

  • offre – L’offre choisie pour ce ticket

  • date_achat – Date et heure d’achat du ticket

  • statut – Statut du ticket (“valide” ou “invalide”)

  • key – Clé unique générée pour le ticket

STATUT_CHOICES = [('valide', 'Valide'), ('invalide', 'Invalide')]
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.

evenement

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.

offre

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_achat

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

statut

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

key

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

save(*args, **kwargs)

Sauvegarde le ticket et génère une clé unique incluant l’ID.

La clé est calculée après la première insertion pour inclure self.id, garantissant l’unicité absolue. La clé est un hash SHA-256 basé sur le client, la date d’achat et l’identifiant du ticket.

exception DoesNotExist

Bases : ObjectDoesNotExist

exception MultipleObjectsReturned

Bases : MultipleObjectsReturned

client_id
evenement_id
get_next_by_date_achat(*, field=<django.db.models.fields.DateTimeField: date_achat>, is_next=True, **kwargs)
get_previous_by_date_achat(*, field=<django.db.models.fields.DateTimeField: date_achat>, is_next=False, **kwargs)
get_statut_display(*, field=<django.db.models.fields.CharField: statut>)
id

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

objects = <django.db.models.manager.Manager object>
offre_id
qrcodes

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

In the example:

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

Place.restaurant is a ReverseOneToOneDescriptor instance.