Here are all the models:
from django.contrib.auth.models import User
from django.db import models
job_state = (('P', 'Pending'), ('A', 'Active'), ('C', 'Completed'), ('F', 'Failed'))
app_type = (('R', 'RX'), ('W', 'WAR'))
server_types = #taken out
class JobGroup(models.Model):
job_type = models.CharField(max_length=100, db_index=True)
created_by = models.ForeignKey(User)
queued_date = models.DateTimeField(null=True, db_index=True)
created_date = models.DateTimeField(auto_now_add=True, db_index=True)
class JobParameter(models.Model):
job_group = models.ForeignKey(JobGroup, related_name='job_param', on_delete=models.CASCADE)
name = models.CharField(max_length=100, db_index=True)
value = models.TextField()
def split_values(self):
if ',' in self.value and isinstance(self.value, str):
return self.value.split(', ')
else:
return [self.value]
class Meta:
unique_together = ('job_group', 'name')
class Job(models.Model):
job_group = models.ForeignKey(JobGroup, related_name='jobs', on_delete=models.CASCADE)
state = models.CharField(max_length=1, choices=job_state, default='P', db_index=True)
start_date = models.DateTimeField(null=True, db_index=True)
end_date = models.DateTimeField(null=True)
store = models.CharField(max_length=40, db_index=True)
payload = models.TextField()
def get_full_state(self):
return self.get_state_display() if self.state in dict(job_state) else 'Unknown'
class Meta:
permissions = (
('deployment_job', 'Access Deployment job'),
('services_job', 'Access System Services job'),
('offline_status_job', 'Access Offline Status job'),
)
class JobLog(models.Model):
job = models.ForeignKey(Job, related_name='logs', on_delete=models.CASCADE)
command = models.TextField()
command_output = models.TextField()
result = models.BooleanField(default=False)
class Service(models.Model):
service_name = models.CharField(max_length=40)
human_readable_name = models.CharField(max_length=40)
server_type = models.CharField(choices=server_types, max_length=5)
def __str__(self):
return self.human_readable_name
class Meta:
ordering = ['human_readable_name']
unique_together = ['service_name', 'server_type']
Migrations for the affected app