@@ -94,8 +94,6 @@ def augmenteds_count(self):
9494 def exhibits_count (self ):
9595 return self .exhibits .count ()
9696
97-
98-
9997 def used_in_html_string (self ):
10098 used_in = "{} {} {} {} {} {} {}" .format (
10199 USED_IN ,
@@ -606,23 +604,35 @@ def artwork_post_save(sender, instance, **kwargs):
606604 old_marker_id = getattr (instance , "_old_marker_id" , None )
607605 if old_marker_id and old_marker_id != instance .marker_id :
608606 if not Artwork .objects .filter (marker_id = old_marker_id ).exists ():
609- Marker .objects .filter (pk = old_marker_id ).update (in_use = False , is_used_by_other_user = False )
607+ Marker .objects .filter (pk = old_marker_id ).update (
608+ in_use = False , is_used_by_other_user = False
609+ )
610610 else :
611611 old_marker = Marker .objects .get (pk = old_marker_id )
612- still_used_by_other = old_marker .artworks .exclude (author = old_marker .owner ).exists ()
612+ still_used_by_other = old_marker .artworks .exclude (
613+ author = old_marker .owner
614+ ).exists ()
613615 if not still_used_by_other :
614- Marker .objects .filter (pk = old_marker_id ).update (is_used_by_other_user = False )
616+ Marker .objects .filter (pk = old_marker_id ).update (
617+ is_used_by_other_user = False
618+ )
615619
616620 # If object changed, check if the old one is still in use
617621 old_augmented_id = getattr (instance , "_old_augmented_id" , None )
618622 if old_augmented_id and old_augmented_id != instance .augmented_id :
619623 if not Artwork .objects .filter (augmented_id = old_augmented_id ).exists ():
620- Object .objects .filter (pk = old_augmented_id ).update (in_use = False , is_used_by_other_user = False )
624+ Object .objects .filter (pk = old_augmented_id ).update (
625+ in_use = False , is_used_by_other_user = False
626+ )
621627 else :
622628 old_object = Object .objects .get (pk = old_augmented_id )
623- still_used_by_other = old_object .artworks .exclude (author = old_object .owner ).exists ()
629+ still_used_by_other = old_object .artworks .exclude (
630+ author = old_object .owner
631+ ).exists ()
624632 if not still_used_by_other :
625- Object .objects .filter (pk = old_augmented_id ).update (is_used_by_other_user = False )
633+ Object .objects .filter (pk = old_augmented_id ).update (
634+ is_used_by_other_user = False
635+ )
626636
627637 # If sound changed, check if the old one is still in use
628638 old_sound_id = getattr (instance , "_old_sound_id" , None )
@@ -634,14 +644,18 @@ def artwork_post_save(sender, instance, **kwargs):
634644def artwork_post_delete (sender , instance , ** kwargs ):
635645 """When an artwork is deleted, check if its marker/object/sound are still in use."""
636646 if not Artwork .objects .filter (marker_id = instance .marker_id ).exists ():
637- Marker .objects .filter (pk = instance .marker_id ).update (in_use = False , is_used_by_other_user = False )
647+ Marker .objects .filter (pk = instance .marker_id ).update (
648+ in_use = False , is_used_by_other_user = False
649+ )
638650 else :
639651 marker = Marker .objects .get (pk = instance .marker_id )
640652 if not marker .artworks .exclude (author = marker .owner ).exists ():
641653 Marker .objects .filter (pk = marker .pk ).update (is_used_by_other_user = False )
642654
643655 if not Artwork .objects .filter (augmented_id = instance .augmented_id ).exists ():
644- Object .objects .filter (pk = instance .augmented_id ).update (in_use = False , is_used_by_other_user = False )
656+ Object .objects .filter (pk = instance .augmented_id ).update (
657+ in_use = False , is_used_by_other_user = False
658+ )
645659 else :
646660 obj = Object .objects .get (pk = instance .augmented_id )
647661 if not obj .artworks .exclude (author = obj .owner ).exists ():
@@ -659,9 +673,7 @@ def _recalculate_sound_flags(sound_id):
659673 return
660674
661675 is_in_use = (
662- sound .artworks .exists ()
663- or sound .ar_objects .exists ()
664- or sound .exhibits .exists ()
676+ sound .artworks .exists () or sound .ar_objects .exists () or sound .exhibits .exists ()
665677 )
666678 used_by_other = (
667679 sound .artworks .exclude (author = sound .owner ).exists ()
0 commit comments