43 lines
		
	
	
		
			1000 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1000 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from enum import Enum
 | |
| 
 | |
| 
 | |
| from django.contrib.auth.models import User
 | |
| from django.db import models
 | |
| 
 | |
| 
 | |
| class Type(Enum):
 | |
|     SLIM = "Slim"
 | |
|     MEDIUM = "Medium"
 | |
|     LARGE = "Large"
 | |
| 
 | |
|     @classmethod
 | |
|     def into_choices(cls):
 | |
|         return [(s.name, s.value) for s in cls]
 | |
| 
 | |
| 
 | |
| class Status(Enum):
 | |
|     READY = "Ready"
 | |
|     PENDING = "Pending"
 | |
|     RUNNING = "Running"
 | |
|     SUCCESS = "Success"
 | |
|     FAILED = "Failed"
 | |
| 
 | |
|     @classmethod
 | |
|     def into_choices(cls):
 | |
|         return [(s.name, s.value) for s in cls]
 | |
| 
 | |
| 
 | |
| class Deployment(models.Model):
 | |
|     id = models.UUIDField(primary_key=True)
 | |
|     name = models.TextField(null=False, blank=False)
 | |
|     type = models.CharField(
 | |
|         max_length=6, choices=Type.into_choices(), default=Type.SLIM.name
 | |
|     )
 | |
|     status = models.CharField(
 | |
|         max_length=7, choices=Status.into_choices(), default=Status.READY.name
 | |
|     )
 | |
|     user = models.ForeignKey(User, on_delete=models.CASCADE)
 | |
| 
 | |
|     def __str__(self):
 | |
|         return f"{self.name} | {self.type} | {self.status}"
 |