Merge branch 'master' of https://e.coding.net/ctcdevteam/cma_search
This commit is contained in:
commit
e9bbddd1c7
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.12 on 2023-06-05 07:43
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('supervision', '0047_auto_20230531_1629'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='pgoaldept',
|
||||
name='goal_o_file',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='task2do',
|
||||
name='count_all',
|
||||
field=models.PositiveSmallIntegerField(default=9, verbose_name='需上报内容数'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2023-06-05 09:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('supervision', '0048_auto_20230605_1543'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='task2',
|
||||
name='end_time',
|
||||
field=models.DateField(blank=True, null=True, verbose_name='截至日期'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2023-06-06 02:43
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('supervision', '0049_task2_end_time'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='task2',
|
||||
old_name='end_time',
|
||||
new_name='end_date',
|
||||
),
|
||||
]
|
|
@ -158,6 +158,7 @@ class Task2(CommonADModel):
|
|||
|
||||
year = models.PositiveSmallIntegerField('年份', default=2023)
|
||||
cycle = models.PositiveSmallIntegerField('所属周期', default=0, help_text='1-6个周期', blank=True)
|
||||
end_date = models.DateField('截至日期', null=True, blank=True)
|
||||
type = models.PositiveSmallIntegerField('任务类型', choices=TASK2_TYPES, default=20)
|
||||
state = models.PositiveSmallIntegerField('任务状态', choices=TASK2_STATES, default=10)
|
||||
depts = models.ManyToManyField(Organization, verbose_name='执行公司', through='supervision.task2do', blank=True)
|
||||
|
@ -191,7 +192,6 @@ class PgoalDept(CommonBDModel):
|
|||
goal_name = models.CharField('目标名称', max_length=100)
|
||||
goal_key = models.CharField('目标key值', max_length=100, default='other', blank=True)
|
||||
goal_value_a = models.FloatField('基础值', null=True, blank=True)
|
||||
goal_o_file = models.ForeignKey(File, related_name='goal_o_file', verbose_name='原文件ID', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
goal_value_b = models.FloatField('设定值', null=True, blank=True)
|
||||
goal_value_c = models.FloatField('实际值', null=True, blank=True)
|
||||
goal_file = models.ForeignKey(File, related_name='goal_file', verbose_name='当前文件ID', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
|
|
@ -113,8 +113,8 @@ class Task2Serializer(serializers.ModelSerializer):
|
|||
|
||||
def update(self, instance, validated_data):
|
||||
validated_data.pop('type', None) # type不可编辑
|
||||
if instance.state != Task2.TASK2_CLOSE:
|
||||
raise ParseError('非创建状态不可编辑')
|
||||
if instance.state == Task2.TASK2_CLOSE:
|
||||
raise ParseError('已关闭不可编辑')
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
class Task2DeptsSerializer(serializers.Serializer):
|
||||
|
@ -145,10 +145,10 @@ class BaseMeta:
|
|||
|
||||
class PgoalDeptSerializer(serializers.ModelSerializer):
|
||||
goal_file_ = FileSimpleSerializer(source='goal_file', read_only=True)
|
||||
goal_o_file_ = FileSimpleSerializer(source='goal_o_file', read_only=True)
|
||||
goal_files_ = FileSimpleSerializer(source='goal_files', many=True, read_only=True)
|
||||
class Meta(BaseMeta):
|
||||
model = PgoalDept
|
||||
read_only_fields = BaseMeta.read_only_fields + ['goal_value_a', 'goal_value_c', 'goal_files', 'goal_key', 'goal_file_', 'goal_o_file', 'goal_o_file_']
|
||||
read_only_fields = BaseMeta.read_only_fields + ['goal_value_a', 'goal_value_c', 'goal_files', 'goal_key', 'goal_file_', 'goal_files_']
|
||||
|
||||
def validate(self, attrs):
|
||||
task2do = attrs.get('task2do', None)
|
||||
|
|
|
@ -455,10 +455,10 @@ class Task2ViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
|||
for key in Pgoal.basedict:
|
||||
pds = PgoalDept.objects.filter(task2do=i, goal_key=key)
|
||||
if pds.exists():
|
||||
pds.update(**{'goal_name': Pgoal.basedict[key], 'goal_value_a': getattr(pg, key), 'goal_o_file': getattr(pg, key+'_file')})
|
||||
pds.update(**{'goal_name': Pgoal.basedict[key], 'goal_value_a': getattr(pg, key)})
|
||||
else:
|
||||
PgoalDept.objects.create(**{'year': i.task2.year, 'task2do': i, 'belong_dept': i.belong_dept,
|
||||
'goal_name': Pgoal.basedict[key], 'goal_key': key, 'goal_value_a': getattr(pg, key), 'goal_o_file': getattr(pg, key+'_file')})
|
||||
'goal_name': Pgoal.basedict[key], 'goal_key': key, 'goal_value_a': getattr(pg, key)})
|
||||
obj.state = Task2.TASK2_DOING
|
||||
obj.save()
|
||||
return Response()
|
||||
|
@ -598,6 +598,7 @@ class PgoalDeptViewSet(Domixin, CreateUpdateCustomMixin, ModelViewSet):
|
|||
goal_file = instance.goal_file
|
||||
if goal_file:
|
||||
instance.goal_files.add(goal_file)
|
||||
self.countup_task2do(instance.task2do)
|
||||
|
||||
class ImpMixin:
|
||||
def get_enum(self, val, atuple, ind):
|
||||
|
|
Loading…
Reference in New Issue