Merge pull request #3258 from openvinotoolkit/dk/fix-3252

Fixed assignment in if statement
main
Dmitry Kalinin 5 years ago committed by GitHub
commit 99bdfac892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Project page requests took a long time and did many DB queries (<https://github.com/openvinotoolkit/cvat/pull/3223>)
- Fixed Python 3.6 support (<https://github.com/openvinotoolkit/cvat/pull/3258>)
### Security

@ -425,7 +425,8 @@ class TaskSerializer(WriteOnceMixin, serializers.ModelSerializer):
instance.label_set.all().delete()
else:
for old_label in instance.project.label_set.all():
if new_label_for_name := list(filter(lambda x: x.get('id', None) == old_label.id, labels)):
new_label_for_name = list(filter(lambda x: x.get('id', None) == old_label.id, labels))
if len(new_label_for_name):
old_label.name = new_label_for_name[0].get('name', old_label.name)
try:
new_label = project.label_set.filter(name=old_label.name).first()
@ -458,7 +459,8 @@ class TaskSerializer(WriteOnceMixin, serializers.ModelSerializer):
new_label_names = set()
old_labels = self.instance.project.label_set.all() if self.instance.project_id else self.instance.label_set.all()
for old_label in old_labels:
if len(new_labels := tuple(filter(lambda x: x.get('id') == old_label.id, attrs.get('label_set', [])))):
new_labels = tuple(filter(lambda x: x.get('id') == old_label.id, attrs.get('label_set', [])))
if len(new_labels):
new_label_names.add(new_labels[0].get('name', old_label.name))
else:
new_label_names.add(old_label.name)

Loading…
Cancel
Save