diff --git a/apps/ofm/migrations/0011_auto_20250924_1359.py b/apps/ofm/migrations/0011_auto_20250924_1359.py new file mode 100644 index 00000000..f30d67fe --- /dev/null +++ b/apps/ofm/migrations/0011_auto_20250924_1359.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.12 on 2025-09-24 05:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ofm', '0010_auto_20250919_0921'), + ] + + operations = [ + migrations.RemoveField( + model_name='publicity', + name='channel_other', + ), + migrations.AddField( + model_name='publicity', + name='pfile', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='稿件路径'), + ), + migrations.AddField( + model_name='publicity', + name='pub_dept', + field=models.CharField(blank=True, max_length=50, null=True, verbose_name='部室/研究院'), + ), + ] diff --git a/apps/ofm/migrations/0012_publicity_ticket.py b/apps/ofm/migrations/0012_publicity_ticket.py new file mode 100644 index 00000000..4f643026 --- /dev/null +++ b/apps/ofm/migrations/0012_publicity_ticket.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.12 on 2025-09-24 06:07 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wf', '0003_workflow_view_path'), + ('ofm', '0011_auto_20250924_1359'), + ] + + operations = [ + migrations.AddField( + model_name='publicity', + name='ticket', + field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='publicity_ticket', to='wf.ticket', verbose_name='关联工单'), + ), + ] diff --git a/apps/ofm/models.py b/apps/ofm/models.py index 09aa8369..e3e2fdba 100644 --- a/apps/ofm/models.py +++ b/apps/ofm/models.py @@ -112,6 +112,8 @@ class Publicity(CommonBDModel): number = models.CharField('记录编号', max_length=50) title = models.CharField('送审稿件标题', max_length=100) participants = models.CharField('所有撰稿人', max_length=50) + pub_dept = models.CharField('部室/研究院', null=True, blank=True, max_length=50) + pfile = models.CharField('稿件路径', null=True, blank=True, max_length=100) level = models.JSONField('用途', default=list, help_text=['重要', '一般', '非涉密']) content = models.JSONField('稿件内容涉及', default=list, help_text=[ "武器装备科研生产综合事项", @@ -120,13 +122,14 @@ class Publicity(CommonBDModel): other_content = models.CharField('其它内容', max_length=100, blank=True, null=True) report_purpose = models.CharField('宣传报道目的', max_length=100, blank=True, null=True) channel = models.JSONField('发布渠道', default=list, help_text=['互联网', '信息平台', '官微', '公开发行物', '其它']) - channel_other = models.CharField('其它渠道', max_length=50, blank=True, null=True) other_channel = models.CharField('其它渠道', max_length=50, blank=True, null=True) report_name = models.CharField('报道名称', max_length=50, blank=True, null=True) review = models.JSONField('第一撰稿人自审', default=list, help_text=['内容不涉及国家秘密和商业秘密,申请公开', '内容涉及国家秘密,申请按涉密渠道发布']) dept_opinion = models.JSONField('部门负责人意见', default=list, help_text=['同意', '不同意']) dept_opinion_review = models.CharField('部门审查意见', max_length=100, blank=True, null=True) publicity_opinion = models.JSONField('宣传统战部审查意见', default=list, help_text=['同意公开宣传报道', '不同意任何渠道的宣传报道']) + ticket = models.ForeignKey('wf.ticket', verbose_name='关联工单', + on_delete=models.SET_NULL, related_name='publicity_ticket', null=True, blank=True, db_constraint=False) # 记录编号自动生成 def save(self, *args, **kwargs): diff --git a/apps/ofm/serializers.py b/apps/ofm/serializers.py index b3b3201f..17af419f 100644 --- a/apps/ofm/serializers.py +++ b/apps/ofm/serializers.py @@ -106,6 +106,8 @@ class BorrowRecordSerializer(CustomModelSerializer): class PublicitySerializer(CustomModelSerializer): + create_by_name = serializers.CharField(source='create_by.name', read_only=True) + belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True) class Meta: model = Publicity fields = '__all__' diff --git a/apps/ofm/services.py b/apps/ofm/services.py index 02d0281c..8a17900d 100644 --- a/apps/ofm/services.py +++ b/apps/ofm/services.py @@ -1,7 +1,7 @@ from apps.wf.models import Ticket # TicketFlow, Transition, Workflow, CustomField, State, -from apps.ofm.models import LendingSeal, Vehicle, BorrowRecord +from apps.ofm.models import LendingSeal, Vehicle, BorrowRecord, Publicity from rest_framework.exceptions import ParseError @@ -50,6 +50,21 @@ def bind_file(ticket: Ticket, transition, new_ticket_data: dict): ticket.ticket_data = ticket_data ticket.create_by = ins.create_by ticket.save() + if ins.ticket is None: + ins.ticket = ticket + ins.save() + + +def bind_publicity(ticket: Ticket, transition, new_ticket_data: dict): + ins = Publicity.objects.get(id=new_ticket_data['t_id']) + ticket_data = ticket.ticket_data + ticket_data.update({ + 't_model': 'publicity', + 't_id': ins.id, + }) + ticket.ticket_data = ticket_data + ticket.create_by = ins.create_by + ticket.save() if ins.ticket is None: ins.ticket = ticket ins.save() \ No newline at end of file diff --git a/apps/ofm/views.py b/apps/ofm/views.py index 9ac103a0..f9b5010b 100644 --- a/apps/ofm/views.py +++ b/apps/ofm/views.py @@ -2,7 +2,7 @@ from django.shortcuts import render from apps.utils.viewsets import CustomModelViewSet, CustomGenericViewSet from .models import Mroom, MroomBooking, MroomSlot, LendingSeal, Vehicle, FileRecord, BorrowRecord, Publicity # Publicity, PatentInfo, PaperOfm, Platform, Project, PatentRecord, PaperRecord, ProjectApproval, ProjectInfo) -from .serializers import (MroomSerializer, MroomBookingSerializer, MroomSlotSerializer, LendingSealSerializer, VehicleSerializer, FileRecordSerializer, BorrowRecordSerializer, PublicitySerializer) +from .serializers import (MroomSerializer, MroomBookingSerializer, MroomSlotSerializer, LendingSealSerializer, VehicleSerializer, FileRecordSerializer, BorrowRecordSerializer, PublicitySerializer,) # ,SealSerializer, # LendingSealSerializer, FileRecordSerializer, BorrowRecordSerializer, PublicitySerializer, # PatentInfoSerializer, PaperSerializer, PlatformSerializer, ProjectSerializer, ProjectMemberSerializer, PaperRecordSerializer, ProjectApprovalSerializer, ProjectInfoSerializer)