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