调整报告公开可访问

This commit is contained in:
mgw
2025-03-17 13:39:59 +08:00
parent db881ac594
commit af529d21ec
2 changed files with 29 additions and 7 deletions

View File

@@ -445,10 +445,10 @@ class QualityCheck(models.Model):
('name', 'like', 'QC-QC') # 根据您的命名规则调整
], order='create_date DESC') # 按创建日期降序排序
# 如果附件数量大于1则删除除最新报告外的其他报告附件
if len(attachments) > 1:
for attachment in attachments[1:]:
attachment.unlink()
# # 如果附件数量大于1则删除除最新报告外的其他报告附件
# if len(attachments) > 1:
# for attachment in attachments[1:]:
# attachment.unlink()
# 返回最新的附件(如果存在)
return attachments and attachments[0] or False
@@ -462,8 +462,8 @@ class QualityCheck(models.Model):
latest_attachment = self.get_latest_report_attachment(self.id)
if latest_attachment:
# 生成包含附件ID的URL
print(f"{report_url}/{latest_attachment.id}/datas")
return f"{report_url}/{latest_attachment.id}/datas"
print(f"{base_url}/quality/report/{latest_attachment.id}")
return f"{base_url}/quality/report/{latest_attachment.id}"
return False
def upload_factory_report(self):