fix: edu 生成证书
This commit is contained in:
parent
8f2345d1e2
commit
405eed0957
|
@ -7,7 +7,7 @@
|
|||
</el-select>
|
||||
<el-input
|
||||
v-model="listQuery.search"
|
||||
placeholder="姓名/证书号/单位/培训日期/发证日期"
|
||||
placeholder="姓名/证书号/单位/培训日期"
|
||||
style="width: 300px"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="handleFilter"
|
||||
|
@ -88,6 +88,7 @@
|
|||
border
|
||||
fit
|
||||
stripe
|
||||
:default-sort = "{prop: '证书编号', order: 'descending'}"
|
||||
highlight-current-row
|
||||
max-height="700"
|
||||
>
|
||||
|
@ -103,7 +104,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="姓名" prop="姓名">
|
||||
</el-table-column>
|
||||
<el-table-column label="证书编号" prop="证书编号">
|
||||
<el-table-column label="证书编号" prop="证书编号" sortable>
|
||||
</el-table-column>
|
||||
<template v-if="listQuery.证书方案=='202309'">
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ from rest_framework.permissions import AllowAny
|
|||
from apps.edu.services import make_img_x
|
||||
from django.db import transaction
|
||||
import datetime
|
||||
import threading
|
||||
from django.db.models import Q
|
||||
|
||||
|
||||
|
@ -28,9 +29,9 @@ class CertificateViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
|||
perms_map = {"get": "*", "post": "certificate", "put": "certificate", "delete": "certificate"}
|
||||
queryset = Certificate.objects.all()
|
||||
serializer_class = CertificateSerializer
|
||||
search_fields = ["姓名", "证书编号", "所属单位", "培训日期", "发证日期"]
|
||||
search_fields = ["姓名", "证书编号", "所属单位", "培训日期"]
|
||||
filterset_fields = ["是否内审员", "是否授权签字人", "是否质量负责人", "是否最高管理者", "姓名", "证书编号", "所属单位", "单位名称", "课程列表", "证书方案"]
|
||||
ordering = ["-create_time", "证书编号"]
|
||||
ordering = ["-证书编号"]
|
||||
|
||||
def get_authenticators(self):
|
||||
if self.request.method == "GET":
|
||||
|
@ -147,17 +148,22 @@ class CertificateViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
|||
raise ParseError("Invalid data")
|
||||
|
||||
# Fetch the objects to update
|
||||
objects = Certificate.objects.filter(id__in=ids)
|
||||
if not objects.exists():
|
||||
raise ParseError("No objects found")
|
||||
Certificate.objects.filter(id__in=ids).update(**updates)
|
||||
queryset = Certificate.objects.filter(id__in=ids)
|
||||
thread = threading.Thread(target=make_img_x, args=(queryset,))
|
||||
thread.start()
|
||||
# # Update the objects
|
||||
# for obj in objects:
|
||||
# # for field, value in updates.items():
|
||||
# # setattr(obj, field, value)
|
||||
# # obj.save()
|
||||
# serializer = CertificateSerializer(obj, data=updates, partial=True)
|
||||
# serializer.is_valid(raise_exception=True)
|
||||
# serializer.save()
|
||||
|
||||
# Update the objects
|
||||
for obj in objects:
|
||||
# for field, value in updates.items():
|
||||
# setattr(obj, field, value)
|
||||
# obj.save()
|
||||
serializer = CertificateSerializer(obj, data=updates, partial=True)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
serializer.save()
|
||||
|
||||
return Response()
|
||||
return Response()
|
||||
|
||||
def update_certificate(certificate_obj):
|
||||
for obj in certificate_obj:
|
||||
make_img_x(obj)
|
||||
return
|
Loading…
Reference in New Issue