未验证 提交 edb3df01 编写于 作者: J Jaesun Park 提交者: GitHub

Update project updated_time (#3810) (#3814)

上级 78363b87
......@@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Incorrect work when copy job list with "Copy" button (<https://github.com/openvinotoolkit/cvat/pull/3749>)
- Iterating over manifest (<https://github.com/openvinotoolkit/cvat/pull/3792>)
- Manifest removing (<https://github.com/openvinotoolkit/cvat/pull/3791>)
- Fixed project updated date (<https://github.com/openvinotoolkit/cvat/pull/3814>)
- Fixed dextr deployment (<https://github.com/openvinotoolkit/cvat/pull/3820>)
- Migration of `dataset_repo` application (<https://github.com/openvinotoolkit/cvat/pull/3827>)
- Helm settings for external psql database were unused by backend (<https://github.com/openvinotoolkit/cvat/pull/3779>)
......
# Generated by Django 3.1.13 on 2021-10-27 07:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('engine', '0042_auto_20210830_1056'),
]
operations = [
migrations.AlterField(
model_name='project',
name='updated_date',
field=models.DateTimeField(auto_now=True),
),
]
......@@ -189,7 +189,7 @@ class Project(models.Model):
on_delete=models.SET_NULL, related_name="+")
bug_tracker = models.CharField(max_length=2000, blank=True, default="")
created_date = models.DateTimeField(auto_now_add=True)
updated_date = models.DateTimeField(auto_now_add=True)
updated_date = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=32, choices=StatusChoice.choices(),
default=StatusChoice.ANNOTATION)
training_project = models.ForeignKey(TrainingProject, null=True, blank=True, on_delete=models.SET_NULL)
......
......@@ -564,14 +564,28 @@ class TaskViewSet(auth.TaskGetQuerySetMixin, viewsets.ModelViewSet):
raise serializers.ValidationError(
"Unexpected action specified for the request")
def perform_update(self, serializer):
instance = serializer.instance
project_id = instance.project_id
updated_instance = serializer.save()
if project_id != updated_instance.project_id:
if project_id is not None:
Project.objects.get(id=project_id).save()
if updated_instance.project_id is not None:
Project.objects.get(id=updated_instance.project_id).save()
def perform_create(self, serializer):
owner = self.request.data.get('owner', None)
if owner:
self._validate_task_limit(owner)
serializer.save()
instance = serializer.save()
else:
self._validate_task_limit(self.request.user)
serializer.save(owner=self.request.user)
instance = serializer.save(owner=self.request.user)
if instance.project:
db_project = instance.project
db_project.save()
def perform_destroy(self, instance):
task_dirname = instance.get_task_dirname()
......@@ -580,6 +594,9 @@ class TaskViewSet(auth.TaskGetQuerySetMixin, viewsets.ModelViewSet):
if instance.data and not instance.data.tasks.all():
shutil.rmtree(instance.data.get_data_dirname(), ignore_errors=True)
instance.data.delete()
if instance.project:
db_project = instance.project
db_project.save()
@swagger_auto_schema(method='get', operation_summary='Returns a list of jobs for a specific task',
responses={'200': JobSerializer(many=True)})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册