@@ -59,23 +59,25 @@ def update_view_image_permissions_on_job_io_change( # noqa:C901
5959 assign_perm ("view_image" , group , images )
6060
6161 elif action in {"post_remove" , "pre_clear" }:
62+ exclude_jobs = jobs if action == "pre_clear" else None
63+
6264 for image in images :
6365 # We cannot remove image permissions directly as the groups
6466 # may have permissions through another object
65- image .update_viewer_groups_permissions (exclude_jobs = jobs )
67+ image .update_viewer_groups_permissions (exclude_jobs = exclude_jobs )
6668
6769 else :
6870 raise NotImplementedError
6971
7072
7173def _get_images_for_jobs (* , jobs ):
72- input_civs = Image .objects .filter (
74+ input_images = Image .objects .filter (
7375 componentinterfacevalue__algorithms_jobs_as_input__in = jobs
7476 )
75- output_civs = Image .objects .filter (
77+ output_images = Image .objects .filter (
7678 componentinterfacevalue__algorithms_jobs_as_output__in = jobs
7779 )
78- return input_civs .union (output_civs )
80+ return input_images .union (output_images )
7981
8082
8183@receiver (m2m_changed , sender = Job .viewer_groups .through )
@@ -111,10 +113,12 @@ def update_view_image_permissions_on_viewer_groups_change( # noqa:C901
111113 for job in jobs :
112114 remove_perm ("view_job" , group , job )
113115
116+ exclude_jobs = jobs if action == "pre_clear" else None
117+
114118 for image in images :
115119 # We cannot remove image permissions directly as the groups
116120 # may have permissions through another object
117- image .update_viewer_groups_permissions (exclude_jobs = jobs )
121+ image .update_viewer_groups_permissions (exclude_jobs = exclude_jobs )
118122
119123 else :
120124 raise NotImplementedError
0 commit comments