Skip to content

Move announcement for spaces to Content Block#16067

Merged
alecslupu merged 7 commits intodevelopfrom
change/announcements-content-block
Feb 17, 2026
Merged

Move announcement for spaces to Content Block#16067
alecslupu merged 7 commits intodevelopfrom
change/announcements-content-block

Conversation

@andreslucena
Copy link
Copy Markdown
Member

@andreslucena andreslucena commented Feb 11, 2026

🎩 What? Why?

As explained at #16064, right now the set-up of the Announcement content block is a bit weird because historical reasons:

  1. You need to define the text at the Assembly or Process general form
  2. You need to enable the Content block in the Landing page layout

These two pages are separated and aren't intuitive.

This PR moves the editor to the content block editor.

📌 Related Issues

Testing

For existing content blocks

  1. Before the patch
  2. Sign in as admin
  3. Edit an assembly, add an announcement
  4. Go to the landing page editor, activate the "Announcement" content block
  5. Apply this patch
  6. Run the data migration
  7. Go to the Assembly form, see that you don't have the announcement there
  8. Go to the landing page editor, see that you have the text in the "Announcement" content block

📷 Screenshots

image image

♥️ Thank you!

Summary by CodeRabbit

  • New Features

    • Announcements are now managed via content blocks with a dedicated announcement settings form and editor.
  • Data Migration

    • New migration moves existing assembly and participatory process announcements into content blocks to preserve content.
  • User-facing Changes

    • Announcement inputs removed from assembly and participatory process admin forms and public exports; announcements are edited via content block workflows.
  • Tests

    • Added and updated tests covering migration and the new content-block announcement flows.

Copilot AI review requested due to automatic review settings February 11, 2026 07:43
@andreslucena andreslucena added the type: change PRs that implement a change for an existing feature label Feb 11, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Removes announcement fields from assemblies and participatory processes and moves announcement content into content blocks: deletes form fields, serializers, GraphQL fields and importer/duplication assignments; adds content-block settings, UI cell, migrations to migrate existing announcements; updates tests accordingly.

Changes

Cohort / File(s) Summary
Assemblies — Form & Commands
decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb, decidim-assemblies/app/commands/decidim/assemblies/admin/create_assembly.rb, decidim-assemblies/app/commands/decidim/assemblies/admin/update_assembly.rb, decidim-assemblies/app/views/decidim/assemblies/admin/assemblies/_form.html.erb
Removed announcement translatable attribute, removed :announcement from fetched/permitted form attributes, and removed announcement input from the admin form.
Assemblies — Import, Export & Duplication
decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb, decidim-assemblies/app/serializers/decidim/assemblies/open_data_assembly_serializer.rb, decidim-assemblies/app/commands/decidim/assemblies/admin/duplicate_assembly.rb
Stopped assigning/copying/serializing announcement (imports, open-data export, duplication).
Assemblies — Content Block & Migration
decidim-assemblies/lib/decidim/assemblies/content_blocks/registry_manager.rb, decidim-assemblies/db/data/20260210195653_move_announcement_to_content_block_on_assemblies.rb
Added announcement settings form cell and settings attribute for announcement block; added migration to move per-locale announcement keys into ContentBlock.settings.
Assemblies — Tests
decidim-assemblies/spec/..., decidim-assemblies/spec/shared/assembly_announcements_examples.rb
Removed direct announcement fixture usage; added content-block-based helpers (e.g., fill_announcement_editor), updated specs and added migration spec.
Participatory Processes — Form & Commands
decidim-participatory_processes/app/forms/.../participatory_process_form.rb, decidim-participatory_processes/app/commands/.../create_participatory_process.rb, decidim-participatory_processes/app/commands/.../update_participatory_process.rb, decidim-participatory_processes/app/views/.../_form.html.erb
Removed announcement translatable attribute, removed :announcement from fetch_form_attributes, and removed announcement input from admin form.
Participatory Processes — Import, Export & API
decidim-participatory_processes/app/serializers/.../participatory_process_importer.rb, decidim-participatory_processes/app/serializers/.../open_data_participatory_process_serializer.rb, decidim-participatory_processes/lib/decidim/api/participatory_process_type.rb
Stopped assigning/serializing announcement and removed GraphQL announcement field.
Participatory Processes — Content Block & Migration
decidim-participatory_processes/lib/decidim/participatory_processes/content_blocks/registry_manager.rb, decidim-participatory_processes/db/data/20260210195709_move_announcement_to_content_block_on_participatory_processes.rb
Added announcement settings form cell and settings attribute; added migration to move announcements into ContentBlock.settings.
Participatory Processes — Tests
decidim-participatory_processes/spec/..., decidim-participatory_processes/spec/shared/process_announcements_examples.rb
Removed direct announcement fields from specs, added content-block scaffolding/helpers (fill_announcement_editor, clear_announcement_editor), and added migration specs.
Core — Content Block UI & Cells
decidim-core/app/cells/decidim/content_blocks/announcement_settings_form_cell.rb, decidim-core/app/cells/decidim/content_blocks/announcement_settings_form/show.erb, decidim-core/app/cells/decidim/content_blocks/participatory_space_announcement_cell.rb, decidim-core/config/locales/en.yml
Added AnnouncementSettingsFormCell and view to render nested announcement settings, read announcement from content block settings in the announcement cell, and added i18n key.
Locales
decidim-assemblies/config/locales/en.yml, decidim-participatory_processes/config/locales/en.yml
Removed announcement-related help keys from assemblies and participatory_processes locales; added core content_blocks announcement body key.

