2021-12-29 12:07:56 +00:00
|
|
|
from django.db import models
|
2022-03-07 11:02:37 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2021-12-29 12:07:56 +00:00
|
|
|
|
|
|
|
|
2022-03-07 11:02:37 +00:00
|
|
|
class TicketSession(models.Model):
|
2021-12-29 12:07:56 +00:00
|
|
|
ticket = models.ForeignKey('tickets.Ticket', related_name='session_relation', on_delete=models.CASCADE, db_constraint=False)
|
|
|
|
session = models.ForeignKey('terminal.Session', related_name='ticket_relation', on_delete=models.CASCADE, db_constraint=False)
|
|
|
|
|
2022-03-07 11:02:37 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _("Ticket session relation")
|
|
|
|
|
2021-12-29 12:07:56 +00:00
|
|
|
@classmethod
|
|
|
|
def get_ticket_by_session_id(cls, session_id):
|
|
|
|
relation = cls.objects.filter(session=session_id).first()
|
|
|
|
if relation:
|
|
|
|
return relation.ticket
|
|
|
|
return None
|