Conversion_Kitchen_Code/kitchen_counter/scriptAudit/models.py

65 lines
2.4 KiB
Python
Raw Permalink Normal View History

import uuid
from django.db import models
from centralisedFileSystem.models import Script
class States:
"""
All the possible states of the audit.
"""
PENDING = "PENDING"
STARTED = "STARTED"
SUCCESS = "SUCCESS"
FAILURE = "FAILURE"
RETRY = "RETRY"
REVOKED = "REVOKED"
# class AuditStatus(models.Model):
# STATUS = (
# ("N", "notstarted"),
# ("R", "running"),
# ("S", "success"),
# ("F", "failed"),
# )
# id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
# script = models.ForeignKey(
# Script, on_delete=models.CASCADE, related_name="audit_scripts_files"
# )
# script_audit_status = models.CharField(choices=STATUS, default="N", max_length=20)
class ScriptAuditModel(models.Model):
_STATES = tuple(((v, v) for k, v in States.__dict__.items() if k[:2] != "__"))
"""
PENDING (waiting for execution or unknown task id)
STARTED (task has been started)
SUCCESS (task executed successfully)
FAILURE (task execution resulted in exception)
RETRY (task is being retried)
REVOKED (task has been revoked)
"""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
script = models.OneToOneField(
Script, on_delete=models.CASCADE, blank=False, null=False, related_name="script_audit"
)
celery_id = models.CharField(max_length=50, blank=False, null=True, editable=False)
last_call = models.DateTimeField(auto_now=True)
pre_audit_run = models.BooleanField(default=False)
status = models.CharField(max_length=10, blank=True, null=True, choices=_STATES)
results = models.CharField(max_length=200, blank=True, null=True)
retries = models.IntegerField(default=0)
expected_duration = models.CharField(max_length=30, blank=True, null=True)
number_of_pages = models.IntegerField(blank=True, null=True)
screenplay_language = models.CharField(max_length=50, blank=False, null=True)
dialogue_language = models.CharField(max_length=50, blank=False, null=True)
transaction_hash = models.CharField(max_length=200, blank=False, null=True)
bchain_privatekey = models.CharField(max_length=200, blank=False, null=True)
isfdx = models.BooleanField(default=False)
only_audit = models.BooleanField(null=True, blank=True)
error_msg = models.TimeField(null=True,blank=True)