Changes between Version 5 and Version 6 of Ticket #27871


Ignore:
Timestamp:
Feb 28, 2017, 11:54:31 AM (8 years ago)
Author:
Kyle Agronick
Comment:

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']

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27871 – Description

    v5 v6  
    1 Here are all the models:
    2 
    3 {{{
    4 
    5 from django.contrib.auth.models import User
    6 from django.db import models
    7 
    8 job_state = (('P', 'Pending'), ('A', 'Active'), ('C', 'Completed'), ('F', 'Failed'))
    9 app_type = (('R', 'RX'), ('W', 'WAR'))
    10 server_types = #taken out
    11 
    12 
    13 class JobGroup(models.Model):
    14     job_type = models.CharField(max_length=100, db_index=True)
    15     created_by = models.ForeignKey(User)
    16     queued_date = models.DateTimeField(null=True, db_index=True)
    17     created_date = models.DateTimeField(auto_now_add=True, db_index=True)
    18 
    19 
    20 class JobParameter(models.Model):
    21     job_group = models.ForeignKey(JobGroup, related_name='job_param', on_delete=models.CASCADE)
    22     name = models.CharField(max_length=100, db_index=True)
    23     value = models.TextField()
    24 
    25     def split_values(self):
    26         if ',' in self.value and isinstance(self.value, str):
    27             return self.value.split(', ')
    28         else:
    29             return [self.value]
    30 
    31     class Meta:
    32         unique_together = ('job_group', 'name')
    33 
    34 
    35 class Job(models.Model):
    36     job_group = models.ForeignKey(JobGroup, related_name='jobs', on_delete=models.CASCADE)
    37     state = models.CharField(max_length=1, choices=job_state, default='P', db_index=True)
    38     start_date = models.DateTimeField(null=True, db_index=True)
    39     end_date = models.DateTimeField(null=True)
    40     store = models.CharField(max_length=40, db_index=True)
    41     payload = models.TextField()
    42 
    43     def get_full_state(self):
    44         return self.get_state_display() if self.state in dict(job_state) else 'Unknown'
    45 
    46     class Meta:
    47         permissions = (
    48             ('deployment_job', 'Access Deployment job'),
    49             ('services_job', 'Access System Services job'),
    50             ('offline_status_job', 'Access Offline Status job'),
    51         )
    52 
    53 
    54 class JobLog(models.Model):
    55     job = models.ForeignKey(Job, related_name='logs', on_delete=models.CASCADE)
    56     command = models.TextField()
    57     command_output = models.TextField()
    58     result = models.BooleanField(default=False)
    59 
    60 
    61 class Service(models.Model):
    62     service_name = models.CharField(max_length=40)
    63     human_readable_name = models.CharField(max_length=40)
    64     server_type = models.CharField(choices=server_types, max_length=5)
    65 
    66     def __str__(self):
    67         return self.human_readable_name
    68 
    69     class Meta:
    70         ordering = ['human_readable_name']
    71         unique_together = ['service_name', 'server_type']
    72 }}}
Back to Top