Sequence Diagram(s)

sequenceDiagram
  participant Admin as Admin UI
  participant Cell as AnnouncementSettingsFormCell
  participant ContentBlock as Decidim::ContentBlock
  participant DB as Database / Migration
  participant API as Serializer / GraphQL

  Admin->>Cell: open/edit announcement settings form
  Cell->>ContentBlock: read/update settings[:announcement_<locale>]
  ContentBlock->>DB: save settings (persist per-locale announcement keys)
  DB->>ContentBlock: migration MoveAnnouncementToContentBlock... moves model.announcement -> settings keys
  ContentBlock->>API: serializers/GraphQL read announcement from settings (not model field)
  API-->>Admin: announcement displayed via content block in front-end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • alecslupu

Poem

🐰
I hopped from form to block with glee,
Took the announcement where it should be.
Now admins edit, position, and see—
One place for note, neat as can be. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: moving assembly/process announcements from a space form field to the content block system.
Linked Issues check ✅ Passed The PR successfully implements all three acceptance criteria from issue #16064: admins can edit announcements in content block settings via WYSIWYG editor, existing announcements are migrated to content blocks via data migration, and announcement fields are removed from space forms.
Out of Scope Changes check ✅ Passed All changes are directly related to moving announcements to content blocks. Files modified include space forms, commands, serializers, content block registry managers, migrations, and corresponding tests and views across both assemblies and participatory processes modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch change/announcements-content-block

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
decidim-assemblies/spec/shared/assembly_announcements_examples.rb (1)

16-26: Duplicated helper and potential slow has_css? check.

Two observations:

  1. This fill_announcement_editor method is identical to the one in decidim-participatory_processes/spec/shared/process_announcements_examples.rb. Consider extracting it into a shared support helper (e.g., a module in decidim-admin/spec/support/) to keep the two in sync.

  2. page.has_css?(...) waits up to the full Capybara default timeout before returning false. If the tabs element is frequently absent, this silently adds seconds to each test run. Passing wait: 0 (or a short timeout) avoids that:

♻️ Suggested tweak
-    if page.has_css?("#content_block-settings--announcement-tabs")
+    if page.has_css?("#content_block-settings--announcement-tabs", wait: 0)
decidim-participatory_processes/spec/shared/process_announcements_examples.rb (2)

16-38: has_css? branching will incur Capybara's default wait time on the negative path.

When the #content_block-settings--announcement-tabs element doesn't exist, page.has_css? will wait for the full Capybara.default_max_wait_time before returning false, slowing down each test that hits the else branch. Consider using has_css?(..., wait: 0) or has_css?(..., wait: 1) if you just need a quick presence check for branching.

♻️ Reduce wait time on the branching check
 def fill_announcement_editor(values)
