Ejemplo n.º 1
0
                        if not anonymous_group:
                            raise Exception(
                                "Could not acquire 'anonymous' Group.")

                        # default permissions for resource owner
                        set_owner_permissions(
                            _resource, members=get_obj_group_managers(_owner))

                        # Anonymous
                        anonymous_can_view = settings.DEFAULT_ANONYMOUS_VIEW_PERMISSION
                        if anonymous_can_view:
                            assign_perm('view_resourcebase', anonymous_group,
                                        _resource.get_self_resource())
                        else:
                            for user_group in get_user_groups(_owner):
                                if not skip_registered_members_common_group(
                                        user_group):
                                    assign_perm('view_resourcebase',
                                                user_group,
                                                _resource.get_self_resource())

                        anonymous_can_download = settings.DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION
                        if anonymous_can_download:
                            assign_perm('download_resourcebase',
                                        anonymous_group,
                                        _resource.get_self_resource())
                        else:
                            for user_group in get_user_groups(_owner):
                                if not skip_registered_members_common_group(
                                        user_group):
Ejemplo n.º 2
0
                                purge_geofence_dataset_rules(instance.get_self_resource())

                            # Owner & Managers
                            perms = [
                                "view_resourcebase",
                                "change_dataset_data",
                                "change_dataset_style",
                                "change_resourcebase",
                                "change_resourcebase_permissions",
                                "download_resourcebase"]
                            sync_geofence_with_guardian(instance, perms, user=_owner)
                            gf_services = _get_gf_services(instance, perms)
                            _, _, _disable_dataset_cache, _, _, _ = get_user_geolimits(instance, _owner, None, gf_services)
                            _disable_cache.append(_disable_dataset_cache)

                            _member_group_perm, _group_managers = instance.get_group_managers(get_user_groups(_owner))
                            for _group_manager in _group_managers:
                                sync_geofence_with_guardian(instance, perms, user=_group_manager)
                                _, _, _disable_dataset_cache, _, _, _ = get_user_geolimits(instance, _group_manager, None, gf_services)
                                _disable_cache.append(_disable_dataset_cache)

                            for user_group in get_user_groups(_owner):
                                if not skip_registered_members_common_group(user_group):
                                    sync_geofence_with_guardian(instance, perms, group=user_group)
                                    _, _, _disable_dataset_cache, _, _, _ = get_user_geolimits(instance, None, user_group, gf_services)
                                    _disable_cache.append(_disable_dataset_cache)

                            # Anonymous
                            if anonymous_can_view:
                                sync_geofence_with_guardian(instance, VIEW_PERMISSIONS, user=None, group=None)
                                gf_services = _get_gf_services(instance, VIEW_PERMISSIONS)