feat: 自动生成所有证书照片

This commit is contained in:
caoqianming 2024-01-05 09:41:28 +08:00
parent 50696b754a
commit ab898fc759
1 changed files with 13 additions and 0 deletions

View File

@ -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
from django.db.models import Q
# Create your views here.
@ -123,3 +124,15 @@ class CertificateViewSet(CreateUpdateCustomMixin, ModelViewSet):
obj.课程列表.set(Course.objects.filter(id__in=courses_list))
i += 1
return Response()
@action(methods=["get"], detail=False, perms_map={"get": "*"})
def gen_img(self, request, *args, **kwargs):
"""没有生成证书照片的都生成照片
没有生成证书照片的都生成照片
"""
queryset = Certificate.objects.filter(Q(证书地址=None) | Q(证书地址=""))
for obj in queryset:
make_img_x(obj)
print(f"生成---{obj.name}---的证书")
return Response()