diff --git a/server/apps/exam/serializers.py b/server/apps/exam/serializers.py index d83cfa1..eb8d22e 100644 --- a/server/apps/exam/serializers.py +++ b/server/apps/exam/serializers.py @@ -75,49 +75,12 @@ class PaperDetailSerializer(ModelSerializer): class ExamCreateUpdateSerializer(ModelSerializer): - # participant_dep = serializers.PrimaryKeyRelatedField(many=True, queryset=Organization.objects.all()) - # participant_user = serializers.PrimaryKeyRelatedField(many=True, queryset=User.objects.all()) - # participant_dep = serializers.CharField(source='participant_dep.id', read_only=True) - # participant_user = serializers.CharField(source='participant_user.id', read_only=True) + class Meta: model = Exam - fields = ['name', 'place', 'open_time', + fields = ['name', 'place', 'open_time','course_name', 'certificate', 'close_time', 'proctor_name', 'proctor_phone', 'chance', 'paper', 'participant_dep', 'participant_user'] - # def create(self, validated_data): - # print("------------", validated_data) - # eus_data = validated_data.pop('participant_user', None) - # deps_data = validated_data.pop('participant_dep', None) - # print("------------", eus_data, deps_data) - # exam_obj = Exam.objects.create(**validated_data) - # if eus_data: - # exam_obj.participant_user.set(eus_data) # 哪些用户参与考试, 使用set方法来设置ManyToMany关系 - # if deps_data: - # exam_obj.participant_dep.set(deps_data) # 哪些部门参与考试 - # return super().create(validated_data) - - # def update(self, instance, validated_data): - # eus = validated_data.pop('exam_user', None) - # deps = validated_data.pop('dep', None) - # if eus: - # instance.participant_user.set(eus) - # if deps: - # instance.participant_dep.set(deps) - # # for attr, value in validated_data.items(): - # # setattr(instance, attr, value) - # # instance.save() - # return instance -# class ExamUserSerializer(ModelSerializer): -# class Meta: -# model = ExamUser -# fields = ['id', 'exam_id','user_id'] - - -# class ExamOriSerializer(ModelSerializer): -# class Meta: -# model = ExamDep -# fields = ['id', 'exam_id','organization_id'] - class ExamListSerializer(ModelSerializer): create_by_name = CharField(source='create_by.name', read_only=True) diff --git a/server/apps/exam/views.py b/server/apps/exam/views.py index ea288fc..df883f6 100644 --- a/server/apps/exam/views.py +++ b/server/apps/exam/views.py @@ -298,9 +298,12 @@ class ExamViewSet(CreateUpdateCustomMixin, ModelViewSet): exam = self.get_object() # 查询本次考试对应哪些人 participants = exam.participant_user.all() + participants_ids = [i.id for i in participants] dep = exam.participant_dep.all() - print(request.user.id, request.user.dept.id, "request.user.dept") - if request.user.id in participants or request.user.dept in dep: + dep_ids = [i.id for i in dep] + # print(participants_id, 'participants_id') + # print(request.user.id, request.user.dept.id, "request.user.dept") + if request.user.id in participants_ids or request.user.dept in dep_ids: pass else: raise ParseError('不在考试人员范围内') @@ -392,6 +395,7 @@ class ExamRecordViewSet(ListModelMixin, DestroyModelMixin, RetrieveModelMixin, G 提交答卷 ''' er = self.get_object() + print('er----------------', er) now = timezone.now() if er.create_by != request.user: raise ParseError('提交人有误') @@ -427,17 +431,21 @@ class ExamRecordViewSet(ListModelMixin, DestroyModelMixin, RetrieveModelMixin, G er.is_pass = True # 如果是自动发证 if exam.certificate: - now = datetime.now() + now_data = datetime.now() course = exam.course_name.all() - print(course, "----------course") + courese_ids = [i.id for i in course] + print(courese_ids, "----------course") + print("------------",request.user.dept.name) + current_date = now_data.strftime('%Y-%m-%d') data_dict = { '姓名': request.user.name, - '证书编号': 'CTCZL'+ now.year+now.month+now.day, + '证书编号': 'CTCZL'+ current_date, '单位名称': request.user.dept.name, '所属单位': '国检测试控股集团'+request.user.dept.name, - '发证日期': now.year+'-'+now.month+'-'+now.day, - '课程列表': course, + '发证日期': current_date, + '课程列表': courese_ids, } + print('-----------------data_dict', data_dict) serializer = CertificateSerializer(data=data_dict) serializer.is_valid(raise_exception=True) serializer.save() diff --git a/server/dist/index.html b/server/dist/index.html index 811deb4..18d6afa 100644 --- a/server/dist/index.html +++ b/server/dist/index.html @@ -1 +1 @@ -vue Admin Template
\ No newline at end of file +vue Admin Template
\ No newline at end of file diff --git a/server/nohup.out b/server/nohup.out index 8ffb170..1637193 100644 --- a/server/nohup.out +++ b/server/nohup.out @@ -4243,3 +4243,156 @@ FileNotFoundError: [Errno 2] No such file or directory: '/media/2024/05/10/质 [2024-05-10 11:13:00 +0800] [17578] [INFO] Worker exiting (pid: 17578) [2024-05-10 11:13:05 +0800] [17574] [INFO] Parent changed, shutting down: [2024-05-10 11:13:05 +0800] [17574] [INFO] Worker exiting (pid: 17574) +[2024-05-10 13:29:56 +0800] [24474] [INFO] Starting gunicorn 20.0.4 +[2024-05-10 13:29:56 +0800] [24474] [INFO] Listening at: http://0.0.0.0:8036 (24474) +[2024-05-10 13:29:56 +0800] [24474] [INFO] Using worker: sync +[2024-05-10 13:29:56 +0800] [24477] [INFO] Booting worker with pid: 24477 +[2024-05-10 13:29:56 +0800] [24478] [INFO] Booting worker with pid: 24478 +[2024-05-10 13:29:56 +0800] [24479] [INFO] Booting worker with pid: 24479 +[2024-05-10 13:29:56 +0800] [24480] [INFO] Booting worker with pid: 24480 +[2024-05-10 13:29:56 +0800] [24481] [INFO] Booting worker with pid: 24481 +[2024-05-10 16:12:50 +0800] [24474] [INFO] Handling signal: hup +[2024-05-10 16:12:50 +0800] [24474] [INFO] Hang up: Master +[2024-05-10 16:12:50 +0800] [25630] [INFO] Booting worker with pid: 25630 +[2024-05-10 16:12:50 +0800] [25631] [INFO] Booting worker with pid: 25631 +[2024-05-10 16:12:50 +0800] [25632] [INFO] Booting worker with pid: 25632 +[2024-05-10 16:12:50 +0800] [24474] [INFO] Handling signal: hup +[2024-05-10 16:12:50 +0800] [24474] [INFO] Hang up: Master +[2024-05-10 16:12:50 +0800] [25633] [INFO] Booting worker with pid: 25633 +[2024-05-10 16:12:50 +0800] [25634] [INFO] Booting worker with pid: 25634 +[2024-05-10 16:12:50 +0800] [25637] [INFO] Booting worker with pid: 25637 +[2024-05-10 16:12:50 +0800] [25635] [INFO] Booting worker with pid: 25635 +[2024-05-10 16:12:50 +0800] [25636] [INFO] Booting worker with pid: 25636 +[2024-05-10 16:12:50 +0800] [25639] [INFO] Booting worker with pid: 25639 +[2024-05-10 16:12:50 +0800] [25638] [INFO] Booting worker with pid: 25638 +[2024-05-10 16:12:52 +0800] [25631] [INFO] Worker exiting (pid: 25631) +[2024-05-10 16:12:52 +0800] [25632] [INFO] Worker exiting (pid: 25632) +[2024-05-10 16:12:52 +0800] [25630] [INFO] Worker exiting (pid: 25630) +[2024-05-10 16:12:52 +0800] [25634] [INFO] Worker exiting (pid: 25634) +[2024-05-10 16:12:52 +0800] [25633] [INFO] Worker exiting (pid: 25633) +[2024-05-11 06:12:58,244] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/.git/config +[2024-05-11 08:45:20,412] [log.py:230] [log:log_response] [WARNING]- Forbidden: /api/mediaauth/ +[2024-05-11 12:27:59,121] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/token/env +[2024-05-11 12:27:59,252] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/token/actuator/env +[2024-05-11 12:27:59,411] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/env +[2024-05-11 12:27:59,544] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/actuator/env +[2024-05-11 12:27:59,705] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/..;/env +[2024-05-11 12:27:59,834] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/..;/actuator/env +[2024-05-11 12:27:59,975] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/token/druid/index.html +[2024-05-11 12:28:00,101] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/druid/index.html +[2024-05-11 12:28:00,245] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/..;/druid/index.html +[2024-05-11 12:28:00,380] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/token/v2/api-docs +[2024-05-11 12:28:00,513] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/token/api-docs +[2024-05-11 12:28:00,640] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/token/swagger-ui.html +[2024-05-11 12:28:00,760] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/v2/api-docs +[2024-05-11 12:28:00,901] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/api-docs +[2024-05-11 12:28:01,026] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/swagger-ui.html +[2024-05-11 12:28:01,149] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/..;/v2/api-docs +[2024-05-11 12:28:01,288] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/..;/api-docs +[2024-05-11 12:28:01,425] [log.py:230] [log:log_response] [WARNING]- Not Found: /api/..;/swagger-ui.html +[2024-05-11 15:36:31 +0800] [25638] [INFO] Parent changed, shutting down: +[2024-05-11 15:36:31 +0800] [25638] [INFO] Worker exiting (pid: 25638) +[2024-05-11 15:36:31 +0800] [25635] [INFO] Parent changed, shutting down: +[2024-05-11 15:36:31 +0800] [25635] [INFO] Worker exiting (pid: 25635) +[2024-05-11 15:36:31 +0800] [25637] [INFO] Parent changed, shutting down: +[2024-05-11 15:36:31 +0800] [25637] [INFO] Worker exiting (pid: 25637) +[2024-05-11 15:36:31 +0800] [25639] [INFO] Parent changed, shutting down: +[2024-05-11 15:36:31 +0800] [25636] [INFO] Parent changed, shutting down: +[2024-05-11 15:36:31 +0800] [25636] [INFO] Worker exiting (pid: 25636) +[2024-05-11 15:36:31 +0800] [25639] [INFO] Worker exiting (pid: 25639) +[2024-05-11 17:18:29 +0800] [33655] [INFO] Starting gunicorn 20.0.4 +[2024-05-11 17:18:29 +0800] [33655] [INFO] Listening at: http://0.0.0.0:8036 (33655) +[2024-05-11 17:18:29 +0800] [33655] [INFO] Using worker: sync +[2024-05-11 17:18:29 +0800] [33658] [INFO] Booting worker with pid: 33658 +[2024-05-11 17:18:29 +0800] [33659] [INFO] Booting worker with pid: 33659 +[2024-05-11 17:18:29 +0800] [33660] [INFO] Booting worker with pid: 33660 +[2024-05-11 17:18:29 +0800] [33663] [INFO] Booting worker with pid: 33663 +[2024-05-11 17:18:29 +0800] [33666] [INFO] Booting worker with pid: 33666 +[2024-05-12 18:05:39 +0800] [33655] [INFO] Handling signal: hup +[2024-05-12 18:05:39 +0800] [33655] [INFO] Hang up: Master +[2024-05-12 18:05:39 +0800] [37983] [INFO] Booting worker with pid: 37983 +[2024-05-12 18:05:39 +0800] [37984] [INFO] Booting worker with pid: 37984 +[2024-05-12 18:05:39 +0800] [37985] [INFO] Booting worker with pid: 37985 +[2024-05-12 18:05:39 +0800] [33655] [INFO] Handling signal: hup +[2024-05-12 18:05:39 +0800] [33655] [INFO] Hang up: Master +[2024-05-12 18:05:39 +0800] [37987] [INFO] Booting worker with pid: 37987 +[2024-05-12 18:05:39 +0800] [37986] [INFO] Booting worker with pid: 37986 +[2024-05-12 18:05:39 +0800] [37988] [INFO] Booting worker with pid: 37988 +[2024-05-12 18:05:39 +0800] [37989] [INFO] Booting worker with pid: 37989 +[2024-05-12 18:05:39 +0800] [37990] [INFO] Booting worker with pid: 37990 +[2024-05-12 18:05:39 +0800] [37991] [INFO] Booting worker with pid: 37991 +[2024-05-12 18:05:39 +0800] [37992] [INFO] Booting worker with pid: 37992 +[2024-05-12 18:05:41 +0800] [37983] [INFO] Worker exiting (pid: 37983) +[2024-05-12 18:05:41 +0800] [37984] [INFO] Worker exiting (pid: 37984) +[2024-05-12 18:05:41 +0800] [37985] [INFO] Worker exiting (pid: 37985) +[2024-05-12 18:05:41 +0800] [37987] [INFO] Worker exiting (pid: 37987) +[2024-05-12 18:05:41 +0800] [37986] [INFO] Worker exiting (pid: 37986) +[2024-05-12 19:37:16,318] [log.py:230] [log:log_response] [WARNING]- Forbidden: /api/mediaauth/ +[2024-05-13 14:33:08 +0800] [37990] [INFO] Parent changed, shutting down: +[2024-05-13 14:33:08 +0800] [37990] [INFO] Worker exiting (pid: 37990) +[2024-05-13 14:33:09 +0800] [37992] [INFO] Parent changed, shutting down: +[2024-05-13 14:33:09 +0800] [37991] [INFO] Parent changed, shutting down: +[2024-05-13 14:33:09 +0800] [37992] [INFO] Worker exiting (pid: 37992) +[2024-05-13 14:33:09 +0800] [37991] [INFO] Worker exiting (pid: 37991) +[2024-05-13 14:33:09 +0800] [37989] [INFO] Parent changed, shutting down: +[2024-05-13 14:33:09 +0800] [37989] [INFO] Worker exiting (pid: 37989) +[2024-05-13 14:33:09 +0800] [37988] [INFO] Parent changed, shutting down: +[2024-05-13 14:33:09 +0800] [37988] [INFO] Worker exiting (pid: 37988) +[2024-05-13 15:53:25 +0800] [46714] [INFO] Starting gunicorn 20.0.4 +[2024-05-13 15:53:25 +0800] [46714] [INFO] Listening at: http://0.0.0.0:8036 (46714) +[2024-05-13 15:53:25 +0800] [46714] [INFO] Using worker: sync +[2024-05-13 15:53:25 +0800] [46717] [INFO] Booting worker with pid: 46717 +[2024-05-13 15:53:25 +0800] [46718] [INFO] Booting worker with pid: 46718 +[2024-05-13 15:53:25 +0800] [46719] [INFO] Booting worker with pid: 46719 +[2024-05-13 15:53:25 +0800] [46722] [INFO] Booting worker with pid: 46722 +[2024-05-13 15:53:25 +0800] [46723] [INFO] Booting worker with pid: 46723 +[2024-05-13 15:53:33 +0800] [46728] [INFO] Booting worker with pid: 46728 +[2024-05-13 15:53:33 +0800] [46729] [INFO] Booting worker with pid: 46729 +[2024-05-13 15:53:33 +0800] [46730] [INFO] Booting worker with pid: 46730 +[2024-05-13 15:53:33 +0800] [46714] [INFO] Handling signal: hup +[2024-05-13 15:53:33 +0800] [46714] [INFO] Hang up: Master +[2024-05-13 15:53:33 +0800] [46733] [INFO] Booting worker with pid: 46733 +[2024-05-13 15:53:33 +0800] [46732] [INFO] Booting worker with pid: 46732 +[2024-05-13 15:53:33 +0800] [46735] [INFO] Booting worker with pid: 46735 +[2024-05-13 15:53:33 +0800] [46734] [INFO] Booting worker with pid: 46734 +[2024-05-13 15:53:33 +0800] [46736] [INFO] Booting worker with pid: 46736 +[2024-05-13 15:53:34 +0800] [46728] [INFO] Worker exiting (pid: 46728) +[2024-05-13 15:53:35 +0800] [46730] [INFO] Worker exiting (pid: 46730) +[2024-05-13 15:53:35 +0800] [46729] [INFO] Worker exiting (pid: 46729) +[2024-05-14 14:52:50 +0800] [46733] [INFO] Parent changed, shutting down: +[2024-05-14 14:52:50 +0800] [46732] [INFO] Parent changed, shutting down: +[2024-05-14 14:52:50 +0800] [46735] [INFO] Parent changed, shutting down: +[2024-05-14 14:52:50 +0800] [46733] [INFO] Worker exiting (pid: 46733) +[2024-05-14 14:52:50 +0800] [46735] [INFO] Worker exiting (pid: 46735) +[2024-05-14 14:52:50 +0800] [46732] [INFO] Worker exiting (pid: 46732) +[2024-05-14 14:52:51 +0800] [46734] [INFO] Parent changed, shutting down: +[2024-05-14 14:52:51 +0800] [46734] [INFO] Worker exiting (pid: 46734) +[2024-05-14 14:52:56 +0800] [46736] [INFO] Parent changed, shutting down: +[2024-05-14 14:52:56 +0800] [46736] [INFO] Worker exiting (pid: 46736) +[2024-05-15 08:56:50 +0800] [61480] [INFO] Starting gunicorn 20.0.4 +[2024-05-15 08:56:50 +0800] [61480] [INFO] Listening at: http://0.0.0.0:8036 (61480) +[2024-05-15 08:56:50 +0800] [61480] [INFO] Using worker: sync +[2024-05-15 08:56:50 +0800] [61483] [INFO] Booting worker with pid: 61483 +[2024-05-15 08:56:50 +0800] [61484] [INFO] Booting worker with pid: 61484 +[2024-05-15 08:56:50 +0800] [61486] [INFO] Booting worker with pid: 61486 +[2024-05-15 08:56:50 +0800] [61488] [INFO] Booting worker with pid: 61488 +[2024-05-15 08:56:50 +0800] [61489] [INFO] Booting worker with pid: 61489 +[2024-05-15 08:57:19 +0800] [61480] [INFO] Handling signal: hup +[2024-05-15 08:57:19 +0800] [61480] [INFO] Hang up: Master +[2024-05-15 08:57:19 +0800] [61529] [INFO] Booting worker with pid: 61529 +[2024-05-15 08:57:19 +0800] [61531] [INFO] Booting worker with pid: 61531 +[2024-05-15 08:57:19 +0800] [61530] [INFO] Booting worker with pid: 61530 +[2024-05-15 08:57:19 +0800] [61480] [INFO] Handling signal: hup +[2024-05-15 08:57:19 +0800] [61480] [INFO] Hang up: Master +[2024-05-15 08:57:19 +0800] [61532] [INFO] Booting worker with pid: 61532 +[2024-05-15 08:57:19 +0800] [61533] [INFO] Booting worker with pid: 61533 +[2024-05-15 08:57:19 +0800] [61534] [INFO] Booting worker with pid: 61534 +[2024-05-15 08:57:19 +0800] [61535] [INFO] Booting worker with pid: 61535 +[2024-05-15 08:57:19 +0800] [61536] [INFO] Booting worker with pid: 61536 +[2024-05-15 08:57:19 +0800] [61537] [INFO] Booting worker with pid: 61537 +[2024-05-15 08:57:19 +0800] [61538] [INFO] Booting worker with pid: 61538 +[2024-05-15 08:57:21 +0800] [61533] [INFO] Worker exiting (pid: 61533) +[2024-05-15 08:57:21 +0800] [61532] [INFO] Worker exiting (pid: 61532) +[2024-05-15 08:57:21 +0800] [61529] [INFO] Worker exiting (pid: 61529) +[2024-05-15 08:57:21 +0800] [61531] [INFO] Worker exiting (pid: 61531) +[2024-05-15 08:57:21 +0800] [61530] [INFO] Worker exiting (pid: 61530) diff --git a/server/server/settings_dev.py b/server/server/settings_dev.py index 491e01e..b24e194 100644 --- a/server/server/settings_dev.py +++ b/server/server/settings_dev.py @@ -1,14 +1,14 @@ from .settings import * DEBUG = True DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'cma', - 'USER': 'postgres', - 'PASSWORD': 'zcDsj2021', - 'HOST': '49.232.14.174', - 'PORT': '5432', - }, + #'default': { + # 'ENGINE': 'django.db.backends.postgresql', + # 'NAME': 'cma', + # 'USER': 'postgres', + #'PASSWORD': 'zcDsj2021', + #'HOST': '49.232.14.174', + #'PORT': '5432', + #}, # 'default': { # 'ENGINE': 'django.db.backends.postgresql', # 'NAME': 'cma', @@ -27,15 +27,15 @@ DATABASES = { # 'HOST': '127.0.0.1', # 'PORT': '5432', # } - # 'default': { - # 'ENGINE': 'django.db.backends.postgresql', - # 'NAME': 'cma', - # 'USER': 'cma', - # 'PASSWORD': 'cma123', - # 'HOST': '127.0.0.1', - # # 'HOST': '1.203.161.102', - # 'PORT': '5432', - # } + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'cma', + 'USER': 'cma', + 'PASSWORD': 'cma123', + 'HOST': '127.0.0.1', + # 'HOST': '1.203.161.102', + 'PORT': '5432', + } }