-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add label generation for the manifest * tweak exported * add weights to the exporter * fix tests * add graphql entry
- Loading branch information
1 parent
eeac7ac
commit 9af4f20
Showing
17 changed files
with
416 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module DecidimAwesome | ||
module ProposalSerializerOverride | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# Public: Exports a hash with the serialized data for this proposal. | ||
def serialize | ||
{ | ||
id: proposal.id, | ||
category: { | ||
id: proposal.category.try(:id), | ||
name: proposal.category.try(:name) || empty_translatable | ||
}, | ||
scope: { | ||
id: proposal.scope.try(:id), | ||
name: proposal.scope.try(:name) || empty_translatable | ||
}, | ||
participatory_space: { | ||
id: proposal.participatory_space.id, | ||
url: Decidim::ResourceLocatorPresenter.new(proposal.participatory_space).url | ||
}, | ||
component: { id: component.id }, | ||
title: proposal.title, | ||
body: convert_to_plain_text(proposal.body), | ||
address: proposal.address, | ||
latitude: proposal.latitude, | ||
longitude: proposal.longitude, | ||
state: proposal.state.to_s, | ||
reference: proposal.reference, | ||
answer: ensure_translatable(proposal.answer), | ||
supports: proposal.proposal_votes_count, | ||
weights: proposal_vote_weights, | ||
endorsements: { | ||
total_count: proposal.endorsements.size, | ||
user_endorsements: user_endorsements | ||
}, | ||
comments: proposal.comments_count, | ||
attachments: proposal.attachments.size, | ||
followers: proposal.follows.size, | ||
published_at: proposal.published_at, | ||
url: url, | ||
meeting_urls: meetings, | ||
related_proposals: related_proposals, | ||
is_amend: proposal.emendation?, | ||
original_proposal: { | ||
title: proposal&.amendable&.title, | ||
url: original_proposal_url | ||
} | ||
} | ||
end | ||
|
||
private | ||
|
||
def proposal_vote_weights | ||
proposal.update_vote_weights! | ||
proposal.vote_weights | ||
end | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
app/types/concerns/decidim/decidim_awesome/proposal_type_override.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module DecidimAwesome | ||
module ProposalTypeOverride | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
field :vote_weights, GraphQL::Types::JSON, description: "The corresponding weights count to the proposal votes", null: true | ||
|
||
def vote_weights | ||
current_component = object.component | ||
object.vote_weights unless current_component.current_settings.votes_hidden? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.