lib/decidim/proposals.rb in decidim-proposals-0.28.4 vs lib/decidim/proposals.rb in decidim-proposals-0.29.0.rc1
- old
+ new
@@ -20,31 +20,103 @@
autoload :OdtToMarkdown, "decidim/proposals/odt_to_markdown"
autoload :Valuatable, "decidim/proposals/valuatable"
include ActiveSupport::Configurable
- # Public Setting that defines the similarity minimum value to consider two
- # proposals similar. Defaults to 0.25.
- config_accessor :similarity_threshold do
- 0.25
- end
-
- # Public Setting that defines how many similar proposals will be shown.
- # Defaults to 10.
- config_accessor :similarity_limit do
- 10
- end
-
# Public Setting that defines how many proposals will be shown in the
# participatory_space_highlighted_elements view hook
config_accessor :participatory_space_highlighted_proposals_limit do
4
end
# Public Setting that defines how many proposals will be shown in the
# process_group_highlighted_elements view hook
config_accessor :process_group_highlighted_proposals_limit do
3
+ end
+
+ def self.proposal_states_colors
+ {
+ gray: {
+ background: "#F6F8FA",
+ foreground: "#4B5058",
+ name: I18n.t("gray", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ blue: {
+ background: "#EBF9FF",
+ foreground: "#0851A6",
+ name: I18n.t("blue", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ green: {
+ background: "#E3FCE9",
+ foreground: "#15602C",
+ name: I18n.t("green", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ yellow: {
+ background: "#FFFCE5",
+ foreground: "#9A6700",
+ name: I18n.t("yellow", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ orange: {
+ background: "#FFF1E5",
+ foreground: "#BC4C00",
+ name: I18n.t("orange", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ red: {
+ background: "#FFEBE9",
+ foreground: "#D1242F",
+ name: I18n.t("red", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ pink: {
+ background: "#FFEFF7",
+ foreground: "#BF3989",
+ name: I18n.t("pink", scope: "activemodel.attributes.proposal_state.colors")
+ },
+ purple: {
+ background: "#FBEFFF",
+ foreground: "#8250DF",
+ name: I18n.t("purple", scope: "activemodel.attributes.proposal_state.colors")
+ }
+ }
+ end
+
+ def self.create_default_states!(component, admin_user, with_traceability: true)
+ colors = Decidim::Proposals.proposal_states_colors
+
+ locale = Decidim.default_locale
+ default_states = {
+ evaluating: {
+ token: :evaluating,
+ bg_color: colors[:orange][:background],
+ text_color: colors[:orange][:foreground],
+ announcement_title: { locale => I18n.with_locale(locale) { I18n.t("proposal_in_evaluation_reason", scope: "decidim.proposals.proposals.show") } },
+ title: { locale => I18n.with_locale(locale) { I18n.t(:evaluating, scope: "decidim.proposals.answers") } }
+ },
+ accepted: {
+ token: :accepted,
+ bg_color: colors[:green][:background],
+ text_color: colors[:green][:foreground],
+ announcement_title: { locale => I18n.with_locale(locale) { I18n.t("proposal_accepted_reason", scope: "decidim.proposals.proposals.show") } },
+ title: { locale => I18n.with_locale(locale) { I18n.t(:accepted, scope: "decidim.proposals.answers") } }
+ },
+ rejected: {
+ token: :rejected,
+ bg_color: colors[:red][:background],
+ text_color: colors[:red][:foreground],
+ announcement_title: { locale => I18n.with_locale(locale) { I18n.t("proposal_rejected_reason", scope: "decidim.proposals.proposals.show") } },
+ title: { locale => I18n.with_locale(locale) { I18n.t(:rejected, scope: "decidim.proposals.answers") } }
+ }
+ }
+ default_states.each_key do |key|
+ default_states[key][:object] = if with_traceability
+ Decidim.traceability.create(
+ Decidim::Proposals::ProposalState, admin_user, component:, **default_states[key]
+ )
+ else
+ Decidim::Proposals::ProposalState.create(component:, **default_states[key])
+ end
+ end
+ default_states
end
end
module ContentParsers
autoload :ProposalParser, "decidim/content_parsers/proposal_parser"