def perform_destroy(self, instance):
        data = self.request.data['data']
        user = self.request.user
        current_institutions = {inst._id for inst in user.affiliated_institutions}

        # DELETEs normally dont get type checked
        # not the best way to do it, should be enforced everywhere, maybe write a test for it
        for val in data:
            if val['type'] != self.serializer_class.Meta.type_:
                raise Conflict()
        for val in data:
            if val['id'] in current_institutions:
                user.remove_institution(val['id'])
        user.save()
dataset/ETHPy150Open CenterForOpenScience/osf.io/api/users/views.py/UserInstitutionsRelationship.perform_destroy/original