Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/42.0.2 #1173

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to this project are documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.


===================
42.0.2 - 2024-12-02
===================

Fixed
-----
- Fix ``AnnotationValueViewSet`` crash when removing the delete markers


===================
42.0.1 - 2024-11-21
===================
Expand Down
6 changes: 3 additions & 3 deletions resolwe/flow/models/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,9 @@ def delete_marker(self) -> bool:
return self._value is None

@property
def value(self) -> str | int | float | datetime.date:
"""Get the actual value."""
return self._value["value"]
def value(self) -> Optional[str | int | float | datetime.date]:
"""Get the actual value or None if object is delete marker."""
return None if self.delete_marker else self._value["value"]

@value.setter
def value(self, value: str | int | float | datetime.date):
Expand Down
14 changes: 14 additions & 0 deletions resolwe/flow/tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,20 @@ def test_list_filter_values(self):
self.assertTrue(response.data[0]["value"], "string")
self.assertTrue(response.data[0]["label"], "label string")

# Test delete markers are handled properly.
delete_marker = AnnotationValue.objects.create(
entity=self.annotation_value1.entity,
field=self.annotation_value1.field,
_value=None,
contributor=self.annotation_value1.contributor,
)
request = factory.get("/", {"entity": self.entity1.pk}, format="json")
force_authenticate(request, self.contributor)
response = self.annotationvalue_viewset(request)
self.assertTrue(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data), 0)
delete_marker.delete()

# Another authenticated request.
self.annotation_value2.entity = self.entity1
self.annotation_value2.save()
Expand Down
Loading