-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodels.py
More file actions
26 lines (20 loc) · 746 Bytes
/
models.py
File metadata and controls
26 lines (20 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import uuid
from django.db import models
class SessionState(models.TextChoices):
PENDING = "PENDING", "Pending"
PROCESSING = "PROCESSING", "Processing"
COMPLETED = "COMPLETED", "Completed"
FAILED = "FAILED", "Failed"
class Session(models.Model):
session_id = models.CharField(max_length=255, unique=True)
created_at = models.DateTimeField(auto_now_add=True)
jwt_token = models.TextField()
state = models.CharField(
max_length=255,
choices=SessionState.choices,
default=SessionState.PENDING,
)
def save(self, *args, **kwargs): # type: ignore[no-untyped-def]
if not self.session_id:
self.session_id = str(uuid.uuid4())
super().save(*args, **kwargs)