Skip to content

Fix notifications when there is a note proposal in other spaces than processes#8822

Merged
andreslucena merged 2 commits intodecidim:developfrom
belighted:fix-proposal_note_created_event
Feb 17, 2022
Merged

Fix notifications when there is a note proposal in other spaces than processes#8822
andreslucena merged 2 commits intodecidim:developfrom
belighted:fix-proposal_note_created_event

Conversation

@sergei-krylov
Copy link
Copy Markdown
Contributor

@sergei-krylov sergei-krylov commented Feb 15, 2022

🎩 What? Why?

Fixes exception on user notifications page. the issue is on generating of proposal_url for a notification when proposal related to anything else except the participatory process.

🐞 The bug

The notification was introduced here and the related tests passes because in tests proposal is by default created for participatory_process.

So it works well with processes, and decidim_admin_participatory_process_proposals engine can properly generate the url for the proposal added to the participatory_process.

The thing is that proposals can be added not only to the processes, but to a few other things, like assembly, initiative, consultation, etc:
https://github.com/decidim/decidim/search?q=%22include+Decidim%3A%3AParticipable%22
(check for include Decidim::Participable)

In those cases the engine would be a different one (accordingly to the component, decidim_admin_assembly_proposals for assemblies, for example). This results to the error when rendering the ProposalNoteCreatedEvent notification:

     ActionController::UrlGenerationError:
       No route matches {:component_id=>113}, missing required keys: [:participatory_process_slug]

Participatory processes engine can't generate urls for the assemblies, and vise versa.

🔧 The fix

The fix is to use the mounted engine that is different depending on the proposal component, it picked from the Participable concern:

def mounted_admin_engine
"decidim_admin_#{underscored_name.pluralize}"
end

Testing

  1. Create an assembly
  2. Add proposals component to the assembly
  3. Create proposal for that component
  4. Add a proposal note to trigger the event
  5. Check the notification page as any user who follows that assembly (as admin user should be enough, it follows by default)

@sergei-krylov sergei-krylov marked this pull request as ready for review February 15, 2022 12:59
@andreslucena
Copy link
Copy Markdown
Member

Hi @sergei-krylov
Welcome! A really great PR, with lots of details on what's happening, I like it 😍

Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

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

Just a small change about traits

@andreslucena andreslucena changed the title Fix: User notifications page crashes when there is a ProposalNoteCreatedEvent Fix notifications when there is a note proposal in other spaces than processes Feb 16, 2022
@andreslucena andreslucena merged commit 56505fb into decidim:develop Feb 17, 2022
@andreslucena
Copy link
Copy Markdown
Member

Congrats for your first merged PR @sergei-krylov
Can you please backport to v0.26-stable 🙏🏽? Thanks

entantoencuanto added a commit that referenced this pull request Feb 18, 2022
* develop: (134 commits)
  Remove Rectify::Presenter references (#8758)
  Clarify the locales on the list of admins (#8838)
  Fix activity cell disappearing author images (#8826)
  Fix notifications when there is a note proposal in other spaces than processes (#8822)
  Fix accountability text search (#8831)
  Fix displaying hidden meetings in show process page (#8823)
  Fix docs for install-decidim.sh permissions (#8839)
  Fix report moderation for all the spaces (#8813)
  Clarify the comment at the resource search class (#8829)
  Fix displaying hidden related resources (#8812)
  Replace Decidim mentions in UI with 'the platform' (#8827)
  Add natively a .keep file to empty directory to include on git committing (#8830)
  Fix scope validation on initiative's creation (#8755)
  Replace `searchlight` with `ransack` which is already a core dependency (#8748)
  Fix characters not encoded in highlighted participatory process group title (#8820)
  Test ensuring the moderated comments are not computed in stats (#8816)
  Update rails to 6.0.4.6 and puma to 5.6.2 (#8817)
  Fix displaying hidden meetings in processes group's "upcoming meetings" content block (#8818)
  Fix displaying hidden meetings in homepage's "upcoming meetings" content block (#8809)
  Improve "Release Candidates" release docs (#8804)
  ...
@andreslucena
Copy link
Copy Markdown
Member

Can you please backport to v0.26-stable 🙏🏽? Thanks

This is not necessary anymore, I've already done that in #8865, as we want to make the v0.26.0 release ASAP, and as this is a fix it'll enter there. Thanks again for your PR @sergei-krylov

@sergei-krylov
Copy link
Copy Markdown
Contributor Author

This is not necessary anymore, I've already done that in #8865, as we want to make the v0.26.0 release ASAP, and as this is a fix it'll enter there. Thanks again for your PR @sergei-krylov

Thank you!

@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants