Audit Changes regarding audit_true field in scriptaudit models

This commit is contained in:
Ubuntu 2024-06-19 08:45:18 +00:00
parent 71b25755c8
commit 353fd2ae83
2 changed files with 64 additions and 63 deletions

View File

@ -161,6 +161,7 @@ def run_audit(msg):
id = script_id id = script_id
)) ))
print("STATUS AUDIT",status) print("STATUS AUDIT",status)
status.only_audit = True
# Blockchain # Blockchain
# if UserCredentialsForBlockchain.objects.filter(user=request.user).exists(): # if UserCredentialsForBlockchain.objects.filter(user=request.user).exists():
blockchain_obj = UserCredentialsForBlockchain.objects.get(user=user) blockchain_obj = UserCredentialsForBlockchain.objects.get(user=user)

View File

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