1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| from django.db import models from base.models import BaseModel from .validators import validate_certificate_file_extension, validate_private_key_file_extension
class Certificate(BaseModel): """ SSL证书 """ name = models.CharField(max_length=60, unique=True, verbose_name="名称") certificate = models.TextField( verbose_name='certificate', blank=True, null=True)
certificate_file = models.FileField( verbose_name='certificate_file', upload_to='ssl/', validators=[validate_certificate_file_extension]) private_key = models.TextField( verbose_name='private_key', blank=True, null=True)
private_key_file = models.FileField( verbose_name='private_key_file', upload_to='ssl/', validators=[validate_private_key_file_extension])
before_time = models.CharField( max_length=60, null=True, blank=True, verbose_name="生效时间") after_time = models.CharField( max_length=60, null=True, blank=True, verbose_name="过期时间") organization = models.CharField( max_length=20, null=True, blank=True, verbose_name="组织") domain = models.CharField( max_length=60, null=True, blank=True, verbose_name="域名")
class Meta: verbose_name = "SSL证书" verbose_name_plural = verbose_name ordering = ['id']
def __str__(self): return self.name
|