Skip to content

Commit

Permalink
Fix proposal export error with deleted users
Browse files Browse the repository at this point in the history
  • Loading branch information
fblupi committed Dec 11, 2024
1 parent 38d09ea commit 8e37f3d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/lib/decidim/overrides/proposals/proposal_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

module Decidim
module Overrides
module Proposals
module ProposalSerializer
private

def author_url(author)
if author.respond_to?(:nickname)
profile_url(author) # is a Decidim::User or Decidim::UserGroup
elsif author.respond_to?(:title)
meeting_url(author) # is a Decidim::Meetings::Meeting
else
root_url # is a Decidim::Organization
end
end

def profile_url(author)
return "" if author.respond_to?(:deleted?) && author.deleted?

Decidim::Core::Engine.routes.url_helpers.profile_url(author.nickname, host:)
end
end
end
end
end
1 change: 1 addition & 0 deletions config/initializers/decidim_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Decidim::SearchResourceFieldsMapper.prepend(Decidim::Overrides::SearchResourceFieldsMapper)
Decidim::Initiatives::InitiativeMetadataGCell.include(Decidim::Initiatives::InitiativeMetadataGCellOverride)
Decidim::Forms::UserAnswersSerializer.prepend(Decidim::Overrides::Forms::UserAnswersSerializer)
Decidim::Proposals::ProposalSerializer.prepend(Decidim::Overrides::Proposals::ProposalSerializer)
Decidim::Initiative.include(Decidim::InitiativeOverride)
Decidim::Accountability::Result.include(Decidim::Accountability::ResultOverride)
Decidim::Accountability::ResultsCalculator.include(Decidim::Accountability::ResultsCalculatorOverride)
Expand Down
1 change: 1 addition & 0 deletions spec/lib/overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
{
package: "decidim-proposals",
files: {
"/lib/decidim/proposals/proposal_serializer.rb" => "ea339213f4f296aaafa3708dcd5c37c4", # remove once the solution of this PR is present https://github.com/decidim/decidim/pull/13592
"/app/helpers/decidim/proposals/application_helper.rb" => "c17dd875a166cd0cd3c09b0e596ebef5",
"/app/presenters/decidim/proposals/proposal_presenter.rb" => "bbc7cee02125c1f8cf909219e48af337"
}
Expand Down

0 comments on commit 8e37f3d

Please sign in to comment.