Skip to content

Commit

Permalink
Merge pull request #1715 from cvisionai/rc/1.3.2
Browse files Browse the repository at this point in the history
1.3.2 Release Canidate
  • Loading branch information
jrtcppv authored Jun 5, 2024
2 parents fce9b32 + e0ef133 commit f4e6c8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ def calc_segments(sender, **kwargs):
)

# Bring up related media to association
instance.media.add(sortedLocalizations.all().values_list("media", flat=True))
instance.media.add(*sortedLocalizations.all().values_list("media", flat=True))
segmentList = []
current = [None, None]
last = None
Expand Down
21 changes: 21 additions & 0 deletions api/main/rest/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def patch_qs(self, params, qs):
raise Http404
obj = qs[0]
model_dict = obj.model_dict
association_type = obj.type.association

# If this is a really old object, it may not have an elemental_id
# but we need to add it for trigger support
Expand All @@ -493,18 +494,38 @@ def patch_qs(self, params, qs):
if "media_ids" in params:
media_elements = Media.objects.filter(pk__in=params["media_ids"])
obj.media.set(media_elements)
if association_type != "Media":
logger.warning(
f"Media set on state {obj.id} of type {association_type}."
"This is not a Media type state."
)

if "localization_ids" in params:
localizations = Localization.objects.filter(pk__in=params["localization_ids"])
obj.localizations.set(localizations)
if association_type != "Localization":
logger.warning(
f"Media set on state {obj.id} of type {association_type}."
"This is not a Media type state."
)

if "localization_ids_add" in params:
localizations = Localization.objects.filter(pk__in=params["localization_ids_add"])
obj.localizations.add(*list(localizations))
if association_type != "Localization":
logger.warning(
f"Media set on state {obj.id} of type {association_type}."
"This is not a Media type state."
)

if "localization_ids_remove" in params:
localizations = Localization.objects.filter(pk__in=params["localization_ids_remove"])
obj.localizations.remove(*list(localizations))
if association_type != "Localization":
logger.warning(
f"Media set on state {obj.id} of type {association_type}."
"This is not a Media type state."
)

if params.get("user_elemental_id", None):
params["in_place"] = 1
Expand Down

0 comments on commit f4e6c8e

Please sign in to comment.