decidim-restfull-core 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/app/commands/decidim/rest_full/core/create_api_client.rb +40 -0
- data/app/commands/decidim/rest_full/core/impersonate_resource_owner_from_credentials.rb +151 -0
- data/app/commands/decidim/rest_full/core/syncronize_unconfirmed_host.rb +45 -0
- data/app/controllers/concerns/decidim/api/rest_full/async_api_job_enqueuing.rb +69 -0
- data/app/controllers/concerns/decidim/api/rest_full/collection_pagination.rb +78 -0
- data/app/controllers/concerns/decidim/api/rest_full/collection_pagination_meta.rb +25 -0
- data/app/controllers/concerns/decidim/api/rest_full/conditional_get_rendering.rb +49 -0
- data/app/controllers/concerns/decidim/api/rest_full/extended_data_endpoints.rb +96 -0
- data/app/controllers/concerns/decidim/api/rest_full/job_response_linking.rb +31 -0
- data/app/controllers/decidim/api/rest_full/application_controller.rb +245 -0
- data/app/controllers/decidim/api/rest_full/attachments/attachments_controller.rb +81 -0
- data/app/controllers/decidim/api/rest_full/components/component_extended_data_controller.rb +31 -0
- data/app/controllers/decidim/api/rest_full/components/components_controller.rb +68 -0
- data/app/controllers/decidim/api/rest_full/core/resources_controller.rb +142 -0
- data/app/controllers/decidim/api/rest_full/core.rb +11 -0
- data/app/controllers/decidim/api/rest_full/jobs/jobs_controller.rb +109 -0
- data/app/controllers/decidim/api/rest_full/organizations/organization_extended_data_controller.rb +31 -0
- data/app/controllers/decidim/api/rest_full/organizations/organizations_controller.rb +234 -0
- data/app/controllers/decidim/api/rest_full/roles/roles_controller.rb +125 -0
- data/app/controllers/decidim/api/rest_full/spaces/space_extended_data_controller.rb +29 -0
- data/app/controllers/decidim/api/rest_full/spaces/spaces_controller.rb +225 -0
- data/app/controllers/decidim/api/rest_full/users/magic_links_controller.rb +81 -0
- data/app/controllers/decidim/api/rest_full/users/user_extended_data_controller.rb +92 -0
- data/app/controllers/decidim/api/rest_full/users/users_controller.rb +40 -0
- data/app/controllers/decidim/api/rest_full/webhooks/webhook_events_controller.rb +33 -0
- data/app/controllers/decidim/api/rest_full/webhooks/webhook_registrations_controller.rb +106 -0
- data/app/controllers/decidim/rest_full/pages_controller.rb +9 -0
- data/app/controllers/decidim/rest_full/system/api_clients_controller.rb +69 -0
- data/app/controllers/decidim/rest_full/system/permissions_controller.rb +30 -0
- data/app/controllers/decidim/rest_full/system/webhook_registrations_controller.rb +49 -0
- data/app/forms/decidim/rest_full/core/admin/config_form.rb +49 -0
- data/app/forms/decidim/rest_full/core/api_client_form.rb +20 -0
- data/app/forms/decidim/rest_full/core/api_permissions.rb +18 -0
- data/app/forms/decidim/rest_full/core/magic_link_redirect_url_form.rb +114 -0
- data/app/forms/decidim/rest_full/core/webhook_event_form.rb +35 -0
- data/app/forms/decidim/rest_full/core/webhook_registration_form.rb +49 -0
- data/app/jobs/decidim/rest_full/application_job.rb +10 -0
- data/app/jobs/decidim/rest_full/core/space_webhook_job.rb +60 -0
- data/app/jobs/decidim/rest_full/core/syncronize_unconfirmed_host_job.rb +18 -0
- data/app/jobs/decidim/rest_full/core/webhook_job.rb +13 -0
- data/app/jobs/decidim/rest_full/execute_api_job_job.rb +55 -0
- data/app/models/decidim/rest_full/api_job.rb +74 -0
- data/app/models/decidim/rest_full/core/ability.rb +195 -0
- data/app/models/decidim/rest_full/core/api_client.rb +56 -0
- data/app/models/decidim/rest_full/core/magic_token.rb +45 -0
- data/app/models/decidim/rest_full/core/permission.rb +15 -0
- data/app/models/decidim/rest_full/core/resource_extended_data.rb +16 -0
- data/app/models/decidim/rest_full/core/webhook_registration.rb +61 -0
- data/app/overrides/system_host_input.rb +40 -0
- data/app/serializers/decidim/api/rest_full/core/application_serializer.rb +19 -0
- data/app/serializers/decidim/api/rest_full/core/assembly_serializer.rb +13 -0
- data/app/serializers/decidim/api/rest_full/core/attachment_serializer.rb +76 -0
- data/app/serializers/decidim/api/rest_full/core/awesome_iframe_component_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/awesome_map_component_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/component_serializer.rb +97 -0
- data/app/serializers/decidim/api/rest_full/core/helpers/resource_links_helper.rb +48 -0
- data/app/serializers/decidim/api/rest_full/core/magic_link_redirect_serializer.rb +43 -0
- data/app/serializers/decidim/api/rest_full/core/magic_link_serializer.rb +44 -0
- data/app/serializers/decidim/api/rest_full/core/organization_serializer.rb +60 -0
- data/app/serializers/decidim/api/rest_full/core/organization_webhook_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/page_component_serializer.rb +20 -0
- data/app/serializers/decidim/api/rest_full/core/page_serializer.rb +12 -0
- data/app/serializers/decidim/api/rest_full/core/participatory_process_serializer.rb +13 -0
- data/app/serializers/decidim/api/rest_full/core/resource_serializer.rb +84 -0
- data/app/serializers/decidim/api/rest_full/core/role_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/serializer_lookup.rb +55 -0
- data/app/serializers/decidim/api/rest_full/core/space_serializer.rb +117 -0
- data/app/serializers/decidim/api/rest_full/core/space_webhook_serializer.rb +64 -0
- data/app/serializers/decidim/api/rest_full/core/user_serializer.rb +43 -0
- data/app/serializers/decidim/api/rest_full/core/user_webhook_serializer.rb +21 -0
- data/app/serializers/decidim/api/rest_full/core/webhook_registration_serializer.rb +25 -0
- data/app/serializers/decidim/api/rest_full/core/webhook_serializer.rb +68 -0
- data/app/serializers/decidim/api/rest_full/core.rb +10 -0
- data/app/services/decidim/rest_full/core/api_system_operations.rb +505 -0
- data/app/services/decidim/rest_full/core/fire_webhook.rb +114 -0
- data/app/services/decidim/rest_full/core/participatory_process_step_activated_webhook_handler.rb +39 -0
- data/app/services/decidim/rest_full/participatory_space_visibility.rb +64 -0
- data/app/views/decidim/rest_full/core/admin/_organization_settings_tab.html.erb +35 -0
- data/app/views/decidim/rest_full/pages/show.html.erb +60 -0
- data/app/views/decidim/rest_full/system/api_clients/_edit_info_tab.erb +261 -0
- data/app/views/decidim/rest_full/system/api_clients/_edit_webhook_tab.erb +74 -0
- data/app/views/decidim/rest_full/system/api_clients/_form.html.erb +23 -0
- data/app/views/decidim/rest_full/system/api_clients/_permissions_scope.html.erb +22 -0
- data/app/views/decidim/rest_full/system/api_clients/edit.html.erb +53 -0
- data/app/views/decidim/rest_full/system/api_clients/index.html.erb +37 -0
- data/app/views/decidim/rest_full/system/api_clients/new.html.erb +13 -0
- data/app/views/decidim/rest_full/system/api_clients/show.html.erb +10 -0
- data/config/i18n-tasks.yml +381 -0
- data/config/locales/decidim_rest_full.en.yml +184 -0
- data/config/routes.rb +116 -0
- data/db/migrate/20241125061513_create_api_client_permissions.rb +12 -0
- data/db/migrate/20250112155305_create_proposal_application_id.rb +11 -0
- data/db/migrate/20250131155931_add_users_magic_token.rb +14 -0
- data/db/migrate/20250609083335_create_webhooks_table.rb +16 -0
- data/db/migrate/20250609091039_add_is_event_to_api_client_permissions.rb +7 -0
- data/db/migrate/20250624080106_create_organization_extended_data.rb +11 -0
- data/db/migrate/20260321120000_add_redirect_url_to_decidim_rest_full_user_magic_tokens.rb +7 -0
- data/db/migrate/20260511120000_create_decidim_rest_full_api_jobs.rb +23 -0
- data/db/migrate/20260515120000_add_poll_and_oauth_context_to_rest_full_api_jobs.rb +38 -0
- data/db/migrate/20260516153000_remove_poll_secret_from_decidim_rest_full_api_jobs.rb +7 -0
- data/db/migrate/20260516160000_add_org_status_index_to_rest_full_api_jobs.rb +9 -0
- data/db/migrate/20260805070000_create_resource_extended_data.rb +44 -0
- data/lib/decidim/rest_full/api_execution_context.rb +58 -0
- data/lib/decidim/rest_full/api_job_command_runner.rb +48 -0
- data/lib/decidim/rest_full/api_job_payload.rb +19 -0
- data/lib/decidim/rest_full/cli/base.rb +84 -0
- data/lib/decidim/rest_full/cli/create.rb +122 -0
- data/lib/decidim/rest_full/cli/delete.rb +48 -0
- data/lib/decidim/rest_full/cli/get.rb +53 -0
- data/lib/decidim/rest_full/cli/grant.rb +58 -0
- data/lib/decidim/rest_full/cli/revoke.rb +53 -0
- data/lib/decidim/rest_full/cli.rb +70 -0
- data/lib/decidim/rest_full/core/apartment_tenant_switch.rb +23 -0
- data/lib/decidim/rest_full/core/api_exception.rb +179 -0
- data/lib/decidim/rest_full/core/attachments_operations.rb +232 -0
- data/lib/decidim/rest_full/core/configuration.rb +116 -0
- data/lib/decidim/rest_full/core/definition_registry.rb +509 -0
- data/lib/decidim/rest_full/core/doorkeeper_config.rb +130 -0
- data/lib/decidim/rest_full/core/engine.rb +167 -0
- data/lib/decidim/rest_full/core/extended_data_at_path.rb +22 -0
- data/lib/decidim/rest_full/core/gem_spec_paths.rb +56 -0
- data/lib/decidim/rest_full/core/has_extended_data.rb +70 -0
- data/lib/decidim/rest_full/core/http_cache/collection_fingerprint.rb +97 -0
- data/lib/decidim/rest_full/core/http_cache/fingerprint_contributor_registry.rb +53 -0
- data/lib/decidim/rest_full/core/http_cache/request_oauth_context.rb +34 -0
- data/lib/decidim/rest_full/core/http_cache/resource_show_fingerprint.rb +74 -0
- data/lib/decidim/rest_full/core/menu.rb +18 -0
- data/lib/decidim/rest_full/core/module_availability.rb +181 -0
- data/lib/decidim/rest_full/core/open_api_definition_paths.rb +59 -0
- data/lib/decidim/rest_full/core/overrides/application_mailer_override.rb +50 -0
- data/lib/decidim/rest_full/core/overrides/organization_client_ids_override.rb +17 -0
- data/lib/decidim/rest_full/core/overrides/update_organization_command_override.rb +27 -0
- data/lib/decidim/rest_full/core/overrides/update_organization_form_override.rb +46 -0
- data/lib/decidim/rest_full/core/overrides/user_extended_data_ransack.rb +15 -0
- data/lib/decidim/rest_full/core/overrides/user_magic_token_override.rb +27 -0
- data/lib/decidim/rest_full/core/permission_registry.rb +65 -0
- data/lib/decidim/rest_full/core/ransackers.rb +99 -0
- data/lib/decidim/rest_full/core/rest_enhancement_builder.rb +115 -0
- data/lib/decidim/rest_full/core/rest_enhancement_registration.rb +21 -0
- data/lib/decidim/rest_full/core/roles/role_id_codec.rb +50 -0
- data/lib/decidim/rest_full/core/roles/roles_aggregator.rb +203 -0
- data/lib/decidim/rest_full/core/roles/roles_writer.rb +343 -0
- data/lib/decidim/rest_full/core/route_registry.rb +123 -0
- data/lib/decidim/rest_full/core/serializer_additions_registry.rb +100 -0
- data/lib/decidim/rest_full/core/settings_tab.rb +22 -0
- data/lib/decidim/rest_full/core/swagger_spec_paths.rb +61 -0
- data/lib/decidim/rest_full/core/tokens_availability.rb +23 -0
- data/lib/decidim/rest_full/core/webhook_dispatcher.rb +55 -0
- data/lib/decidim/rest_full/core/webhook_event_catalog.rb +136 -0
- data/lib/decidim/rest_full/extension.rb +276 -0
- data/lib/decidim/rest_full/rest_full.rb +12 -0
- data/lib/decidim/rest_full/routes.rb +58 -0
- data/lib/decidim/rest_full/routing.rb +53 -0
- data/lib/decidim/rest_full/sync_runner.rb +14 -0
- data/lib/decidim/rest_full/test/apartment.rb +52 -0
- data/lib/decidim/rest_full/test/definitions/README.md +96 -0
- data/lib/decidim/rest_full/test/definitions/attachment.rb +64 -0
- data/lib/decidim/rest_full/test/definitions/collection_meta.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/component.rb +99 -0
- data/lib/decidim/rest_full/test/definitions/component_type.rb +8 -0
- data/lib/decidim/rest_full/test/definitions/core.rb +16 -0
- data/lib/decidim/rest_full/test/definitions/creation_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/edition_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/error.rb +40 -0
- data/lib/decidim/rest_full/test/definitions/filter_param.rb +105 -0
- data/lib/decidim/rest_full/test/definitions/grant_param.rb +82 -0
- data/lib/decidim/rest_full/test/definitions/health.rb +12 -0
- data/lib/decidim/rest_full/test/definitions/introspect_data.rb +67 -0
- data/lib/decidim/rest_full/test/definitions/job.rb +130 -0
- data/lib/decidim/rest_full/test/definitions/locales_param.rb +19 -0
- data/lib/decidim/rest_full/test/definitions/magic_link.rb +37 -0
- data/lib/decidim/rest_full/test/definitions/magic_link_redirect.rb +32 -0
- data/lib/decidim/rest_full/test/definitions/manifests.rb +28 -0
- data/lib/decidim/rest_full/test/definitions/oauth_token_response.rb +18 -0
- data/lib/decidim/rest_full/test/definitions/organization.rb +75 -0
- data/lib/decidim/rest_full/test/definitions/organization_extended_data.rb +19 -0
- data/lib/decidim/rest_full/test/definitions/publication_date.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/relationship_identifier.rb +29 -0
- data/lib/decidim/rest_full/test/definitions/resource_extended_data.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/role.rb +61 -0
- data/lib/decidim/rest_full/test/definitions/shared.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/space.rb +112 -0
- data/lib/decidim/rest_full/test/definitions/tags/attachments_tag.rb +26 -0
- data/lib/decidim/rest_full/test/definitions/tags/component_tag.rb +26 -0
- data/lib/decidim/rest_full/test/definitions/tags/jobs_tag.rb +20 -0
- data/lib/decidim/rest_full/test/definitions/tags/oauth_tag.rb +28 -0
- data/lib/decidim/rest_full/test/definitions/tags/organization_extended_data_tag.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/tags/organizations_tag.rb +24 -0
- data/lib/decidim/rest_full/test/definitions/tags/roles_tag.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/tags/space_tag.rb +22 -0
- data/lib/decidim/rest_full/test/definitions/tags/users_tag.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/tags/webhooks_tag.rb +31 -0
- data/lib/decidim/rest_full/test/definitions/tags.rb +12 -0
- data/lib/decidim/rest_full/test/definitions/time_zone.rb +10 -0
- data/lib/decidim/rest_full/test/definitions/translated_prop.rb +11 -0
- data/lib/decidim/rest_full/test/definitions/user.rb +93 -0
- data/lib/decidim/rest_full/test/definitions/user_extended_data.rb +14 -0
- data/lib/decidim/rest_full/test/definitions/webhook.rb +95 -0
- data/lib/decidim/rest_full/test/definitions.rb +15 -0
- data/lib/decidim/rest_full/test/factories/api_client.rb +16 -0
- data/lib/decidim/rest_full/test/factories/magic_token.rb +13 -0
- data/lib/decidim/rest_full/test/factories/webhook_registration.rb +10 -0
- data/lib/decidim/rest_full/test/factories.rb +5 -0
- data/lib/decidim/rest_full/test/global_context.rb +11 -0
- data/lib/decidim/rest_full/test/on_api_endpoint_methods.rb +190 -0
- data/lib/decidim/rest_full/test/open_api_tag_registry.rb +25 -0
- data/lib/decidim/rest_full/test/openapi_specs.rb +107 -0
- data/lib/decidim/rest_full/test/shared_examples/has_extended_data.rb +41 -0
- data/lib/decidim/rest_full/test/shared_examples.rb +345 -0
- data/lib/decidim/rest_full/version.rb +27 -0
- data/lib/decidim/rest_full.rb +99 -0
- data/lib/decidim-restfull-core.rb +3 -0
- data/lib/tasks/decidim/rest_full/fire_webhook.rake +52 -0
- data/lib/tasks/decidim/rest_full/integrator_sandbox.rake +37 -0
- data/lib/tasks/decidim/rest_full/rest_full_upgrade.rake +64 -0
- data/lib/tasks/decidim/rest_full/rest_full_webpacker.rake +58 -0
- data/spec/commands/decidim/rest_full/core/impersonate_resource_owner_from_credentials_spec.rb +159 -0
- data/spec/commands/decidim/rest_full/core/syncronize_unconfirmed_host_spec.rb +117 -0
- data/spec/controllers/concerns/decidim/api/rest_full/collection_pagination_spec.rb +128 -0
- data/spec/decidim/rest_full/core/configuration_engine_disabled_routes_spec.rb +24 -0
- data/spec/forms/decidim/rest_full/core/magic_link_redirect_url_form_spec.rb +69 -0
- data/spec/forms/decidim/rest_full/core/webhook_registration_form_spec.rb +42 -0
- data/spec/jobs/decidim/rest_full/core/space_webhook_job_spec.rb +62 -0
- data/spec/jobs/decidim/rest_full/core/syncronize_unconfirmed_host_job_spec.rb +34 -0
- data/spec/jobs/decidim/rest_full/core/webhook_job_spec.rb +29 -0
- data/spec/jobs/decidim/rest_full/execute_api_job_job_spec.rb +45 -0
- data/spec/lib/decidim/rest_full/core/apartment_tenant_switch_spec.rb +26 -0
- data/spec/lib/decidim/rest_full/core/api_exception/bad_request_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/core/definition_registry_add_resource_relationships_spec.rb +19 -0
- data/spec/lib/decidim/rest_full/core/gem_spec_paths_spec.rb +27 -0
- data/spec/lib/decidim/rest_full/core/http_cache/collection_fingerprint_spec.rb +59 -0
- data/spec/lib/decidim/rest_full/core/http_cache/fingerprint_contributor_registry_spec.rb +60 -0
- data/spec/lib/decidim/rest_full/core/http_cache/resource_show_fingerprint_spec.rb +33 -0
- data/spec/lib/decidim/rest_full/core/module_availability_spec.rb +130 -0
- data/spec/lib/decidim/rest_full/core/open_api_definition_paths_spec.rb +54 -0
- data/spec/lib/decidim/rest_full/core/optional_feature_gems_spec.rb +172 -0
- data/spec/lib/decidim/rest_full/core/roles/role_id_codec_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/core/roles/roles_aggregator_spec.rb +53 -0
- data/spec/lib/decidim/rest_full/core/roles/roles_writer_spec.rb +38 -0
- data/spec/lib/decidim/rest_full/core/route_registry_spec.rb +90 -0
- data/spec/lib/decidim/rest_full/core/serializer_additions_registry_spec.rb +100 -0
- data/spec/lib/decidim/rest_full/core/settings_tab_spec.rb +15 -0
- data/spec/lib/decidim/rest_full/core/swagger_spec_paths_spec.rb +50 -0
- data/spec/lib/decidim/rest_full/core/webhook_dispatcher_proposal_published_spec.rb +63 -0
- data/spec/lib/decidim/rest_full/core/webhook_event_catalog_spec.rb +34 -0
- data/spec/lib/decidim/rest_full/routing_spec.rb +62 -0
- data/spec/lib/decidim/rest_full/test/apartment_spec.rb +17 -0
- data/spec/models/decidim/rest_full/api_job_spec.rb +51 -0
- data/spec/models/decidim/rest_full/application_mailer_override_spec.rb +60 -0
- data/spec/models/decidim/rest_full/core/has_extended_data_spec.rb +16 -0
- data/spec/models/decidim/rest_full/core/magic_token_spec.rb +68 -0
- data/spec/models/decidim/rest_full/core/webhook_registration_spec.rb +161 -0
- data/spec/models/decidim/rest_full/user_magic_token_spec.rb +51 -0
- data/spec/requests/decidim/api/rest_full/application_controller_introspect_spec.rb +85 -0
- data/spec/requests/decidim/api/rest_full/application_controller_ropc_spec.rb +299 -0
- data/spec/requests/decidim/api/rest_full/application_controller_token_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_direct_upload_spec.rb +39 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_index_spec.rb +41 -0
- data/spec/requests/decidim/api/rest_full/attachments/attachments_controller_show_spec.rb +34 -0
- data/spec/requests/decidim/api/rest_full/components/component_extended_data_controller_spec.rb +78 -0
- data/spec/requests/decidim/api/rest_full/components/components_controller_search_spec.rb +197 -0
- data/spec/requests/decidim/api/rest_full/components/components_controller_search_sql_spec.rb +48 -0
- data/spec/requests/decidim/api/rest_full/jobs/api_jobs_async_and_conditional_get_spec.rb +209 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_destroy_spec.rb +58 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_index_spec.rb +126 -0
- data/spec/requests/decidim/api/rest_full/jobs/jobs_controller_show_spec.rb +89 -0
- data/spec/requests/decidim/api/rest_full/module_availability_gate_spec.rb +77 -0
- data/spec/requests/decidim/api/rest_full/organizations/organization_extended_data_controller_index_spec.rb +88 -0
- data/spec/requests/decidim/api/rest_full/organizations/organization_extended_data_controller_update_spec.rb +194 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_index_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_show_spec.rb +66 -0
- data/spec/requests/decidim/api/rest_full/organizations/organizations_controller_update_spec.rb +120 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_create_spec.rb +230 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_destroy_spec.rb +52 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_index_spec.rb +127 -0
- data/spec/requests/decidim/api/rest_full/roles/roles_controller_show_spec.rb +215 -0
- data/spec/requests/decidim/api/rest_full/routes_boot_spec.rb +58 -0
- data/spec/requests/decidim/api/rest_full/scenarios/upsert_user_by_phone_and_set_locale_spec.rb +69 -0
- data/spec/requests/decidim/api/rest_full/spaces/space_extended_data_controller_spec.rb +78 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_index_spec.rb +167 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_search_spec.rb +280 -0
- data/spec/requests/decidim/api/rest_full/spaces/spaces_controller_show_spec.rb +98 -0
- data/spec/requests/decidim/api/rest_full/users/magic_links_controller_create_spec.rb +124 -0
- data/spec/requests/decidim/api/rest_full/users/magic_links_controller_show_spec.rb +84 -0
- data/spec/requests/decidim/api/rest_full/users/user_extended_data_controller_index_spec.rb +74 -0
- data/spec/requests/decidim/api/rest_full/users/user_extended_data_controller_update_spec.rb +192 -0
- data/spec/requests/decidim/api/rest_full/users/users_controller_index_spec.rb +182 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_events_controller_show_spec.rb +52 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_create_spec.rb +95 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_destroy_spec.rb +34 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_index_spec.rb +43 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_show_spec.rb +51 -0
- data/spec/requests/decidim/api/rest_full/webhooks/webhook_registrations_controller_update_spec.rb +57 -0
- data/spec/requests/decidim/rest_full/system/api_clients_controller_spec.rb +69 -0
- data/spec/serializers/decidim/api/rest_full/core/organization_webhook_serializer_spec.rb +18 -0
- data/spec/serializers/decidim/api/rest_full/core/space_webhook_serializer_spec.rb +44 -0
- data/spec/serializers/decidim/api/rest_full/core/user_webhook_serializer_spec.rb +19 -0
- data/spec/services/decidim/rest_full/core/api_system_operations_resource_extended_data_update_spec.rb +35 -0
- data/spec/services/decidim/rest_full/core/fire_webhook_spec.rb +59 -0
- data/spec/services/decidim/rest_full/core/participatory_process_step_activated_webhook_handler_spec.rb +57 -0
- metadata +482 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module RestFull
|
|
5
|
+
# Shared participatory-space / component visibility for API actors and services.
|
|
6
|
+
# Used by {Decidim::Api::RestFull::ApplicationController}, proposal operations, etc.
|
|
7
|
+
class ParticipatorySpaceVisibility
|
|
8
|
+
def initialize(organization:, act_as:)
|
|
9
|
+
@organization = organization
|
|
10
|
+
@act_as = act_as
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def visible_spaces
|
|
14
|
+
@visible_spaces ||= begin
|
|
15
|
+
spaces = Decidim.participatory_space_registry.manifests.map do |space|
|
|
16
|
+
model = space.model_class_name
|
|
17
|
+
next unless Object.const_defined?(model)
|
|
18
|
+
|
|
19
|
+
klass = model.constantize
|
|
20
|
+
query = visible_scope_for(klass, act_as)
|
|
21
|
+
{
|
|
22
|
+
participatory_space_type: model,
|
|
23
|
+
participatory_space_id: query.ids
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
spaces.compact.reject { |s| s[:participatory_space_id].empty? }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def in_visible_spaces(context = Decidim::Component.all)
|
|
31
|
+
vs = visible_spaces
|
|
32
|
+
if vs.size.positive?
|
|
33
|
+
first = vs.first
|
|
34
|
+
query = context.where(**first)
|
|
35
|
+
vs[1..].each { |s| query = query.or(context.where(**s)) }
|
|
36
|
+
query
|
|
37
|
+
else
|
|
38
|
+
context.where("1=0")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def visible_scope_for(klass, user)
|
|
43
|
+
base = klass.where(organization:)
|
|
44
|
+
if base.respond_to?(:visible_for)
|
|
45
|
+
base.visible_for(user)
|
|
46
|
+
elsif base.respond_to?(:published)
|
|
47
|
+
base.published
|
|
48
|
+
else
|
|
49
|
+
base
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def space_class_from_name(manifest_name)
|
|
54
|
+
Decidim.participatory_space_registry.manifests.find do |manifest|
|
|
55
|
+
manifest.name == :"#{manifest_name}"
|
|
56
|
+
end.model_class_name
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
attr_reader :organization, :act_as
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
2
|
+
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
3
|
+
<div data-restfull-toggle-tab>
|
|
4
|
+
<%= tf.fields_for_names(:enabled) %>
|
|
5
|
+
<% available = Decidim::RestFull::Core::ModuleAvailability.available_feature_modules %>
|
|
6
|
+
<% if available.any? %>
|
|
7
|
+
<fieldset class="mt-4" data-restfull-toggle-modules>
|
|
8
|
+
<legend class="form-legend"><%= t("decidim_toggle.system.decidim_restfull.modules_legend") %></legend>
|
|
9
|
+
<%= tf.fields_for_names(*available.map { |feature| :"#{feature}_enabled" }) %>
|
|
10
|
+
</fieldset>
|
|
11
|
+
<% end %>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
15
|
+
<script nonce="<%= content_security_policy_nonce %>">
|
|
16
|
+
(function () {
|
|
17
|
+
var root = document.querySelector("[data-restfull-toggle-tab]");
|
|
18
|
+
if (!root) return;
|
|
19
|
+
var master = root.querySelector('input[type="checkbox"][name$="[enabled]"]');
|
|
20
|
+
var modules = root.querySelector("[data-restfull-toggle-modules]");
|
|
21
|
+
if (!master || !modules) return;
|
|
22
|
+
|
|
23
|
+
function sync() {
|
|
24
|
+
var on = master.checked;
|
|
25
|
+
modules.querySelectorAll('input[type="checkbox"]').forEach(function (input) {
|
|
26
|
+
input.disabled = !on;
|
|
27
|
+
var field = input.closest(".field");
|
|
28
|
+
if (field) field.classList.toggle("is-disabled", !on);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
master.addEventListener("change", sync);
|
|
33
|
+
sync();
|
|
34
|
+
})();
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title><%= t(".title", default: "Decidim Rest API") %></title>
|
|
7
|
+
<style>
|
|
8
|
+
.container {
|
|
9
|
+
position: fixed;
|
|
10
|
+
top: 0;
|
|
11
|
+
left: 0;
|
|
12
|
+
right: 0;
|
|
13
|
+
bottom: 0;
|
|
14
|
+
background: #313131;
|
|
15
|
+
color: white;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
}
|
|
22
|
+
.h1 {
|
|
23
|
+
display: block;
|
|
24
|
+
min-width: 100%;
|
|
25
|
+
text-align: center;
|
|
26
|
+
}
|
|
27
|
+
.button {
|
|
28
|
+
color: white;
|
|
29
|
+
padding: 8px 16px;
|
|
30
|
+
border: 1px solid white;
|
|
31
|
+
margin: 1rem;
|
|
32
|
+
font-size: 21px;
|
|
33
|
+
letter-spacing: 0.2px;
|
|
34
|
+
display: inline-block;
|
|
35
|
+
border-radius: 4px;
|
|
36
|
+
text-decoration: none;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
.button:hover{
|
|
40
|
+
color: white;
|
|
41
|
+
opacity: 0.8;
|
|
42
|
+
text-decoration: none;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
45
|
+
</head>
|
|
46
|
+
<body>
|
|
47
|
+
<div class="container">
|
|
48
|
+
<h1 class="h1"><%= t(".title", default: "Decidim Rest API") %></h1>
|
|
49
|
+
|
|
50
|
+
<div>
|
|
51
|
+
<a class="button" href="<%= Decidim::RestFull.config.docs_url %>/" target="_blank">
|
|
52
|
+
<%= t(".documentation_website", default: "Documentation website") %>
|
|
53
|
+
</a>
|
|
54
|
+
<a class="button" href="/api/rest/docs/openapi.json" target="_blank">
|
|
55
|
+
<%= t(".open_api_spec", default: "Open API spec") %>
|
|
56
|
+
</a>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</body>
|
|
60
|
+
</html>
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
<%= decidim_form_for(@form) do |f| %>
|
|
2
|
+
<%= render partial: "form", object: f, locals: { disabled:true } %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<div class="form__wrapper">
|
|
6
|
+
<h3 class="h5"><%= t(".keys_label") %></h3>
|
|
7
|
+
<label>
|
|
8
|
+
<span><%= t(".client_id") %></span>
|
|
9
|
+
<input type="text" value="<%= @api_client.client_id %>" name="unnamed" autocomplete="off">
|
|
10
|
+
</label>
|
|
11
|
+
<label>
|
|
12
|
+
<span><%= t(".client_secret") %></span>
|
|
13
|
+
<input type="text" value="<%= @api_client.client_secret %>" name="unnamed" autocomplete="off">
|
|
14
|
+
</label>
|
|
15
|
+
</div>
|
|
16
|
+
<h2 class="h2"><%= t(".permissions_title") %></h2>
|
|
17
|
+
<div>
|
|
18
|
+
<strong><%= t(".permissions_scopes") %></strong><code><%= @api_client.scopes.to_a %></code>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<%= form_for(@perm_form, method: :post, url: system_api_permissions_path ) do |form| %>
|
|
22
|
+
<%= form.hidden_field :api_client_id, value: @api_client.id %>
|
|
23
|
+
<% org = @api_client.organization %>
|
|
24
|
+
<% avail = Decidim::RestFull::Core::ModuleAvailability %>
|
|
25
|
+
<% if avail.scope_enabled?(org, :system) && @api_client.scopes.to_a.include?("system") %>
|
|
26
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
27
|
+
locals: {
|
|
28
|
+
form:,
|
|
29
|
+
api_client:,
|
|
30
|
+
scope: :system,
|
|
31
|
+
dom_id: "system_permissions",
|
|
32
|
+
title: t("scope_system", scope: "decidim.rest_full.models.api_client.fields"),
|
|
33
|
+
groups: [
|
|
34
|
+
{ group: :auth_type, label: t(".auth_type") },
|
|
35
|
+
{ group: :organization, label: t(".organization_perm") },
|
|
36
|
+
{ group: :user, label: t(".user_perm") }
|
|
37
|
+
]
|
|
38
|
+
} %>
|
|
39
|
+
<% end %>
|
|
40
|
+
<% if avail.scope_enabled?(org, :public) && @api_client.scopes.to_a.include?("public") %>
|
|
41
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
42
|
+
locals: {
|
|
43
|
+
form:,
|
|
44
|
+
api_client:,
|
|
45
|
+
scope: :public,
|
|
46
|
+
dom_id: "public_permissions",
|
|
47
|
+
title: t("scope_public", scope: "decidim.rest_full.models.api_client.fields"),
|
|
48
|
+
groups: [
|
|
49
|
+
{ group: :component, label: t(".component") },
|
|
50
|
+
{ group: :space, label: t(".space") }
|
|
51
|
+
]
|
|
52
|
+
} %>
|
|
53
|
+
<% public_events = Decidim::RestFull::Core::WebhookEventCatalog.all.select { |e| e.scope == "public" }.map(&:event_name) %>
|
|
54
|
+
<% if public_events.any? %>
|
|
55
|
+
<div class="mt-4">
|
|
56
|
+
<strong><%= t("webhook_events", scope: "decidim.rest_full.system.api_clients") %></strong><br>
|
|
57
|
+
<p class="text-sm">
|
|
58
|
+
<%= t("webhook_events_description", scope: "decidim.rest_full.system.api_clients") %>
|
|
59
|
+
</p>
|
|
60
|
+
<ul>
|
|
61
|
+
<% public_events.each do |permission| %>
|
|
62
|
+
<li class="my-2">
|
|
63
|
+
<label>
|
|
64
|
+
<%= form.check_box :permissions, { multiple: true, label: "", checked: api_client.permissions.pluck(:permission).include?(permission.to_s) }, permission, nil %>
|
|
65
|
+
<span class="font-normal">
|
|
66
|
+
<%= t(permission.to_s, scope: "decidim.rest_full.models.api_client.permission") %>
|
|
67
|
+
</span>
|
|
68
|
+
</label>
|
|
69
|
+
</li>
|
|
70
|
+
<% end %>
|
|
71
|
+
</ul>
|
|
72
|
+
</div>
|
|
73
|
+
<% end %>
|
|
74
|
+
<% end %>
|
|
75
|
+
<% if avail.scope_enabled?(org, :blogs) && @api_client.scopes.to_a.include?("blogs") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:blogs).any? %>
|
|
76
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
77
|
+
locals: {
|
|
78
|
+
form:,
|
|
79
|
+
api_client:,
|
|
80
|
+
scope: :blogs,
|
|
81
|
+
dom_id: "blog_permissions",
|
|
82
|
+
title: t("scope_blogs", scope: "decidim.rest_full.models.api_client.fields"),
|
|
83
|
+
groups: [
|
|
84
|
+
{ group: :blogs, label: t(".blogs") }
|
|
85
|
+
]
|
|
86
|
+
} %>
|
|
87
|
+
<% end %>
|
|
88
|
+
<% if avail.scope_enabled?(org, :debates) && @api_client.scopes.to_a.include?("debates") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:debates).any? %>
|
|
89
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
90
|
+
locals: {
|
|
91
|
+
form:,
|
|
92
|
+
api_client:,
|
|
93
|
+
scope: :debates,
|
|
94
|
+
dom_id: "debates_permissions",
|
|
95
|
+
title: t("scope_debates", scope: "decidim.rest_full.models.api_client.fields"),
|
|
96
|
+
groups: [
|
|
97
|
+
{ group: :debates, label: t(".debates") }
|
|
98
|
+
]
|
|
99
|
+
} %>
|
|
100
|
+
<% end %>
|
|
101
|
+
<% if avail.scope_enabled?(org, :budgets) && @api_client.scopes.to_a.include?("budgets") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:budgets).any? %>
|
|
102
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
103
|
+
locals: {
|
|
104
|
+
form:,
|
|
105
|
+
api_client:,
|
|
106
|
+
scope: :budgets,
|
|
107
|
+
dom_id: "budgets_permissions",
|
|
108
|
+
title: t("scope_budgets", scope: "decidim.rest_full.models.api_client.fields"),
|
|
109
|
+
groups: [
|
|
110
|
+
{ group: :budgets, label: t(".budgets") }
|
|
111
|
+
]
|
|
112
|
+
} %>
|
|
113
|
+
<% end %>
|
|
114
|
+
<% if avail.scope_enabled?(org, :surveys) && @api_client.scopes.to_a.include?("surveys") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:surveys).any? %>
|
|
115
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
116
|
+
locals: {
|
|
117
|
+
form:,
|
|
118
|
+
api_client:,
|
|
119
|
+
scope: :surveys,
|
|
120
|
+
dom_id: "surveys_permissions",
|
|
121
|
+
title: t("scope_surveys", scope: "decidim.rest_full.models.api_client.fields"),
|
|
122
|
+
groups: [
|
|
123
|
+
{ group: :surveys, label: t(".surveys") }
|
|
124
|
+
]
|
|
125
|
+
} %>
|
|
126
|
+
<% end %>
|
|
127
|
+
<% if avail.scope_enabled?(org, :accountability) && @api_client.scopes.to_a.include?("accountability") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:accountability).any? %>
|
|
128
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
129
|
+
locals: {
|
|
130
|
+
form:,
|
|
131
|
+
api_client:,
|
|
132
|
+
scope: :accountability,
|
|
133
|
+
dom_id: "accountability_permissions",
|
|
134
|
+
title: t("scope_accountability", scope: "decidim.rest_full.models.api_client.fields"),
|
|
135
|
+
groups: [
|
|
136
|
+
{ group: :accountability, label: t(".accountability") }
|
|
137
|
+
]
|
|
138
|
+
} %>
|
|
139
|
+
<% end %>
|
|
140
|
+
<% if avail.scope_enabled?(org, :proposals) && @api_client.scopes.to_a.include?("proposals") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:proposals).any? %>
|
|
141
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
142
|
+
locals: {
|
|
143
|
+
form:,
|
|
144
|
+
api_client:,
|
|
145
|
+
scope: :proposals,
|
|
146
|
+
dom_id: "proposals_permission",
|
|
147
|
+
title: t("scope_proposals", scope: "decidim.rest_full.models.api_client.fields"),
|
|
148
|
+
groups: [
|
|
149
|
+
{ group: :proposals, label: t(".proposals") }
|
|
150
|
+
]
|
|
151
|
+
} %>
|
|
152
|
+
<% proposal_events = Decidim::RestFull::Core::WebhookEventCatalog.all.select { |e| e.scope == "proposals" }.map(&:event_name) %>
|
|
153
|
+
<% if proposal_events.any? %>
|
|
154
|
+
<div class="mt-4">
|
|
155
|
+
<strong><%= t("webhook_events", scope: "decidim.rest_full.system.api_clients") %></strong><br>
|
|
156
|
+
<p class="text-sm">
|
|
157
|
+
<%= t("webhook_events_description", scope: "decidim.rest_full.system.api_clients") %>
|
|
158
|
+
</p>
|
|
159
|
+
<ul>
|
|
160
|
+
<% proposal_events.each do |permission| %>
|
|
161
|
+
<li class="my-2">
|
|
162
|
+
<label>
|
|
163
|
+
<%= form.check_box :permissions, { multiple: true, label: "", checked: api_client.permissions.pluck(:permission).include?(permission.to_s) }, permission, nil %>
|
|
164
|
+
<span class="font-normal">
|
|
165
|
+
<%= t(permission.to_s, scope: "decidim.rest_full.models.api_client.permission") %>
|
|
166
|
+
</span>
|
|
167
|
+
</label>
|
|
168
|
+
</li>
|
|
169
|
+
<% end %>
|
|
170
|
+
</ul>
|
|
171
|
+
</div>
|
|
172
|
+
<% end %>
|
|
173
|
+
<% end %>
|
|
174
|
+
<% if avail.scope_enabled?(org, :meetings) && @api_client.scopes.to_a.include?("meetings") && Decidim::RestFull::Core::PermissionRegistry.by_scope(:meetings).any? %>
|
|
175
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
176
|
+
locals: {
|
|
177
|
+
form:,
|
|
178
|
+
api_client:,
|
|
179
|
+
scope: :meetings,
|
|
180
|
+
dom_id: "meetings_permissions",
|
|
181
|
+
title: t("scope_meetings", scope: "decidim.rest_full.models.api_client.fields"),
|
|
182
|
+
groups: [
|
|
183
|
+
{ group: :meetings, label: t(".meetings") }
|
|
184
|
+
]
|
|
185
|
+
} %>
|
|
186
|
+
<% meeting_events = Decidim::RestFull::Core::WebhookEventCatalog.all.select { |e| e.scope == "meetings" }.map(&:event_name) %>
|
|
187
|
+
<% if meeting_events.any? %>
|
|
188
|
+
<div class="mt-4">
|
|
189
|
+
<strong><%= t("webhook_events", scope: "decidim.rest_full.system.api_clients") %></strong><br>
|
|
190
|
+
<p class="text-sm">
|
|
191
|
+
<%= t("webhook_events_description", scope: "decidim.rest_full.system.api_clients") %>
|
|
192
|
+
</p>
|
|
193
|
+
<ul>
|
|
194
|
+
<% meeting_events.each do |permission| %>
|
|
195
|
+
<li class="my-2">
|
|
196
|
+
<label>
|
|
197
|
+
<%= form.check_box :permissions, { multiple: true, label: "", checked: api_client.permissions.pluck(:permission).include?(permission.to_s) }, permission, nil %>
|
|
198
|
+
<span class="font-normal">
|
|
199
|
+
<%= t(permission.to_s, scope: "decidim.rest_full.models.api_client.permission") %>
|
|
200
|
+
</span>
|
|
201
|
+
</label>
|
|
202
|
+
</li>
|
|
203
|
+
<% end %>
|
|
204
|
+
</ul>
|
|
205
|
+
</div>
|
|
206
|
+
<% end %>
|
|
207
|
+
<% end %>
|
|
208
|
+
<% if avail.scope_enabled?(org, :oauth) && @api_client.scopes.to_a.include?("oauth") %>
|
|
209
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
210
|
+
locals: {
|
|
211
|
+
form:,
|
|
212
|
+
api_client:,
|
|
213
|
+
scope: :oauth,
|
|
214
|
+
dom_id: "oauth_permissions",
|
|
215
|
+
title: t("scope_oauth", scope: "decidim.rest_full.models.api_client.fields"),
|
|
216
|
+
groups: [
|
|
217
|
+
{ group: :oauth, label: t(".oauth") }
|
|
218
|
+
]
|
|
219
|
+
} %>
|
|
220
|
+
<% end %>
|
|
221
|
+
<% Decidim::RestFull::Core::PermissionRegistry.extension_ui_scopes.each do |ext_scope| %>
|
|
222
|
+
<% next unless avail.scope_enabled?(org, ext_scope) %>
|
|
223
|
+
<% next unless @api_client.scopes.to_a.include?(ext_scope.to_s) %>
|
|
224
|
+
<% next unless Decidim::RestFull::Core::PermissionRegistry.by_scope(ext_scope).any? %>
|
|
225
|
+
<%= render partial: "/decidim/rest_full/system/api_clients/permissions_scope",
|
|
226
|
+
locals: {
|
|
227
|
+
form:,
|
|
228
|
+
api_client:,
|
|
229
|
+
scope: ext_scope.to_sym,
|
|
230
|
+
dom_id: "#{ext_scope}_permissions",
|
|
231
|
+
title: t("scope_#{ext_scope}", scope: "decidim.rest_full.models.api_client.fields", default: ext_scope.to_s.humanize),
|
|
232
|
+
groups: Decidim::RestFull::Core::PermissionRegistry.extension_ui_groups(ext_scope).map do |group|
|
|
233
|
+
{ group: group.to_sym, label: t(".#{group}", default: group.to_s.humanize) }
|
|
234
|
+
end
|
|
235
|
+
} %>
|
|
236
|
+
<% extension_events = Decidim::RestFull::Core::WebhookEventCatalog.all.select { |e| e.scope == ext_scope.to_s }.map(&:event_name) %>
|
|
237
|
+
<% if extension_events.any? %>
|
|
238
|
+
<div class="mt-4">
|
|
239
|
+
<strong><%= t("webhook_events", scope: "decidim.rest_full.system.api_clients") %></strong><br>
|
|
240
|
+
<p class="text-sm">
|
|
241
|
+
<%= t("webhook_events_description", scope: "decidim.rest_full.system.api_clients") %>
|
|
242
|
+
</p>
|
|
243
|
+
<ul>
|
|
244
|
+
<% extension_events.each do |permission| %>
|
|
245
|
+
<li class="my-2">
|
|
246
|
+
<label>
|
|
247
|
+
<%= form.check_box :permissions, { multiple: true, label: "", checked: api_client.permissions.pluck(:permission).include?(permission.to_s) }, permission, nil %>
|
|
248
|
+
<span class="font-normal">
|
|
249
|
+
<%= t(permission.to_s, scope: "decidim.rest_full.models.api_client.permission", default: permission.to_s) %>
|
|
250
|
+
</span>
|
|
251
|
+
</label>
|
|
252
|
+
</li>
|
|
253
|
+
<% end %>
|
|
254
|
+
</ul>
|
|
255
|
+
</div>
|
|
256
|
+
<% end %>
|
|
257
|
+
<% end %>
|
|
258
|
+
<div class="my-4">
|
|
259
|
+
<%= form.submit t(".update_permissions"), class: "button button__sm md:button__lg button__primary" %>
|
|
260
|
+
</div>
|
|
261
|
+
<% end %>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<% webhook_registrations = Decidim::RestFull::Core::WebhookRegistration.where(api_client_id: @api_client.id) %>
|
|
2
|
+
|
|
3
|
+
<div class="space-y-6">
|
|
4
|
+
<div class="flex justify-between items-center">
|
|
5
|
+
<h2 class="h2"><%= t(".webhook_registrations", default: "Webhook Registrations") %></h2>
|
|
6
|
+
<button type="button" class="button button__sm button__primary" onclick="document.getElementById('new-webhook-form').classList.toggle('hidden')">
|
|
7
|
+
<%= t(".add_webhook", default: "Add Webhook") %>
|
|
8
|
+
</button>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div id="new-webhook-form" class="hidden p-4 bg-gray-50 rounded-lg border border-gray-200">
|
|
12
|
+
<%= form_for(Decidim::RestFull::Core::WebhookRegistrationForm.new, url: system_webhook_registrations_path, html: { class: "space-y-4" }) do |form| %>
|
|
13
|
+
<%= hidden_field_tag "webhook_registration_form[api_client_id]", @api_client.id %>
|
|
14
|
+
<div>
|
|
15
|
+
<label class="block text-sm font-medium text-gray-700 mb-2 required"><%= t(".url", default: "URL") %></label>
|
|
16
|
+
<%= text_field_tag "webhook_registration_form[url]", nil, placeholder: "https://example.org/webhook", autocomplete: "off", class: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary" %>
|
|
17
|
+
</div>
|
|
18
|
+
<div>
|
|
19
|
+
<label class="block text-sm font-medium text-gray-700 mb-2"><%= t(".subscriptions", default: "Subscriptions") %></label>
|
|
20
|
+
<div class="space-y-2">
|
|
21
|
+
<% available_events = @api_client.permissions.events.pluck(:permission) %>
|
|
22
|
+
<% available_events.each do |event| %>
|
|
23
|
+
<label class="flex items-center gap-2">
|
|
24
|
+
<%= check_box_tag "webhook_registration_form[subscriptions][]", event, false, class: "rounded border-gray-300 text-primary focus:ring-primary" %>
|
|
25
|
+
<span class="text-sm text-gray-700"><%= event %></span>
|
|
26
|
+
</label>
|
|
27
|
+
<% end %>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="flex justify-end gap-2">
|
|
31
|
+
<button type="button" onclick="document.getElementById('new-webhook-form').classList.add('hidden')" class="button button__sm button__text-primary">
|
|
32
|
+
<%= t(".cancel", default: "Cancel") %>
|
|
33
|
+
</button>
|
|
34
|
+
<%= form.submit t(".create", default: "Create"), class: "button button__sm button__primary" %>
|
|
35
|
+
</div>
|
|
36
|
+
<% end %>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<% if webhook_registrations.any? %>
|
|
40
|
+
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
|
|
41
|
+
<table class="min-w-full divide-y divide-gray-300">
|
|
42
|
+
<thead class="bg-gray-50">
|
|
43
|
+
<tr>
|
|
44
|
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t(".url", default: "URL") %></th>
|
|
45
|
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t(".subscriptions", default: "Subscriptions") %></th>
|
|
46
|
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t(".created_at", default: "Created At") %></th>
|
|
47
|
+
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t(".actions", default: "Actions") %></th>
|
|
48
|
+
</tr>
|
|
49
|
+
</thead>
|
|
50
|
+
<tbody class="bg-white divide-y divide-gray-200">
|
|
51
|
+
<% webhook_registrations.each do |webhook| %>
|
|
52
|
+
<tr>
|
|
53
|
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900"><%= webhook.url %></td>
|
|
54
|
+
<td class="px-6 py-4 text-sm text-gray-500">
|
|
55
|
+
<div class="flex flex-wrap gap-1">
|
|
56
|
+
<% webhook.subscriptions.each do |subscription| %>
|
|
57
|
+
<span class="inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-gray-100 text-gray-800"><%= subscription %></span>
|
|
58
|
+
<% end %>
|
|
59
|
+
</div>
|
|
60
|
+
</td>
|
|
61
|
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><%= l webhook.created_at, format: :short %></td>
|
|
62
|
+
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
63
|
+
<%= link_to t(".delete", default: "Delete"), system_webhook_registration_path(webhook), method: :delete, data: { confirm: t(".confirm_delete", default: "Are you sure?") }, class: "text-red-600 hover:text-red-900" %> </td>
|
|
64
|
+
</tr>
|
|
65
|
+
<% end %>
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
68
|
+
</div>
|
|
69
|
+
<% else %>
|
|
70
|
+
<div class="text-center py-12 bg-gray-50 rounded-lg border border-gray-200">
|
|
71
|
+
<p class="text-gray-500"><%= t(".no_webhooks", default: "No webhook registrations found.") %></p>
|
|
72
|
+
</div>
|
|
73
|
+
<% end %>
|
|
74
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%# locals: (form:, disabled:) %>
|
|
2
|
+
<div class="form__wrapper">
|
|
3
|
+
<%= form.text_field :name, disabled: %>
|
|
4
|
+
<%= form.select :decidim_organization_id,
|
|
5
|
+
Decidim::Organization.all.map { |o| [organization_name(o), o.id] },
|
|
6
|
+
{ include_blank: t(".select_organization") },
|
|
7
|
+
{ multiple: false, disabled: } %>
|
|
8
|
+
<div>
|
|
9
|
+
<h3 class="h5"><%= t(".scopes_label") %></h3>
|
|
10
|
+
<% organization = form.object.organization || Decidim::Organization.find_by(id: form.object.decidim_organization_id) %>
|
|
11
|
+
<% scopes = if organization
|
|
12
|
+
Decidim::RestFull::Core::DoorkeeperConfig.advertised_scopes_for(organization)
|
|
13
|
+
else
|
|
14
|
+
Decidim::RestFull::Core::DoorkeeperConfig.advertised_scopes
|
|
15
|
+
end %>
|
|
16
|
+
<% scopes.each do |scope| %>
|
|
17
|
+
<label class="block py-2 <%= "hidden" if disabled && form.object.scopes.to_a.exclude?(scope.to_s) %>">
|
|
18
|
+
<%= form.check_box :scopes, { multiple: true, label: "", disabled:, checked: form.object.scopes.to_a.include?(scope.to_s) }, scope, nil %>
|
|
19
|
+
<span class="font-normal"><%= t("scope_#{scope}", scope: "decidim.rest_full.models.api_client.fields") %></span>
|
|
20
|
+
</label>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%# locals: (form:, api_client:, scope:, dom_id:, title:, groups:) %>
|
|
2
|
+
<div class="border border-black my-2">
|
|
3
|
+
<h2 class="border-b-4 h5 p-4" id="<%= dom_id %>">
|
|
4
|
+
<%= title %>
|
|
5
|
+
</h2>
|
|
6
|
+
<div id="<%= dom_id %>" class="p-4 ">
|
|
7
|
+
<% groups.each do |group_def| %>
|
|
8
|
+
<div class="mt-4">
|
|
9
|
+
<div class="font-bold py-2"><%= group_def[:label] %></div>
|
|
10
|
+
<div class="flex gap-6 flex-wrap">
|
|
11
|
+
<% Decidim::RestFull::Core::PermissionRegistry.by_scope_and_group(scope, group_def[:group]).each do |entry| %>
|
|
12
|
+
<% permission = entry.key %>
|
|
13
|
+
<label>
|
|
14
|
+
<%= form.check_box :permissions, { multiple: true, label: "", checked: api_client.permissions.pluck(:permission).include?(permission.to_s) }, permission, nil %>
|
|
15
|
+
<span class="font-normal"><%= t(permission.to_s, scope: "decidim.rest_full.models.api_client.permission", default: permission.to_s) %></span>
|
|
16
|
+
</label>
|
|
17
|
+
<% end %>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<% end %>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<% add_decidim_page_title(@api_client.name) %>
|
|
2
|
+
<% provide :title do %>
|
|
3
|
+
<%= link_to t(".go_back"), system_api_clients_path, class: "button button__sm button__text-primary" %>
|
|
4
|
+
<h1 class="h1"><%= @api_client.name %></h1>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<div class="w-full">
|
|
8
|
+
<div>
|
|
9
|
+
<nav class="flex space-x-4" aria-label="Tabs">
|
|
10
|
+
<button type="button" id="tab-info" class="js-tab-button px-4 py-2 text-sm font-medium rounded-lg bg-primary text-white border border-primary" data-tab="info" aria-current="page">
|
|
11
|
+
<%= t(".permissions", default: "Permissions") %>
|
|
12
|
+
</button>
|
|
13
|
+
<button type="button" id="tab-webhook" class="js-tab-button px-4 py-2 text-sm font-medium rounded-lg bg-white text-gray-700 border border-gray-300 hover:bg-gray-50" data-tab="webhook">
|
|
14
|
+
<%= t(".webhook", default: "Webhook") %>
|
|
15
|
+
</button>
|
|
16
|
+
</nav>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="mt-6">
|
|
19
|
+
<div id="tab-content-info" class="tab-content">
|
|
20
|
+
<%= render partial: "decidim/rest_full/system/api_clients/edit_info_tab" %>
|
|
21
|
+
</div>
|
|
22
|
+
<div id="tab-content-webhook" class="tab-content hidden">
|
|
23
|
+
<%= render partial: "decidim/rest_full/system/api_clients/edit_webhook_tab" %>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<script nonce="<%= content_security_policy_nonce %>">
|
|
29
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
30
|
+
const tabButtons = document.querySelectorAll('.js-tab-button');
|
|
31
|
+
const tabContents = document.querySelectorAll('.tab-content');
|
|
32
|
+
|
|
33
|
+
tabButtons.forEach(button => {
|
|
34
|
+
button.addEventListener('click', function() {
|
|
35
|
+
const targetTab = this.getAttribute('data-tab');
|
|
36
|
+
|
|
37
|
+
// Update button styles - inactive: outlined, active: filled
|
|
38
|
+
tabButtons.forEach(btn => {
|
|
39
|
+
btn.classList.remove('bg-primary', 'text-white', 'border-primary');
|
|
40
|
+
btn.classList.add('bg-white', 'text-gray-700', 'border-gray-300', 'hover:bg-gray-50');
|
|
41
|
+
});
|
|
42
|
+
this.classList.remove('bg-white', 'text-gray-700', 'border-gray-300', 'hover:bg-gray-50');
|
|
43
|
+
this.classList.add('bg-primary', 'text-white', 'border-primary');
|
|
44
|
+
|
|
45
|
+
// Show/hide content
|
|
46
|
+
tabContents.forEach(content => {
|
|
47
|
+
content.classList.add('hidden');
|
|
48
|
+
});
|
|
49
|
+
document.getElementById(`tab-content-${targetTab}`).classList.remove('hidden');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<% add_decidim_page_title(t(".title")) %>
|
|
2
|
+
|
|
3
|
+
<% provide :title do %>
|
|
4
|
+
<h1 class="h1"><%= t ".title" %></h1>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<%= link_to t("actions.new_api_client", scope: "decidim.rest_full.system.api_clients"), [:new, :system, :api_client], class: "button button__sm md:button__lg button__primary" %>
|
|
8
|
+
|
|
9
|
+
<table>
|
|
10
|
+
<thead>
|
|
11
|
+
<tr>
|
|
12
|
+
<th><%= t("created_at", scope: "decidim.rest_full.models.api_client.fields") %></th>
|
|
13
|
+
<th><%= t("name", scope: "decidim.rest_full.models.api_client.fields") %></th>
|
|
14
|
+
<th><%= t("client_id", scope: "decidim.rest_full.models.api_client.fields") %></th>
|
|
15
|
+
<th><%= t("actions.title", scope: "decidim.rest_full.system.api_clients") %></th>
|
|
16
|
+
</tr>
|
|
17
|
+
</thead>
|
|
18
|
+
<tbody>
|
|
19
|
+
<% @api_clients.each do |api_client| %>
|
|
20
|
+
<tr>
|
|
21
|
+
<td>
|
|
22
|
+
<%= l api_client.created_at, format: :short %>
|
|
23
|
+
</td>
|
|
24
|
+
<td>
|
|
25
|
+
<%= link_to api_client.name, system_api_client_path(api_client) %>
|
|
26
|
+
</td>
|
|
27
|
+
<td>
|
|
28
|
+
<%= link_to api_client.client_id, system_api_client_path(api_client) %>
|
|
29
|
+
</td>
|
|
30
|
+
<td class="flex gap-4 justify-end">
|
|
31
|
+
<%= link_to t("actions.edit", scope: "decidim.rest_full.system.api_clients"), edit_system_api_client_path(api_client), class: "button button__sm button__text-primary" %>
|
|
32
|
+
<%= link_to t("actions.destroy", scope: "decidim.rest_full.system.api_clients"), system_api_client_path(api_client), method: :delete, data: { confirm: t(".confirm_delete") }, class: "button button__sm button__text-primary" %>
|
|
33
|
+
</td>
|
|
34
|
+
</tr>
|
|
35
|
+
<% end %>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% add_decidim_page_title(t(".title")) %>
|
|
2
|
+
|
|
3
|
+
<% provide :title do %>
|
|
4
|
+
<h1 class="h1"><%= t ".title" %></h1>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<%= decidim_form_for(@form) do |f| %>
|
|
8
|
+
<%= render partial: "form", object: f, locals: { disabled: false } %>
|
|
9
|
+
|
|
10
|
+
<div class="form__wrapper-block">
|
|
11
|
+
<%= f.submit t(".save"), class: "button button__sm md:button__lg button__primary" %>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% add_decidim_page_title(@api_client.name) %>
|
|
2
|
+
|
|
3
|
+
<% provide :title do %>
|
|
4
|
+
<h1 class="h1"><%= @api_client.name %></h1>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<%= link_to t(".go_back"), system_api_clients_path, class: "button button__sm button__text-primary" %>
|
|
8
|
+
<%= decidim_form_for(@form) do |f| %>
|
|
9
|
+
<%= render partial: "form", object: f, locals: { disabled:true } %>
|
|
10
|
+
<% end %>
|