Merge pull request #3564 from consul/default_settings
Simplify settings seeds
This commit is contained in:
@@ -40,5 +40,90 @@ class Setting < ApplicationRecord
|
||||
setting = where(key: key).first
|
||||
setting.destroy if setting.present?
|
||||
end
|
||||
|
||||
def defaults
|
||||
{
|
||||
"feature.featured_proposals": nil,
|
||||
"feature.facebook_login": true,
|
||||
"feature.google_login": true,
|
||||
"feature.twitter_login": true,
|
||||
"feature.public_stats": true,
|
||||
"feature.signature_sheets": true,
|
||||
"feature.user.recommendations": true,
|
||||
"feature.user.recommendations_on_debates": true,
|
||||
"feature.user.recommendations_on_proposals": true,
|
||||
"feature.user.skip_verification": "true",
|
||||
"feature.community": true,
|
||||
"feature.map": nil,
|
||||
"feature.allow_attached_documents": true,
|
||||
"feature.allow_images": true,
|
||||
"feature.help_page": true,
|
||||
"homepage.widgets.feeds.debates": true,
|
||||
"homepage.widgets.feeds.processes": true,
|
||||
"homepage.widgets.feeds.proposals": true,
|
||||
# Code to be included at the top (inside <body>) of every page
|
||||
"html.per_page_code_body": "",
|
||||
# Code to be included at the top (inside <head>) of every page (useful for tracking)
|
||||
"html.per_page_code_head": "",
|
||||
"map.latitude": 51.48,
|
||||
"map.longitude": 0.0,
|
||||
"map.zoom": 10,
|
||||
"process.debates": true,
|
||||
"process.proposals": true,
|
||||
"process.polls": true,
|
||||
"process.budgets": true,
|
||||
"process.legislation": true,
|
||||
"proposals.successful_proposal_id": nil,
|
||||
"proposals.poll_short_title": nil,
|
||||
"proposals.poll_description": nil,
|
||||
"proposals.poll_link": nil,
|
||||
"proposals.email_short_title": nil,
|
||||
"proposals.email_description": nil,
|
||||
"proposals.poster_short_title": nil,
|
||||
"proposals.poster_description": nil,
|
||||
# Names for the moderation console, as a hint for moderators
|
||||
# to know better how to assign users with official positions
|
||||
"official_level_1_name": I18n.t("seeds.settings.official_level_1_name"),
|
||||
"official_level_2_name": I18n.t("seeds.settings.official_level_2_name"),
|
||||
"official_level_3_name": I18n.t("seeds.settings.official_level_3_name"),
|
||||
"official_level_4_name": I18n.t("seeds.settings.official_level_4_name"),
|
||||
"official_level_5_name": I18n.t("seeds.settings.official_level_5_name"),
|
||||
"max_ratio_anon_votes_on_debates": 50,
|
||||
"max_votes_for_debate_edit": 1000,
|
||||
"max_votes_for_proposal_edit": 1000,
|
||||
"comments_body_max_length": 1000,
|
||||
"proposal_code_prefix": "CONSUL",
|
||||
"votes_for_proposal_success": 10000,
|
||||
"months_to_archive_proposals": 12,
|
||||
# Users with this email domain will automatically be marked as level 1 officials
|
||||
# Emails under the domain's subdomains will also be included
|
||||
"email_domain_for_officials": "",
|
||||
"facebook_handle": nil,
|
||||
"instagram_handle": nil,
|
||||
"telegram_handle": nil,
|
||||
"twitter_handle": nil,
|
||||
"twitter_hashtag": nil,
|
||||
"youtube_handle": nil,
|
||||
"url": "http://example.com", # Public-facing URL of the app.
|
||||
# CONSUL installation's organization name
|
||||
"org_name": "CONSUL",
|
||||
"meta_title": nil,
|
||||
"meta_description": nil,
|
||||
"meta_keywords": nil,
|
||||
"proposal_notification_minimum_interval_in_days": 3,
|
||||
"direct_message_max_per_day": 3,
|
||||
"mailer_from_name": "CONSUL",
|
||||
"mailer_from_address": "noreply@consul.dev",
|
||||
"min_age_to_participate": 16,
|
||||
"hot_score_period_in_days": 31,
|
||||
"related_content_score_threshold": -0.3,
|
||||
"featured_proposals_number": 3,
|
||||
"dashboard.emails": nil
|
||||
}
|
||||
end
|
||||
|
||||
def reset_defaults
|
||||
defaults.each { |name, value| self[name] = value }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -118,6 +118,7 @@ ignore_missing:
|
||||
- "devise.failure.invalid"
|
||||
- "devise.registrations.destroyed"
|
||||
- "devise.password_expired.*"
|
||||
- "seeds.settings.*"
|
||||
|
||||
## Consider these keys used:
|
||||
ignore_unused:
|
||||
@@ -206,7 +207,7 @@ ignore_unused:
|
||||
- admin.stats.polls.expired
|
||||
- "stats.polls.*_percentage"
|
||||
- landings.cambia_tu_ciudad.*
|
||||
- 'seeds.settings.*'
|
||||
- "seeds.settings.*"
|
||||
- "dashboard.polls.*.submit"
|
||||
####
|
||||
## Exclude these keys from the `i18n-tasks eq-base" report:
|
||||
|
||||
@@ -1,86 +1,27 @@
|
||||
section "Creating Settings" do
|
||||
Setting.create(key: "official_level_1_name",
|
||||
value: I18n.t("seeds.settings.official_level_1_name"))
|
||||
Setting.create(key: "official_level_2_name",
|
||||
value: I18n.t("seeds.settings.official_level_2_name"))
|
||||
Setting.create(key: "official_level_3_name",
|
||||
value: I18n.t("seeds.settings.official_level_3_name"))
|
||||
Setting.create(key: "official_level_4_name",
|
||||
value: I18n.t("seeds.settings.official_level_4_name"))
|
||||
Setting.create(key: "official_level_5_name",
|
||||
value: I18n.t("seeds.settings.official_level_5_name"))
|
||||
Setting.create(key: "max_ratio_anon_votes_on_debates", value: "50")
|
||||
Setting.create(key: "max_votes_for_debate_edit", value: "1000")
|
||||
Setting.create(key: "max_votes_for_proposal_edit", value: "1000")
|
||||
Setting.create(key: "proposal_code_prefix", value: "MAD")
|
||||
Setting.create(key: "votes_for_proposal_success", value: "100")
|
||||
Setting.create(key: "months_to_archive_proposals", value: "12")
|
||||
Setting.create(key: "comments_body_max_length", value: "1000")
|
||||
Setting.reset_defaults
|
||||
|
||||
Setting.create(key: "twitter_handle", value: "@consul_dev")
|
||||
Setting.create(key: "twitter_hashtag", value: "#consul_dev")
|
||||
Setting.create(key: "facebook_handle", value: "CONSUL")
|
||||
Setting.create(key: "youtube_handle", value: "CONSUL")
|
||||
Setting.create(key: "telegram_handle", value: "CONSUL")
|
||||
Setting.create(key: "instagram_handle", value: "CONSUL")
|
||||
Setting.create(key: "url", value: "http://localhost:3000")
|
||||
Setting.create(key: "org_name", value: "CONSUL")
|
||||
|
||||
Setting.create(key: "process.debates", value: "true")
|
||||
Setting.create(key: "process.proposals", value: "true")
|
||||
Setting.create(key: "process.polls", value: "true")
|
||||
Setting.create(key: "process.budgets", value: "true")
|
||||
Setting.create(key: "process.legislation", value: "true")
|
||||
|
||||
Setting.create(key: "feature.featured_proposals", value: "true")
|
||||
|
||||
Setting.create(key: "feature.twitter_login", value: "true")
|
||||
Setting.create(key: "feature.facebook_login", value: "true")
|
||||
Setting.create(key: "feature.google_login", value: "true")
|
||||
Setting.create(key: "feature.signature_sheets", value: "true")
|
||||
Setting.create(key: "feature.user.recommendations", value: "true")
|
||||
Setting.create(key: "feature.user.recommendations_on_debates", value: "true")
|
||||
Setting.create(key: "feature.user.recommendations_on_proposals", value: "true")
|
||||
Setting.create(key: "feature.user.skip_verification", value: "true")
|
||||
Setting.create(key: "feature.community", value: "true")
|
||||
Setting.create(key: "feature.map", value: "true")
|
||||
Setting.create(key: "feature.allow_images", value: "true")
|
||||
Setting.create(key: "feature.allow_attached_documents", value: "true")
|
||||
Setting.create(key: "feature.public_stats", value: "true")
|
||||
Setting.create(key: "feature.help_page", value: "true")
|
||||
|
||||
Setting.create(key: "html.per_page_code_head", value: "")
|
||||
Setting.create(key: "html.per_page_code_body", value: "")
|
||||
|
||||
Setting.create(key: "comments_body_max_length", value: "1000")
|
||||
Setting.create(key: "mailer_from_name", value: "CONSUL")
|
||||
Setting.create(key: "mailer_from_address", value: "noreply@consul.dev")
|
||||
Setting.create(key: "meta_title", value: "CONSUL")
|
||||
Setting.create(key: "meta_description", value: "Citizen participation tool for an open, "\
|
||||
"transparent and democratic government")
|
||||
Setting.create(key: "meta_keywords", value: "citizen participation, open government")
|
||||
Setting.create(key: "min_age_to_participate", value: "16")
|
||||
Setting.create(key: "map.latitude", value: 40.4332002)
|
||||
Setting.create(key: "map.longitude", value: -3.7009591)
|
||||
Setting.create(key: "map.zoom", value: 10)
|
||||
|
||||
Setting.create(key: "featured_proposals_number", value: 3)
|
||||
Setting.create(key: "proposal_notification_minimum_interval_in_days", value: 0)
|
||||
Setting.create(key: "direct_message_max_per_day", value: 3)
|
||||
|
||||
Setting.create(key: "related_content_score_threshold", value: -0.3)
|
||||
Setting.create(key: "hot_score_period_in_days", value: 31)
|
||||
|
||||
Setting.create(key: "homepage.widgets.feeds.proposals", value: "true")
|
||||
Setting.create(key: "homepage.widgets.feeds.debates", value: "true")
|
||||
Setting.create(key: "homepage.widgets.feeds.processes", value: "true")
|
||||
|
||||
Setting.create(key: "proposals.successful_proposal_id", value: nil)
|
||||
Setting.create(key: "proposals.poll_short_title", value: nil)
|
||||
Setting.create(key: "proposals.poll_description", value: nil)
|
||||
Setting.create(key: "proposals.poll_link", value: nil)
|
||||
Setting.create(key: "proposals.email_short_title", value: nil)
|
||||
Setting.create(key: "proposals.email_description", value: nil)
|
||||
|
||||
Setting.create(key: "dashboard.emails", value: nil)
|
||||
{
|
||||
"facebook_handle": "CONSUL",
|
||||
"feature.featured_proposals": "true",
|
||||
"feature.map": "true",
|
||||
"instagram_handle": "CONSUL",
|
||||
"mailer_from_address": "noreply@consul.dev",
|
||||
"mailer_from_name": "CONSUL",
|
||||
"meta_description": "Citizen participation tool for an open, "\
|
||||
"transparent and democratic government",
|
||||
"meta_keywords": "citizen participation, open government",
|
||||
"meta_title": "CONSUL",
|
||||
"org_name": "CONSUL",
|
||||
"proposal_code_prefix": "MAD",
|
||||
"proposal_notification_minimum_interval_in_days": 0,
|
||||
"telegram_handle": "CONSUL",
|
||||
"twitter_handle": "@consul_dev",
|
||||
"twitter_hashtag": "#consul_dev",
|
||||
"url": "http://localhost:3000",
|
||||
"votes_for_proposal_success": "100",
|
||||
"youtube_handle": "CONSUL"
|
||||
}.each do |name, value|
|
||||
Setting[name] = value
|
||||
end
|
||||
end
|
||||
|
||||
125
db/seeds.rb
125
db/seeds.rb
@@ -7,117 +7,7 @@ if Administrator.count == 0 && !Rails.env.test?
|
||||
admin.create_administrator
|
||||
end
|
||||
|
||||
# Names for the moderation console, as a hint for moderators
|
||||
# to know better how to assign users with official positions
|
||||
Setting["official_level_1_name"] = "Cargo oficial 1"
|
||||
Setting["official_level_2_name"] = "Cargo oficial 2"
|
||||
Setting["official_level_3_name"] = "Cargo oficial 3"
|
||||
Setting["official_level_4_name"] = "Cargo oficial 4"
|
||||
Setting["official_level_5_name"] = "Cargo oficial 5"
|
||||
|
||||
# Max percentage of allowed anonymous votes on a debate
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 50
|
||||
|
||||
# Max votes where a debate is still editable
|
||||
Setting["max_votes_for_debate_edit"] = 1000
|
||||
|
||||
# Max votes where a proposal is still editable
|
||||
Setting["max_votes_for_proposal_edit"] = 1000
|
||||
|
||||
# Max length for comments
|
||||
Setting["comments_body_max_length"] = 1000
|
||||
|
||||
# Prefix for the Proposal codes
|
||||
Setting["proposal_code_prefix"] = "CONSUL"
|
||||
|
||||
# Number of votes needed for proposal success
|
||||
Setting["votes_for_proposal_success"] = 53726
|
||||
|
||||
# Months to archive proposals
|
||||
Setting["months_to_archive_proposals"] = 12
|
||||
|
||||
# Users with this email domain will automatically be marked as level 1 officials
|
||||
# Emails under the domain's subdomains will also be included
|
||||
Setting["email_domain_for_officials"] = ""
|
||||
|
||||
# Code to be included at the top (inside <head>) of every page (useful for tracking)
|
||||
Setting["html.per_page_code_head"] = ""
|
||||
|
||||
# Code to be included at the top (inside <body>) of every page
|
||||
Setting["html.per_page_code_body"] = ""
|
||||
|
||||
# Social settings
|
||||
Setting["twitter_handle"] = nil
|
||||
Setting["twitter_hashtag"] = nil
|
||||
Setting["facebook_handle"] = nil
|
||||
Setting["youtube_handle"] = nil
|
||||
Setting["telegram_handle"] = nil
|
||||
Setting["instagram_handle"] = nil
|
||||
|
||||
# Public-facing URL of the app.
|
||||
Setting["url"] = "http://example.com"
|
||||
|
||||
# CONSUL installation's organization name
|
||||
Setting["org_name"] = "CONSUL"
|
||||
|
||||
# Meta tags for SEO
|
||||
Setting["meta_title"] = nil
|
||||
Setting["meta_description"] = nil
|
||||
Setting["meta_keywords"] = nil
|
||||
|
||||
# Processes
|
||||
Setting["process.debates"] = true
|
||||
Setting["process.proposals"] = true
|
||||
Setting["process.polls"] = true
|
||||
Setting["process.budgets"] = true
|
||||
Setting["process.legislation"] = true
|
||||
|
||||
# Feature flags
|
||||
Setting["feature.featured_proposals"] = nil
|
||||
Setting["feature.twitter_login"] = true
|
||||
Setting["feature.facebook_login"] = true
|
||||
Setting["feature.google_login"] = true
|
||||
Setting["feature.public_stats"] = true
|
||||
Setting["feature.signature_sheets"] = true
|
||||
Setting["feature.user.recommendations"] = true
|
||||
Setting["feature.user.recommendations_on_debates"] = true
|
||||
Setting["feature.user.recommendations_on_proposals"] = true
|
||||
Setting["feature.user.skip_verification"] = "true"
|
||||
Setting["feature.community"] = true
|
||||
Setting["feature.map"] = nil
|
||||
Setting["feature.allow_images"] = true
|
||||
Setting["feature.allow_attached_documents"] = true
|
||||
Setting["feature.help_page"] = true
|
||||
|
||||
# Proposal notifications
|
||||
Setting["proposal_notification_minimum_interval_in_days"] = 3
|
||||
Setting["direct_message_max_per_day"] = 3
|
||||
|
||||
# Email settings
|
||||
Setting["mailer_from_name"] = "CONSUL"
|
||||
Setting["mailer_from_address"] = "noreply@consul.dev"
|
||||
|
||||
# Verification settings
|
||||
Setting["min_age_to_participate"] = 16
|
||||
|
||||
# Featured proposals
|
||||
Setting["featured_proposals_number"] = 3
|
||||
|
||||
# City map feature default configuration (Greenwich)
|
||||
Setting["map.latitude"] = 51.48
|
||||
Setting["map.longitude"] = 0.0
|
||||
Setting["map.zoom"] = 10
|
||||
|
||||
# Related content
|
||||
Setting["related_content_score_threshold"] = -0.3
|
||||
|
||||
# Homepage
|
||||
Setting["homepage.widgets.feeds.proposals"] = true
|
||||
Setting["homepage.widgets.feeds.debates"] = true
|
||||
Setting["homepage.widgets.feeds.processes"] = true
|
||||
|
||||
# Votes hot_score configuration
|
||||
Setting["hot_score_period_in_days"] = 31
|
||||
Setting.reset_defaults
|
||||
|
||||
WebSection.create(name: "homepage")
|
||||
WebSection.create(name: "debates")
|
||||
@@ -125,18 +15,5 @@ WebSection.create(name: "proposals")
|
||||
WebSection.create(name: "budgets")
|
||||
WebSection.create(name: "help_page")
|
||||
|
||||
# Proposals
|
||||
Setting["proposals.successful_proposal_id"] = nil
|
||||
Setting["proposals.poll_short_title"] = nil
|
||||
Setting["proposals.poll_description"] = nil
|
||||
Setting["proposals.poll_link"] = nil
|
||||
Setting["proposals.email_short_title"] = nil
|
||||
Setting["proposals.email_description"] = nil
|
||||
Setting["proposals.poster_short_title"] = nil
|
||||
Setting["proposals.poster_description"] = nil
|
||||
|
||||
# Dashboard
|
||||
Setting["dashboard.emails"] = nil
|
||||
|
||||
# Default custom pages
|
||||
load Rails.root.join("db", "pages.rb")
|
||||
|
||||
Reference in New Issue
Block a user