Move announcement for spaces to Content Block#16067
Conversation
...processes/spec/db/data/move_announcement_to_content_block_on_participatory_processes_spec.rb
Fixed
Show fixed
Hide fixed
📝 WalkthroughWalkthroughRemoves 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
There was a problem hiding this comment.
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_editoris duplicated across assembly and process shared examples.Both
decidim-assemblies/spec/shared/assembly_announcements_examples.rb(line 16) and this file define an identicalfill_announcement_editormethod. 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 fromActiveRecord::Baseinstead ofApplicationRecordin migration-scoped models.Inline models in data migrations should be as decoupled from the application as possible. If
ApplicationRecordgains callbacks, validations, or other behavior in the future, it could interfere with migration execution. UsingActiveRecord::Baseis 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
decidim-assemblies/spec/db/data/move_announcement_to_content_block_on_assemblies_spec.rb
Outdated
Show resolved
Hide resolved
...processes/spec/db/data/move_announcement_to_content_block_on_participatory_processes_spec.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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
announcementfrom assemblies/processes admin forms, commands, serializers/importers, and GraphQL types, and updates affected specs. - Introduces data migrations + specs to copy existing
announcementcolumn 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
announcementfield from the GraphQLParticipatoryProcessTypeis 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.
..._processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb
Show resolved
Hide resolved
...processes/spec/db/data/move_announcement_to_content_block_on_participatory_processes_spec.rb
Outdated
Show resolved
Hide resolved
decidim-assemblies/app/serializers/decidim/assemblies/open_data_assembly_serializer.rb
Show resolved
Hide resolved
decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb
Show resolved
Hide resolved
decidim-core/app/cells/decidim/content_blocks/announcement_settings_form_cell.rb
Show resolved
Hide resolved
...pp/serializers/decidim/participatory_processes/open_data_participatory_process_serializer.rb
Show resolved
Hide resolved
74de63b
|
This is ready for the review |
decidim-core/app/cells/decidim/content_blocks/participatory_space_announcement_cell.rb
Show resolved
Hide resolved
|
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:
cc @decidim/product |
alecslupu
left a comment
There was a problem hiding this comment.
👍 Approving with all the items being clarified / extracted to tickets.
🎩 What? Why?
As explained at #16064, right now the set-up of the Announcement content block is a bit weird because historical reasons:
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
📷 Screenshots
Summary by CodeRabbit
New Features
Data Migration
User-facing Changes
Tests