app/grandchallenge/reader_studies/signals.py
def update_image_permissions(instance, action, reverse, model, pk_set, **_):
    """
    Assign or remove view permissions to the readers group when images
    are added or remove to/from the reader study images. Handles reverse
    relations and clearing.
    """
    if action not in ["post_add", "post_remove", "pre_clear"]:
        # nothing to do for the other actions
        return

    if reverse:
        images = Image.objects.filter(pk=instance.pk)
        if pk_set is None:
            # When using a _clear action, pk_set is None
            # https://docs.djangoproject.com/en/2.2/ref/signals/#m2m-changed
            reader_studies = instance.readerstudies.all()
        else:
            reader_studies = model.objects.filter(pk__in=pk_set)

        reader_studies = reader_studies.select_related(
            "readers_group", "editors_group"
        )
    else:
        reader_studies = [instance]
        if pk_set is None:
            # When using a _clear action, pk_set is None
            # https://docs.djangoproject.com/en/2.2/ref/signals/#m2m-changed
            images = instance.images.all()
        else:
            images = model.objects.filter(pk__in=pk_set)

    op = assign_perm if "add" in action else remove_perm

    for rs in reader_studies:
        op("view_image", rs.editors_group, images)
        op("view_image", rs.readers_group, images)

    Assign or remove view permissions to the readers group when images
    are added or remove to/from the reader study images. Handles reverse
    relations and clearing.
    
Assign or remove view permissions to the readers group when images
are added or remove to/from the reader study images. Handles reverse
relations and clearing.
Assign or remove view permissions to the readers group when images are added or remove to / from the reader study images . Handles reverse relations and clearing .
def update_image_permissions(instance, action, reverse, model, pk_set, **_):
    if action not in ["post_add", "post_remove", "pre_clear"]:
        return
    if reverse:
        images = Image.objects.filter(pk=instance.pk)
        if pk_set is None:
            reader_studies = instance.readerstudies.all()
        else:
            reader_studies = model.objects.filter(pk__in=pk_set)
        reader_studies = reader_studies.select_related(
            "readers_group", "editors_group"
        )
    else:
        reader_studies = [instance]
        if pk_set is None:
            images = instance.images.all()
        else:
            images = model.objects.filter(pk__in=pk_set)
    op = assign_perm if "add" in action else remove_perm
    for rs in reader_studies:
        op("view_image", rs.editors_group, images)
        op("view_image", rs.readers_group, images)
def update_image_permissions ( instance , action , reverse , model , pk_set , ** _ ) : if action not in [ "post_add" , "post_remove" , "pre_clear" ] : return if reverse : images = Image . objects . filter ( pk = instance . pk ) if pk_set is None : reader_studies = instance . readerstudies . all ( ) else : reader_studies = model . objects . filter ( pk__in = pk_set ) reader_studies = reader_studies . select_related ( "readers_group" , "editors_group" ) else : reader_studies = [ instance ] if pk_set is None : images = instance . images . all ( ) else : images = model . objects . filter ( pk__in = pk_set ) op = assign_perm if "add" in action else remove_perm for rs in reader_studies : op ( "view_image" , rs . editors_group , images ) op ( "view_image" , rs . readers_group , images )
Assign or remove view permissions to the readers group when images
are added or remove to/from the reader study images.
Assign or remove view permissions to the readers group when images are added or remove to / from the reader study images .
"""
    Assign or remove view permissions to the readers group when images
    are added or remove to/from the reader study images. Handles reverse
    relations and clearing.
    """ # nothing to do for the other actions # When using a _clear action, pk_set is None # https://docs.djangoproject.com/en/2.2/ref/signals/#m2m-changed # When using a _clear action, pk_set is None # https://docs.djangoproject.com/en/2.2/ref/signals/#m2m-changed
instance
action
reverse
model
pk_set