from django.db import models from libs import ModelMixin, human_datetime from apps.account.models import User from apps.app.models import App class DeployRequest(models.Model, ModelMixin): STATUS = ( ('-3', '发布异常'), ('-1', '已驳回'), ('1', '待审核'), ('2', '待发布'), ('3', '发布成功'), ) app = models.ForeignKey(App, on_delete=models.CASCADE) name = models.CharField(max_length=50) extra = models.TextField() host_ids = models.TextField() desc = models.CharField(max_length=255, null=True) status = models.CharField(max_length=2, choices=STATUS) reason = models.CharField(max_length=255, null=True) created_at = models.CharField(max_length=20, default=human_datetime) created_by = models.ForeignKey(User, models.PROTECT, related_name='+') approve_at = models.CharField(max_length=20, null=True) approve_by = models.ForeignKey(User, models.PROTECT, related_name='+', null=True) def __repr__(self): return f'' class Meta: db_table = 'deploy_requests' ordering = ('-id',)