-    if page.has_css?("#content_block-settings--announcement-tabs")
+    if page.has_css?("#content_block-settings--announcement-tabs", wait: 0)
       fill_in_i18n_editor(
 def clear_announcement_editor(locales)
-    if page.has_css?("#content_block-settings--announcement-tabs")
+    if page.has_css?("#content_block-settings--announcement-tabs", wait: 0)
       clear_i18n_editor(

67-87: Missing post-save assertion after click_on "Update".

The first test (Line 51) asserts have_content("Active content blocks") after saving, confirming the update succeeded. This test skips that check, so a silent save failure would go unnoticed and the subsequent frontend assertions could pass vacuously (e.g., no announcement displayed simply because it was never saved).

♻️ Add a post-save assertion for consistency
     click_on "Update"
+    expect(page).to have_content("Active content blocks")

     visit decidim_admin_participatory_processes.participatory_processes_path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

github-actions[bot]
github-actions bot previously approved these changes Feb 11, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@decidim-assemblies/spec/db/data/move_announcement_to_content_block_on_assemblies_spec.rb`:
- Around line 49-64: The example spec's description is misleading: the test for
content_block with manifest_name :announcement actually expects settings to be
updated while preserving the published state after calling
migrator.migrate(:up). Update the it description to accurately describe the
behavior (e.g., "preserves published state of an existing active block and
updates its settings" or "merges settings into an existing active block while
keeping it published") so it matches the assertions that content_block.reload
is_published and settings["announcement_en"] == "Important announcement"; leave
the test body, factory usage (create :content_block, organization, scope_name,
scoped_resource_id, published_at) and migrator.migrate(:up) unchanged.

In
`@decidim-participatory_processes/spec/db/data/move_announcement_to_content_block_on_participatory_processes_spec.rb`:
- Around line 49-64: The test description is misleading because the migration
does update the content_block's settings while preserving published_at; update
the example description to reflect actual behavior (e.g., rename the example
from "does not change an existing active block" to something like "preserves
published_at but updates settings on existing active block"), keeping the
assertions on content_block.reload, .be_published, settings["announcement_en"]
== "Important announcement" and published_at preservation intact; adjust only
the it string, not the assertions or migrator.migrate call.
🧹 Nitpick comments (2)
decidim-participatory_processes/spec/shared/process_announcements_examples.rb (1)

16-38: fill_announcement_editor is duplicated across assembly and process shared examples.

Both decidim-assemblies/spec/shared/assembly_announcements_examples.rb (line 16) and this file define an identical fill_announcement_editor method. Consider extracting it to a shared support helper to reduce duplication. This is a minor nit given it's test code.

decidim-participatory_processes/db/data/20260210195709_move_announcement_to_content_block_on_participatory_processes.rb (1)

4-10: Consider inheriting from ActiveRecord::Base instead of ApplicationRecord in migration-scoped models.

Inline models in data migrations should be as decoupled from the application as possible. If ApplicationRecord gains callbacks, validations, or other behavior in the future, it could interfere with migration execution. Using ActiveRecord::Base is the safer choice.

I note the assemblies migration uses the same pattern, so this is consistent — but both would benefit from the change.

Suggested fix
-  class ParticipatoryProcess < ApplicationRecord
+  class ParticipatoryProcess < ActiveRecord::Base
     self.table_name = "decidim_participatory_processes"
   end

-  class ContentBlock < ApplicationRecord
+  class ContentBlock < ActiveRecord::Base
     self.table_name = "decidim_content_blocks"
   end

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves participatory space “Announcement” content from the Assembly/Process general settings forms into the Landing Page “Announcement” content block settings, aligning where the text is authored with where the block is enabled/positioned.

Changes:

  • Adds an “Announcement” content block settings form (translated WYSIWYG) and switches the announcement rendering cell to read from content block settings.
  • Removes announcement from assemblies/processes admin forms, commands, serializers/importers, and GraphQL types, and updates affected specs.
  • Introduces data migrations + specs to copy existing announcement column content into the corresponding announcement content block settings.

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
decidim-participatory_processes/spec/types/participatory_process_type_spec.rb Removes GraphQL announcement field coverage for participatory processes.
decidim-participatory_processes/spec/types/integration_schema_spec.rb Updates integration schema expectations to exclude announcement.
decidim-participatory_processes/spec/system/admin/admin_manages_participatory_processes_spec.rb Removes announcement editor expectations from process admin form system spec.
decidim-participatory_processes/spec/shared/process_announcements_examples.rb Reworks shared examples to edit announcement via content block settings UI.
decidim-participatory_processes/spec/shared/manage_processes_examples.rb Stops filling announcement on the process admin form.
decidim-participatory_processes/spec/serializers/decidim/participatory_processes/participatory_process_serializer_spec.rb Drops announcement from serializer expectations.
decidim-participatory_processes/spec/serializers/decidim/participatory_processes/participatory_process_importer_spec.rb Drops announcement from importer expectations.
decidim-participatory_processes/spec/serializers/decidim/participatory_processes/open_data_participatory_process_serializer_spec.rb Drops announcement from open data serializer expectations.
decidim-participatory_processes/spec/db/data/move_announcement_to_content_block_on_participatory_processes_spec.rb Adds spec coverage for the participatory process data migration.
decidim-participatory_processes/spec/commands/create_participatory_process_spec.rb Removes announcement from create command params in specs.
decidim-participatory_processes/lib/decidim/participatory_processes/content_blocks/registry_manager.rb Defines translated WYSIWYG announcement setting and settings form cell for the block.
decidim-participatory_processes/lib/decidim/api/participatory_process_type.rb Removes announcement from the participatory process GraphQL type.
decidim-participatory_processes/db/data/20260210195709_move_announcement_to_content_block_on_participatory_processes.rb Data migration to copy announcement column content into content block settings.
decidim-participatory_processes/config/locales/en.yml Removes old admin form help/open-data help strings for announcement.
decidim-participatory_processes/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb Removes announcement editor from the participatory process admin form.
decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb Stops importing announcement into the model.
decidim-participatory_processes/app/serializers/decidim/participatory_processes/open_data_participatory_process_serializer.rb Stops exporting announcement in open data (and thus in derived serializer).
decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb Removes announcement translatable attribute from the form object.
decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb Stops updating announcement via the update command.
decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb Stops creating announcement via the create command.
decidim-core/config/locales/en.yml Adds a label for the announcement content block body field.
decidim-core/app/cells/decidim/content_blocks/participatory_space_announcement_cell.rb Switches announcement rendering to read from content block settings.
decidim-core/app/cells/decidim/content_blocks/announcement_settings_form_cell.rb Adds a settings form cell to label the announcement body field.
decidim-core/app/cells/decidim/content_blocks/announcement_settings_form/show.erb Adds translated WYSIWYG editor field for announcement settings.
decidim-assemblies/spec/types/assembly_type_spec.rb Removes GraphQL announcement field coverage for assemblies.
decidim-assemblies/spec/system/admin/admin_manages_assemblies_spec.rb Removes announcement editor expectations from assembly admin form system spec.
decidim-assemblies/spec/shared/manage_assemblies_examples.rb Stops filling announcement on the assembly admin form.
decidim-assemblies/spec/shared/assembly_announcements_examples.rb Reworks shared examples to edit announcement via content block settings UI.
decidim-assemblies/spec/serializers/decidim/assemblies/assembly_serializer_spec.rb Drops announcement from serializer expectations.
decidim-assemblies/spec/forms/assembly_form_spec.rb Removes announcement parameters/expectations from assembly form specs.
decidim-assemblies/spec/db/data/move_announcement_to_content_block_on_assemblies_spec.rb Adds spec coverage for the assembly data migration.
decidim-assemblies/spec/commands/update_assembly_spec.rb Removes announcement from update command params in specs.
decidim-assemblies/spec/commands/duplicate_assembly_spec.rb Drops announcement duplication expectation.
decidim-assemblies/spec/commands/create_assembly_spec.rb Removes announcement from create command params in specs.
decidim-assemblies/lib/decidim/assemblies/content_blocks/registry_manager.rb Defines translated WYSIWYG announcement setting and settings form cell for the block.
decidim-assemblies/lib/decidim/api/assembly_type.rb Removes announcement from the assembly GraphQL type.
decidim-assemblies/db/data/20260210195653_move_announcement_to_content_block_on_assemblies.rb Data migration to copy announcement column content into content block settings.
decidim-assemblies/config/locales/en.yml Removes old admin form help/open-data help strings for announcement.
decidim-assemblies/app/views/decidim/assemblies/admin/assemblies/_form.html.erb Removes announcement editor from the assembly admin form.
decidim-assemblies/app/serializers/decidim/assemblies/open_data_assembly_serializer.rb Stops exporting announcement in open data (and thus in derived serializer).
decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb Stops importing announcement into the model.
decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb Removes announcement translatable attribute from the form object.
decidim-assemblies/app/commands/decidim/assemblies/admin/update_assembly.rb Stops updating announcement via the update command.
decidim-assemblies/app/commands/decidim/assemblies/admin/duplicate_assembly.rb Stops duplicating announcement from the model.
decidim-assemblies/app/commands/decidim/assemblies/admin/create_assembly.rb Stops creating announcement via the create command.
Comments suppressed due to low confidence (1)

decidim-participatory_processes/lib/decidim/api/participatory_process_type.rb:22

  • Removing the announcement field from the GraphQL ParticipatoryProcessType is a breaking schema change, and there doesn’t appear to be an equivalent field that reads from the announcement content block settings. Consider keeping the field for backward compatibility (resolving via content blocks), or adding a replacement field and deprecating the old one first.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

github-actions[bot]
github-actions bot previously approved these changes Feb 11, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 11, 2026
@andreslucena
Copy link
Copy Markdown
Member Author

This is ready for the review

@alecslupu
Copy link
Copy Markdown
Contributor

I also see, that we no longer export announcement data.

@andreslucena
Copy link
Copy Markdown
Member Author

I also see, that we no longer export announcement data.

Yes, that's intended: as announcement no longer an attribute in the models directly, then it doesn't make sense to make the exception just for this case.

If we want to export these, then I'd prefer to go to a more general approach:

  • when exporting spaces, to have the content blocks in the JSON
  • when import spaces, to have a checkbox for "Import content blocks"
  • when in the GraphQL API, to have a ContentBlockType
  • when in the Open Data (CSVs), to have a file for content blocks
  • etc

cc @decidim/product

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Approving with all the items being clarified / extracted to tickets.

@alecslupu alecslupu merged commit da34641 into develop Feb 17, 2026
88 of 92 checks passed
@alecslupu alecslupu deleted the change/announcements-content-block branch February 17, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move the “Announcement” field of a space to its content block

4 participants