diff --git a/CHANGELOG.md b/CHANGELOG.md index 37c4fd423ab8..9c19d5b4d4c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Incorrect work when copy job list with "Copy" button () - Iterating over manifest () - Manifest removing () +- Fixed project updated date () - Fixed dextr deployment () - Migration of `dataset_repo` application () diff --git a/cvat/apps/engine/migrations/0043_auto_20211027_0718.py b/cvat/apps/engine/migrations/0043_auto_20211027_0718.py new file mode 100644 index 000000000000..66ab83a28dd3 --- /dev/null +++ b/cvat/apps/engine/migrations/0043_auto_20211027_0718.py @@ -0,0 +1,18 @@ +# 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), + ), + ] diff --git a/cvat/apps/engine/models.py b/cvat/apps/engine/models.py index 22272423655f..a3e32a0b57b8 100644 --- a/cvat/apps/engine/models.py +++ b/cvat/apps/engine/models.py @@ -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) diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 920c7a15d3ac..4032636e38d3 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -564,14 +564,28 @@ def retrieve(self, request, pk=None): 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 @@ def perform_destroy(self, instance): 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)})