set dirty bag flag
@@ -9,6 +9,7 @@ Related to https://github.com/hydroshare/hydroshare/issues/4695
from django.core.management.base import BaseCommand
from hs_core.models import BaseResource
from hs_core.models import Creator
+from hs_core.hydroshare.utils import set_dirty_bag_flag
class Command(BaseCommand):
@@ -18,6 +19,7 @@ class Command(BaseCommand):
resources = BaseResource.objects.filter(raccess__published=False).only('object_id', 'short_id')
for res in resources:
creators = Creator.objects.filter(object_id=res.object_id)
+ is_dirty = False
for index, creator in enumerate(creators, start=1):
if creator.order != index:
print("*" * 100)
@@ -25,3 +27,6 @@ class Command(BaseCommand):
f"\nExpected: {index}, got: {creator.order}")
creator.order = index
creator.save()
+ is_dirty = True
+ if is_dirty:
+ set_dirty_bag_flag(res)
