generated from OpenSourcePolitics/decidim-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Addition of private proposal fields (#43)
* feat: Addition of Private Proposal Fields * fix: Extend the serializer to fix the export * merge: Add conflicted files * fix: Fix the locks
- Loading branch information
Showing
11 changed files
with
4,465 additions
and
3,093 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require "extends/serializers/decidim/decidim_awesome/private_proposal_serializer_extends" |
14 changes: 14 additions & 0 deletions
14
db/migrate/20240715133031_create_private_proposal_fields.decidim_decidim_awesome.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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from decidim_decidim_awesome (originally 20230309124413) | ||
|
||
class CreatePrivateProposalFields < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :decidim_awesome_private_proposal_fields do |t| | ||
t.text :private_body, default: "<xml></xml>" | ||
|
||
t.references :proposal, null: false, foreign_key: { to_table: :decidim_proposals_proposals }, index: { name: "decidim_awesome_private_proposal_fields_idx" } | ||
t.timestamps | ||
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
19 changes: 19 additions & 0 deletions
19
lib/extends/serializers/decidim/decidim_awesome/private_proposal_serializer_extends.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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module PrivateProposalSerializerExtends | ||
def serialize_private_custom_fields(payload) | ||
private_custom_fields = Decidim::DecidimAwesome::CustomFields.new(awesome_private_proposal_custom_fields) | ||
return payload if private_custom_fields.blank? | ||
|
||
private_body = proposal.awesome_private_proposal_field.present? ? proposal.awesome_private_proposal_field.private_body : "" | ||
fields_entries(private_custom_fields, private_body) do |key, value| | ||
payload["secret/#{key}".to_sym] = value | ||
end | ||
|
||
payload | ||
end | ||
end | ||
|
||
Decidim::DecidimAwesome::PrivateProposalSerializer.class_eval do | ||
prepend(PrivateProposalSerializerExtends) | ||
end |
Oops, something went wrong.