From f1908f0b86e340cf7b97c638522364bdecca1519 Mon Sep 17 00:00:00 2001 From: Hadrien Froger Date: Sat, 14 Dec 2024 11:27:02 +0000 Subject: [PATCH] :bug: (component) Fix: authorship joining on proposals --- .../decidim/api/rest_full/blog_component_serializer.rb | 2 +- .../decidim/api/rest_full/proposal_component_serializer.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/serializers/decidim/api/rest_full/blog_component_serializer.rb b/app/serializers/decidim/api/rest_full/blog_component_serializer.rb index 97925e5..bd95e93 100644 --- a/app/serializers/decidim/api/rest_full/blog_component_serializer.rb +++ b/app/serializers/decidim/api/rest_full/blog_component_serializer.rb @@ -9,7 +9,7 @@ def self.resources_for(component, act_as) if act_as.nil? resources.published else - resources.published.or(resources.where(published_at: nil, decidim_user_id: act_as.id)) + resources.published.or(resources.where(published_at: nil, decidim_author_id: act_as.id)) end end has_many :resources, meta: (proc do |component, params| diff --git a/app/serializers/decidim/api/rest_full/proposal_component_serializer.rb b/app/serializers/decidim/api/rest_full/proposal_component_serializer.rb index 537884d..94b0a9d 100644 --- a/app/serializers/decidim/api/rest_full/proposal_component_serializer.rb +++ b/app/serializers/decidim/api/rest_full/proposal_component_serializer.rb @@ -9,7 +9,12 @@ def self.resources_for(component, act_as) if act_as.nil? resources.published else - resources.published.or(resources.where(published_at: nil, decidim_user_id: act_as.id)) + resources.published.or( + resources.joins(:coauthorships).where( + published_at: nil, + coauthorships: { decidim_author_id: act_as.id } + ) + ) end end