You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SoftwareMethodology/src/DjangoBlog-master/servermanager/models.py

54 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from django.db import models
# Create your models here.
class commands(models.Model):
"""
存储预设系统命令的模型,用于管理可执行的系统指令
"""
# 命令标题:用于标识命令(如"查看系统状态"字符串类型最大长度300
title = models.CharField('命令标题', max_length=300)
# 命令内容:实际执行的系统命令字符串(如"df -h"最大长度2000
command = models.CharField('命令', max_length=2000)
# 命令描述:说明命令的功能和用途,方便管理员理解
describe = models.CharField('命令描述', max_length=300)
# 创建时间:自动记录命令添加时间,创建时自动填充,后续不更新
creation_time = models.DateTimeField('创建时间', auto_now_add=True)
# 修改时间:自动记录命令最后一次修改时间,每次保存时更新
last_modify_time = models.DateTimeField('修改时间', auto_now=True)
# 定义模型实例的字符串表示形式,返回命令标题
def __str__(self):
return self.title
# 模型元数据配置
class Meta:
verbose_name = '命令' # 模型的单数显示名称
verbose_name_plural = verbose_name # 复数显示名称与单数一致
class EmailSendLog(models.Model):
"""
记录邮件发送历史的日志模型,用于追踪邮件发送状态
"""
# 收件人存储收件人邮箱地址多个邮箱用逗号分隔最大长度300
emailto = models.CharField('收件人', max_length=300)
# 邮件标题存储邮件的主题最大长度2000
title = models.CharField('邮件标题', max_length=2000)
# 邮件内容:存储邮件正文,文本类型(无长度限制)
content = models.TextField('邮件内容')
# 发送结果布尔值标记邮件是否发送成功默认False未成功
send_result = models.BooleanField('结果', default=False)
# 创建时间:自动记录日志创建时间(即邮件发送时间)
creation_time = models.DateTimeField('创建时间', auto_now_add=True)
# 定义模型实例的字符串表示形式,返回邮件标题
def __str__(self):
return self.title
# 模型元数据配置
class Meta:
verbose_name = '邮件发送log' # 模型的单数显示名称
verbose_name_plural = verbose_name # 复数显示名称与单数一致
ordering = ['-creation_time'] # 默认按创建时间降序排序(最新记录在前)