Merge pull request #3370 from consul/double_quoutes_everywhere

Change single quotes to double quotes everywhere
This commit is contained in:
Julian Nicolas Herrero
2019-03-19 12:20:16 +01:00
committed by GitHub
96 changed files with 528 additions and 529 deletions

View File

@@ -4,12 +4,12 @@ AllCops:
DisplayCopNames: true DisplayCopNames: true
DisplayStyleGuide: true DisplayStyleGuide: true
Include: Include:
- '**/Rakefile' - "**/Rakefile"
- '**/config.ru' - "**/config.ru"
Exclude: Exclude:
- 'db/**/*' - "db/**/*"
- 'config/**/*' - "config/**/*"
- 'script/**/*' - "script/**/*"
TargetRubyVersion: 2.3 TargetRubyVersion: 2.3
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled. # to ignore them, so only the ones explicitly set in this file are enabled.

View File

@@ -1,6 +1,6 @@
language: ruby language: ruby
addons: addons:
postgresql: '9.4' postgresql: "9.4"
chrome: stable chrome: stable
rvm: rvm:
- 2.3.2 - 2.3.2

22
Capfile
View File

@@ -1,22 +1,22 @@
# Load DSL and set up stages # Load DSL and set up stages
require 'capistrano/setup' require "capistrano/setup"
# Include default deployment tasks # Include default deployment tasks
require 'capistrano/deploy' require "capistrano/deploy"
require "capistrano/bundler" require "capistrano/bundler"
require 'capistrano/rails/assets' require "capistrano/rails/assets"
require 'capistrano/rails/migrations' require "capistrano/rails/migrations"
#require 'capistrano/passenger' #require "capistrano/passenger"
require 'capistrano/delayed_job' require "capistrano/delayed_job"
require 'whenever/capistrano' require "whenever/capistrano"
require 'rvm1/capistrano3' require "rvm1/capistrano3"
#SCM: Git #SCM: Git
require "capistrano/scm/git" require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git install_plugin Capistrano::SCM::Git
# Load custom tasks from `lib/capistrano/tasks` if you have any defined # Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } Dir.glob("lib/capistrano/tasks/*.cap").each { |r| import r }
Dir.glob('lib/capistrano/**/*.rb').each { |r| import r } Dir.glob("lib/capistrano/**/*.rb").each { |r| import r }

172
Gemfile
View File

@@ -1,100 +1,100 @@
source 'https://rubygems.org' source "https://rubygems.org"
gem 'rails', '4.2.11.1' gem "rails", "4.2.11.1"
gem 'acts-as-taggable-on', '~> 5.0.0' gem "acts-as-taggable-on", "~> 5.0.0"
gem 'acts_as_votable', '~> 0.11.1' gem "acts_as_votable", "~> 0.11.1"
gem 'ahoy_matey', '~> 1.6.0' gem "ahoy_matey", "~> 1.6.0"
gem 'ancestry', '~> 3.0.2' gem "ancestry", "~> 3.0.2"
gem 'autoprefixer-rails', '~> 8.2.0' gem "autoprefixer-rails", "~> 8.2.0"
gem 'browser', '~> 2.5.3' gem "browser", "~> 2.5.3"
gem 'cancancan', '~> 2.3.0' gem "cancancan", "~> 2.3.0"
gem 'ckeditor', '~> 4.2.3' gem "ckeditor", "~> 4.2.3"
gem 'cocoon', '~> 1.2.9' gem "cocoon", "~> 1.2.9"
gem 'coffee-rails', '~> 4.2.2' gem "coffee-rails", "~> 4.2.2"
gem 'daemons', '~> 1.2.4' gem "daemons", "~> 1.2.4"
gem 'dalli', '~> 2.7.6' gem "dalli", "~> 2.7.6"
gem 'delayed_job_active_record', '~> 4.1.3' gem "delayed_job_active_record", "~> 4.1.3"
gem 'devise', '~> 3.5.7' gem "devise", "~> 3.5.7"
gem 'devise-async', '~> 0.10.2' gem "devise-async", "~> 0.10.2"
gem 'devise_security_extension', '~> 0.10.0' gem "devise_security_extension", "~> 0.10.0"
gem 'foundation-rails', '~> 6.4.3.0' gem "foundation-rails", "~> 6.4.3.0"
gem 'foundation_rails_helper', '~> 2.0.0' gem "foundation_rails_helper", "~> 2.0.0"
gem 'graphiql-rails', '~> 1.4.1' gem "graphiql-rails", "~> 1.4.1"
gem 'graphql', '~> 1.7.8' gem "graphql", "~> 1.7.8"
gem 'groupdate', '~> 3.2.0' gem "groupdate", "~> 3.2.0"
gem 'initialjs-rails', '~> 0.2.0.5' gem "initialjs-rails", "~> 0.2.0.5"
gem 'invisible_captcha', '~> 0.10.0' gem "invisible_captcha", "~> 0.10.0"
gem 'jquery-fileupload-rails' gem "jquery-fileupload-rails"
gem 'jquery-rails', '~> 4.3.3' gem "jquery-rails", "~> 4.3.3"
gem 'jquery-ui-rails', '~> 6.0.1' gem "jquery-ui-rails", "~> 6.0.1"
gem 'kaminari', '~> 1.1.1' gem "kaminari", "~> 1.1.1"
gem 'newrelic_rpm', '~> 4.1.0.333' gem "newrelic_rpm", "~> 4.1.0.333"
gem 'omniauth', '~> 1.8.1' gem "omniauth", "~> 1.8.1"
gem 'omniauth-facebook', '~> 4.0.0' gem "omniauth-facebook", "~> 4.0.0"
gem 'omniauth-google-oauth2', '~> 0.4.0' gem "omniauth-google-oauth2", "~> 0.4.0"
gem 'omniauth-twitter', '~> 1.4.0' gem "omniauth-twitter", "~> 1.4.0"
gem 'paperclip', '~> 5.2.1' gem "paperclip", "~> 5.2.1"
gem 'paranoia', '~> 2.4.1' gem "paranoia", "~> 2.4.1"
gem 'pg', '~> 0.21.0' gem "pg", "~> 0.21.0"
gem 'pg_search', '~> 2.0.1' gem "pg_search", "~> 2.0.1"
gem 'redcarpet', '~> 3.4.0' gem "redcarpet", "~> 3.4.0"
gem 'responders', '~> 2.4.0' gem "responders", "~> 2.4.0"
gem 'rinku', '~> 2.0.2', require: 'rails_rinku' gem "rinku", "~> 2.0.2", require: "rails_rinku"
gem 'rollbar', '~> 2.18.0' gem "rollbar", "~> 2.18.0"
gem 'sass-rails', '~> 5.0', '>= 5.0.4' gem "sass-rails", "~> 5.0", ">= 5.0.4"
gem 'savon', '~> 2.12.0' gem "savon", "~> 2.12.0"
gem 'sitemap_generator', '~> 6.0.1' gem "sitemap_generator", "~> 6.0.1"
gem 'social-share-button', '~> 1.1' gem "social-share-button", "~> 1.1"
gem 'sprockets', '~> 3.7.2' gem "sprockets", "~> 3.7.2"
gem 'turbolinks', '~> 2.5.3' gem "turbolinks", "~> 2.5.3"
gem 'turnout', '~> 2.4.0' gem "turnout", "~> 2.4.0"
gem 'uglifier', '~> 4.1.19' gem "uglifier", "~> 4.1.19"
gem 'unicorn', '~> 5.4.1' gem "unicorn", "~> 5.4.1"
gem 'whenever', '~> 0.10.0', require: false gem "whenever", "~> 0.10.0", require: false
gem 'globalize', '~> 5.0.0' gem "globalize", "~> 5.0.0"
gem 'globalize-accessors', '~> 0.2.1' gem "globalize-accessors", "~> 0.2.1"
gem 'recipient_interceptor', '~> 0.2.0' gem "recipient_interceptor", "~> 0.2.0"
source 'https://rails-assets.org' do source "https://rails-assets.org" do
gem 'rails-assets-leaflet' gem "rails-assets-leaflet"
gem 'rails-assets-markdown-it', '~> 8.2.1' gem "rails-assets-markdown-it", "~> 8.2.1"
end end
group :development, :test do group :development, :test do
gem 'bullet', '~> 5.7.0' gem "bullet", "~> 5.7.0"
gem 'byebug', '~> 10.0.0' gem "byebug", "~> 10.0.0"
gem 'factory_bot_rails', '~> 4.8.2' gem "factory_bot_rails", "~> 4.8.2"
gem 'faker', '~> 1.8.7' gem "faker", "~> 1.8.7"
gem 'i18n-tasks', '~> 0.9.25' gem "i18n-tasks", "~> 0.9.25"
gem 'knapsack_pro', '~> 1.1.0' gem "knapsack_pro", "~> 1.1.0"
gem 'launchy', '~> 2.4.3' gem "launchy", "~> 2.4.3"
gem 'letter_opener_web', '~> 1.3.4' gem "letter_opener_web", "~> 1.3.4"
gem 'quiet_assets', '~> 1.1.0' gem "quiet_assets", "~> 1.1.0"
gem 'spring', '~> 2.0.1' gem "spring", "~> 2.0.1"
gem 'spring-commands-rspec', '~> 1.0.4' gem "spring-commands-rspec", "~> 1.0.4"
end end
group :test do group :test do
gem 'capybara', '~> 2.17.0' gem "capybara", "~> 2.17.0"
gem 'coveralls', '~> 0.8.22', require: false gem "coveralls", "~> 0.8.22", require: false
gem 'database_cleaner', '~> 1.7.0' gem "database_cleaner", "~> 1.7.0"
gem 'email_spec', '~> 2.1.0' gem "email_spec", "~> 2.1.0"
gem 'rspec-rails', '~> 3.8' gem "rspec-rails", "~> 3.8"
gem 'selenium-webdriver', '~> 3.10' gem "selenium-webdriver", "~> 3.10"
end end
group :development do group :development do
gem 'capistrano', '~> 3.10.1', require: false gem "capistrano", "~> 3.10.1", require: false
gem 'capistrano-bundler', '~> 1.2', require: false gem "capistrano-bundler", "~> 1.2", require: false
gem 'capistrano-rails', '~> 1.4.0', require: false gem "capistrano-rails", "~> 1.4.0", require: false
gem 'capistrano3-delayed-job', '~> 1.7.3' gem "capistrano3-delayed-job", "~> 1.7.3"
gem 'mdl', '~> 0.5.0', require: false gem "mdl", "~> 0.5.0", require: false
gem 'rubocop', '~> 0.54.0', require: false gem "rubocop", "~> 0.54.0", require: false
gem 'rubocop-rspec', '~> 1.26.0', require: false gem "rubocop-rspec", "~> 1.26.0", require: false
gem 'rvm1-capistrano3', '~> 1.4.0', require: false gem "rvm1-capistrano3", "~> 1.4.0", require: false
gem 'scss_lint', '~> 0.55.0', require: false gem "scss_lint", "~> 0.55.0", require: false
gem 'web-console', '~> 3.3.0' gem "web-console", "~> 3.3.0"
end end
eval_gemfile './Gemfile_custom' eval_gemfile "./Gemfile_custom"

View File

@@ -1,7 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__) require File.expand_path("../config/application", __FILE__)
Rails.application.load_tasks if Rake::Task.tasks.empty? Rails.application.load_tasks if Rake::Task.tasks.empty?
KnapsackPro.load_tasks if defined?(KnapsackPro) KnapsackPro.load_tasks if defined?(KnapsackPro)

View File

@@ -133,6 +133,6 @@ $(function(){
Turbolinks.enableProgressBar(); Turbolinks.enableProgressBar();
$(document).ready(initialize_modules); $(document).ready(initialize_modules);
$(document).on('page:load', initialize_modules); $(document).on("page:load", initialize_modules);
$(document).on('ajax:complete', initialize_modules); $(document).on("ajax:complete", initialize_modules);
}); });

View File

@@ -19,7 +19,7 @@ CKEDITOR.editorConfig = function( config )
// Rails CSRF token // Rails CSRF token
config.filebrowserParams = function(){ config.filebrowserParams = function(){
var csrf_token, csrf_param, meta, var csrf_token, csrf_param, meta,
metas = document.getElementsByTagName('meta'), metas = document.getElementsByTagName("meta"),
params = new Object(); params = new Object();
for ( var i = 0 ; i < metas.length ; i++ ){ for ( var i = 0 ; i < metas.length ; i++ ){
@@ -58,47 +58,47 @@ CKEDITOR.editorConfig = function( config )
}; };
// Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash) // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
CKEDITOR.on( 'dialogDefinition', function( ev ){ CKEDITOR.on( "dialogDefinition", function( ev ){
// Take the dialog name and its definition from the event data. // Take the dialog name and its definition from the event data.
var dialogName = ev.data.name; var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition; var dialogDefinition = ev.data.definition;
var content, upload; var content, upload;
if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) { if (CKEDITOR.tools.indexOf(["link", "image", "attachment", "flash"], dialogName) > -1) {
content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload')); content = (dialogDefinition.getContents("Upload") || dialogDefinition.getContents("upload"));
upload = (content == null ? null : content.get('upload')); upload = (content == null ? null : content.get("upload"));
if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) { if (upload && upload.filebrowser && upload.filebrowser["params"] === undefined) {
upload.filebrowser['params'] = config.filebrowserParams(); upload.filebrowser["params"] = config.filebrowserParams();
upload.action = config.addQueryString(upload.action, upload.filebrowser['params']); upload.action = config.addQueryString(upload.action, upload.filebrowser["params"]);
} }
} }
}); });
// Toolbar groups configuration. // Toolbar groups configuration.
config.toolbar = [ config.toolbar = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] }, { name: "document", groups: [ "mode", "document", "doctools" ], items: [ "Source"] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] }, { name: "clipboard", groups: [ "clipboard", "undo" ], items: [ "Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Undo", "Redo" ] },
// { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] }, // { name: "editing", groups: [ "find", "selection", "spellchecker" ], items: [ "Find", "Replace", "-", "SelectAll", "-", "Scayt" ] },
// { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, // { name: "forms", items: [ "Form", "Checkbox", "Radio", "TextField", "Textarea", "Select", "Button", "ImageButton", "HiddenField" ] },
{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] }, { name: "links", items: [ "Link", "Unlink", "Anchor" ] },
{ name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar' ] }, { name: "insert", items: [ "Image", "Flash", "Table", "HorizontalRule", "SpecialChar" ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] }, { name: "paragraph", groups: [ "list", "indent", "blocks", "align", "bidi" ], items: [ "NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote", "CreateDiv", "-", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock" ] },
'/', "/",
{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] }, { name: "styles", items: [ "Styles", "Format", "Font", "FontSize" ] },
{ name: 'colors', items: [ 'TextColor', 'BGColor' ] }, { name: "colors", items: [ "TextColor", "BGColor" ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] } { name: "basicstyles", groups: [ "basicstyles", "cleanup" ], items: [ "Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript", "-", "RemoveFormat" ] }
]; ];
config.toolbar_mini = [ config.toolbar_mini = [
{ name: 'paragraph', groups: [ 'list' ], items: [ 'NumberedList', 'BulletedList' ] }, { name: "paragraph", groups: [ "list" ], items: [ "NumberedList", "BulletedList" ] },
{ name: 'links', items: [ 'Link', 'Unlink' ] }, { name: "links", items: [ "Link", "Unlink" ] },
{ name: 'styles', items: [ 'Format' ] }, { name: "styles", items: [ "Format" ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike' ] } { name: "basicstyles", groups: [ "basicstyles", "cleanup" ], items: [ "Bold", "Italic", "Underline", "Strike" ] }
]; ];
config.toolbar_admin = config.toolbar_mini.concat([ config.toolbar_admin = config.toolbar_mini.concat([
{ name: 'insert', items: [ 'Image', 'Table' ] } { name: "insert", items: [ "Image", "Table" ] }
]); ]);
config.toolbar = "mini"; config.toolbar = "mini";

View File

@@ -1,3 +1,3 @@
//= require ckeditor/init //= require ckeditor/init
CKEDITOR.config.customConfig = '<%= javascript_path 'ckeditor/config.js' %>'; CKEDITOR.config.customConfig = "<%= javascript_path 'ckeditor/config.js' %>";

View File

@@ -1,4 +1,4 @@
$(document).bind('page:change', function() { $(document).bind("page:change", function() {
if (typeof(CKEDITOR) != "undefined"){ if (typeof(CKEDITOR) != "undefined"){
for(name in CKEDITOR.instances){ for(name in CKEDITOR.instances){
try{CKEDITOR.replace(name);}catch(err){}; try{CKEDITOR.replace(name);}catch(err){};

View File

@@ -9,6 +9,6 @@ var initialize_stats_modules = function() {
$(function(){ $(function(){
$(document).ready(initialize_stats_modules); $(document).ready(initialize_stats_modules);
$(document).on('page:load', initialize_stats_modules); $(document).on("page:load", initialize_stats_modules);
$(document).on('ajax:complete', initialize_stats_modules); $(document).on("ajax:complete", initialize_stats_modules);
}); });

View File

@@ -1,7 +1,7 @@
module AdminBudgetInvestmentsHelper module AdminBudgetInvestmentsHelper
def advanced_menu_visibility def advanced_menu_visibility
(params[:advanced_filters].empty? && params["min_total_supports"].blank?) ? 'hide' : '' (params[:advanced_filters].empty? && params["min_total_supports"].blank?) ? "hide" : ""
end end
def init_advanced_menu def init_advanced_menu

View File

@@ -1,7 +1,7 @@
module AdminHelper module AdminHelper
def side_menu def side_menu
if namespace == 'moderation/budgets' if namespace == "moderation/budgets"
render "/moderation/menu" render "/moderation/menu"
else else
render "/#{namespace}/menu" render "/#{namespace}/menu"
@@ -13,7 +13,7 @@ module AdminHelper
end end
def namespaced_header_title def namespaced_header_title
if namespace == 'moderation/budgets' if namespace == "moderation/budgets"
t("moderation.header.title") t("moderation.header.title")
else else
t("#{namespace}.header.title") t("#{namespace}.header.title")
@@ -71,13 +71,13 @@ module AdminHelper
def official_level_options def official_level_options
options = [["", 0]] options = [["", 0]]
(1..5).each do |i| (1..5).each do |i|
options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(': '), i] options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(": "), i]
end end
options options
end end
def admin_select_options def admin_select_options
Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] } Administrator.all.order("users.username asc").includes(:user).collect { |v| [ v.name, v.id ] }
end end
def admin_submit_action(resource) def admin_submit_action(resource)

View File

@@ -4,10 +4,10 @@ module ApplicationHelper
return false if user_signed_in? return false if user_signed_in?
# Using path because fullpath yields false negatives since it contains # Using path because fullpath yields false negatives since it contains
# parameters too # parameters too
request.path == '/' request.path == "/"
end end
# if current path is /debates current_path_with_query_params(foo: 'bar') returns /debates?foo=bar # if current path is /debates current_path_with_query_params(foo: "bar") returns /debates?foo=bar
# notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last) # notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last)
def current_path_with_query_params(query_parameters) def current_path_with_query_params(query_parameters)
url_for(request.query_parameters.merge(query_parameters)) url_for(request.query_parameters.merge(query_parameters))

View File

@@ -1,12 +1,12 @@
module BudgetsHelper module BudgetsHelper
def show_links_to_budget_investments(budget) def show_links_to_budget_investments(budget)
['balloting', 'reviewing_ballots', 'finished'].include? budget.phase ["balloting", "reviewing_ballots", "finished"].include? budget.phase
end end
def heading_name_and_price_html(heading, budget) def heading_name_and_price_html(heading, budget)
content_tag :div do content_tag :div do
concat(heading.name + ' ') concat(heading.name + " ")
concat(content_tag(:span, budget.formatted_heading_price(heading))) concat(content_tag(:span, budget.formatted_heading_price(heading)))
end end
end end

View File

@@ -6,9 +6,9 @@ module DebatesHelper
def empty_recommended_debates_message_text(user) def empty_recommended_debates_message_text(user)
if user.interests.any? if user.interests.any?
t('debates.index.recommendations.without_results') t("debates.index.recommendations.without_results")
else else
t('debates.index.recommendations.without_interests') t("debates.index.recommendations.without_interests")
end end
end end

View File

@@ -1,7 +1,7 @@
module DocumentablesHelper module DocumentablesHelper
def documentable_class(documentable) def documentable_class(documentable)
documentable.class.name.parameterize('_') documentable.class.name.parameterize("_")
end end
def max_documents_allowed(documentable) def max_documents_allowed(documentable)

View File

@@ -5,7 +5,7 @@ module DocumentsHelper
end end
def document_errors_on_attachment(document) def document_errors_on_attachment(document)
document.errors[:attachment].join(', ') if document.errors.key?(:attachment) document.errors[:attachment].join(", ") if document.errors.key?(:attachment)
end end
def bytes_to_mega(bytes) def bytes_to_mega(bytes)
@@ -18,7 +18,7 @@ module DocumentsHelper
def render_destroy_document_link(builder, document) def render_destroy_document_link(builder, document)
if !document.persisted? && document.cached_attachment.present? if !document.persisted? && document.cached_attachment.present?
link_to t('documents.form.delete_button'), link_to t("documents.form.delete_button"),
direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type, direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type,
"direct_upload[resource_id]": document.documentable_id, "direct_upload[resource_id]": document.documentable_id,
"direct_upload[resource_relation]": "documents", "direct_upload[resource_relation]": "documents",
@@ -27,7 +27,7 @@ module DocumentsHelper
remote: true, remote: true,
class: "delete remove-cached-attachment" class: "delete remove-cached-attachment"
else else
link_to_remove_association document.new_record? ? t('documents.form.cancel_button') : t('documents.form.delete_button') , builder, class: "delete remove-document" link_to_remove_association document.new_record? ? t("documents.form.cancel_button") : t("documents.form.delete_button") , builder, class: "delete remove-document"
end end
end end
@@ -40,7 +40,7 @@ module DocumentsHelper
html += builder.file_field :attachment, html += builder.file_field :attachment,
label: false, label: false,
accept: accepted_content_types_extensions(document.documentable_type.constantize), accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: 'js-document-attachment', class: "js-document-attachment",
data: { data: {
url: document_direct_upload_url(document), url: document_direct_upload_url(document),
nested_document: true nested_document: true

View File

@@ -5,7 +5,7 @@ module EmbedVideosHelper
def embedded_video_code def embedded_video_code
link = @proposal.video_url link = @proposal.video_url
title = t('proposals.show.embed_video_title', proposal: @proposal.title) title = t("proposals.show.embed_video_title", proposal: @proposal.title)
if link =~ /vimeo.*/ if link =~ /vimeo.*/
server = "Vimeo" server = "Vimeo"
elsif link =~ /youtu*.*/ elsif link =~ /youtu*.*/
@@ -27,7 +27,7 @@ module EmbedVideosHelper
if match && match[2] if match && match[2]
'<iframe src="' + src + match[2] + '" style="border:0;" allowfullscreen title="' + title + '"></iframe>' '<iframe src="' + src + match[2] + '" style="border:0;" allowfullscreen title="' + title + '"></iframe>'
else else
'' ""
end end
end end

View File

@@ -6,8 +6,8 @@ module FollowablesHelper
def followable_icon(followable) def followable_icon(followable)
{ {
proposals: 'Proposal', proposals: "Proposal",
budget: 'Budget::Investment' budget: "Budget::Investment"
}.invert[followable] }.invert[followable]
end end

View File

@@ -2,12 +2,12 @@ module FollowsHelper
def follow_text(followable) def follow_text(followable)
entity = followable.class.name.underscore entity = followable.class.name.underscore
t('shared.follow_entity', entity: t("activerecord.models.#{entity}.one").downcase) t("shared.follow_entity", entity: t("activerecord.models.#{entity}.one").downcase)
end end
def unfollow_text(followable) def unfollow_text(followable)
entity = followable.class.name.underscore entity = followable.class.name.underscore
t('shared.unfollow_entity', entity: t("activerecord.models.#{entity}.one").downcase) t("shared.unfollow_entity", entity: t("activerecord.models.#{entity}.one").downcase)
end end
end end

View File

@@ -5,7 +5,7 @@ module ImageablesHelper
end end
def imageable_class(imageable) def imageable_class(imageable)
imageable.class.name.parameterize('_') imageable.class.name.parameterize("_")
end end
def imageable_max_file_size def imageable_max_file_size

View File

@@ -19,7 +19,7 @@ module ImagesHelper
end end
def image_errors_on_attachment(image) def image_errors_on_attachment(image)
image.errors[:attachment].join(', ') if image.errors.key?(:attachment) image.errors[:attachment].join(", ") if image.errors.key?(:attachment)
end end
def image_bytes_to_megabytes(bytes) def image_bytes_to_megabytes(bytes)
@@ -32,7 +32,7 @@ module ImagesHelper
def render_destroy_image_link(builder, image) def render_destroy_image_link(builder, image)
if !image.persisted? && image.cached_attachment.present? if !image.persisted? && image.cached_attachment.present?
link_to t('images.form.delete_button'), link_to t("images.form.delete_button"),
direct_upload_destroy_url("direct_upload[resource_type]": image.imageable_type, direct_upload_destroy_url("direct_upload[resource_type]": image.imageable_type,
"direct_upload[resource_id]": image.imageable_id, "direct_upload[resource_id]": image.imageable_id,
"direct_upload[resource_relation]": "image", "direct_upload[resource_relation]": "image",
@@ -41,7 +41,7 @@ module ImagesHelper
remote: true, remote: true,
class: "delete remove-cached-attachment" class: "delete remove-cached-attachment"
else else
link_to_remove_association t('images.form.delete_button'), builder, class: "delete remove-image" link_to_remove_association t("images.form.delete_button"), builder, class: "delete remove-image"
end end
end end
@@ -54,7 +54,7 @@ module ImagesHelper
html += builder.file_field :attachment, html += builder.file_field :attachment,
label: false, label: false,
accept: imageable_accepted_content_types_extensions, accept: imageable_accepted_content_types_extensions,
class: 'js-image-attachment', class: "js-image-attachment",
data: { data: {
url: image_direct_upload_url(imageable), url: image_direct_upload_url(imageable),
nested_image: true nested_image: true

View File

@@ -2,7 +2,7 @@ module LayoutsHelper
def layout_menu_link_to(text, path, is_active, options) def layout_menu_link_to(text, path, is_active, options)
if is_active if is_active
content_tag(:span, t('shared.you_are_in'), class: 'show-for-sr') + ' ' + content_tag(:span, t("shared.you_are_in"), class: "show-for-sr") + " " +
link_to(text, path, options.merge(class: "is-active")) link_to(text, path, options.merge(class: "is-active"))
else else
link_to(text, path, options) link_to(text, path, options)

View File

@@ -14,10 +14,10 @@ module LegislationHelper
def link_to_toggle_legislation_proposal_selection(proposal) def link_to_toggle_legislation_proposal_selection(proposal)
if proposal.selected? if proposal.selected?
button_text = t("admin.legislation.proposals.index.selected") button_text = t("admin.legislation.proposals.index.selected")
html_class = 'button expanded' html_class = "button expanded"
else else
button_text = t("admin.legislation.proposals.index.select") button_text = t("admin.legislation.proposals.index.select")
html_class = 'button hollow expanded' html_class = "button hollow expanded"
end end
link_to button_text, link_to button_text,

View File

@@ -1,7 +1,7 @@
module OfficersHelper module OfficersHelper
def officer_label(officer) def officer_label(officer)
truncate([officer.name, officer.email].compact.join(' - '), length: 100) truncate([officer.name, officer.email].compact.join(" - "), length: 100)
end end
def vote_collection_shift? def vote_collection_shift?

View File

@@ -42,7 +42,7 @@ module PollsHelper
end end
def poll_voter_token(poll, user) def poll_voter_token(poll, user)
Poll::Voter.where(poll: poll, user: user, origin: "web").first&.token || '' Poll::Voter.where(poll: poll, user: user, origin: "web").first&.token || ""
end end
def voted_before_sign_in(question) def voted_before_sign_in(question)

View File

@@ -11,12 +11,12 @@ module SearchHelper
[t("shared.advanced_search.date_2"), 2], [t("shared.advanced_search.date_2"), 2],
[t("shared.advanced_search.date_3"), 3], [t("shared.advanced_search.date_3"), 3],
[t("shared.advanced_search.date_4"), 4], [t("shared.advanced_search.date_4"), 4],
[t("shared.advanced_search.date_5"), 'custom']], [t("shared.advanced_search.date_5"), "custom"]],
selected_date_range) selected_date_range)
end end
def selected_date_range def selected_date_range
custom_date_range? ? 'custom' : params[:advanced_search].try(:[], :date_min) custom_date_range? ? "custom" : params[:advanced_search].try(:[], :date_min)
end end
def custom_date_range? def custom_date_range?

View File

@@ -1,7 +1,7 @@
module SettingsHelper module SettingsHelper
def setting_for_widget(widget) def setting_for_widget(widget)
Setting.where(key: 'feature.user.recommendations').first Setting.where(key: "feature.user.recommendations").first
end end
end end

View File

@@ -1,28 +1,28 @@
module StatsHelper module StatsHelper
def events_chart_tag(events, opt = {}) def events_chart_tag(events, opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(events: events) opt[:data][:graph] = admin_api_stats_path(events: events)
content_tag :div, "", opt content_tag :div, "", opt
end end
def visits_chart_tag(opt = {}) def visits_chart_tag(opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(visits: true) opt[:data][:graph] = admin_api_stats_path(visits: true)
content_tag :div, "", opt content_tag :div, "", opt
end end
def spending_proposals_chart_tag(opt = {}) def spending_proposals_chart_tag(opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) opt[:data][:graph] = admin_api_stats_path(spending_proposals: true)
content_tag :div, "", opt content_tag :div, "", opt
end end
def budget_investments_chart_tag(opt = {}) def budget_investments_chart_tag(opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(budget_investments: true) opt[:data][:graph] = admin_api_stats_path(budget_investments: true)
content_tag :div, "", opt content_tag :div, "", opt

View File

@@ -2,32 +2,32 @@ module TagsHelper
def taggables_path(taggable_type, tag_name) def taggables_path(taggable_type, tag_name)
case taggable_type case taggable_type
when 'debate' when "debate"
debates_path(search: tag_name) debates_path(search: tag_name)
when 'proposal' when "proposal"
proposals_path(search: tag_name) proposals_path(search: tag_name)
when 'budget/investment' when "budget/investment"
budget_investments_path(@budget, search: tag_name) budget_investments_path(@budget, search: tag_name)
when 'legislation/proposal' when "legislation/proposal"
legislation_process_proposals_path(@process, search: tag_name) legislation_process_proposals_path(@process, search: tag_name)
else else
'#' "#"
end end
end end
def taggable_path(taggable) def taggable_path(taggable)
taggable_type = taggable.class.name.underscore taggable_type = taggable.class.name.underscore
case taggable_type case taggable_type
when 'debate' when "debate"
debate_path(taggable) debate_path(taggable)
when 'proposal' when "proposal"
proposal_path(taggable) proposal_path(taggable)
when 'budget/investment' when "budget/investment"
budget_investment_path(taggable.budget_id, taggable) budget_investment_path(taggable.budget_id, taggable)
when 'legislation/proposal' when "legislation/proposal"
legislation_process_proposal_path(@process, taggable) legislation_process_proposal_path(@process, taggable)
else else
'#' "#"
end end
end end

View File

@@ -4,7 +4,7 @@ module TracksHelper
track_data = "" track_data = ""
prefix = " data-track-event-" prefix = " data-track-event-"
data.each do |key, value| data.each do |key, value|
track_data = track_data + prefix + key.to_s + '=' + value + " " track_data = track_data + prefix + key.to_s + "=" + value + " "
end end
content_for :track_event do content_for :track_event do
track_data track_data

View File

@@ -16,8 +16,8 @@ module UsersHelper
if commentable.nil? if commentable.nil?
deleted_commentable_text(comment) deleted_commentable_text(comment)
elsif commentable.hidden? elsif commentable.hidden?
content_tag(:del, commentable.title) + ' ' + content_tag(:del, commentable.title) + " " +
content_tag(:span, '(' + deleted_commentable_text(comment) + ')', class: 'small') content_tag(:span, "(" + deleted_commentable_text(comment) + ")", class: "small")
else else
link_to(commentable.title, comment) link_to(commentable.title, comment)
end end
@@ -58,9 +58,9 @@ module UsersHelper
def interests_title_text(user) def interests_title_text(user)
if current_user == user if current_user == user
t('account.show.public_interests_my_title_list') t("account.show.public_interests_my_title_list")
else else
t('account.show.public_interests_user_title_list') t("account.show.public_interests_user_title_list")
end end
end end

View File

@@ -22,8 +22,8 @@ module ValuationHelper
valuators.first.name + valuators.first.name +
"</span>".html_safe "</span>".html_safe
else else
"<span title=\"".html_safe + valuators.map(&:name).join(', ') + "\">".html_safe + "<span title=\"".html_safe + valuators.map(&:name).join(", ") + "\">".html_safe +
t('valuation.budget_investments.index.valuators_assigned', count: valuators.size) + t("valuation.budget_investments.index.valuators_assigned", count: valuators.size) +
"</span>".html_safe "</span>".html_safe
end end
end end

View File

@@ -1,7 +1,7 @@
module ValuatorsHelper module ValuatorsHelper
def valuator_label(valuator) def valuator_label(valuator)
truncate([valuator.name, valuator.email, valuator.description].compact.join(' - '), length: 100) truncate([valuator.name, valuator.email, valuator.description].compact.join(" - "), length: 100)
end end
end end

View File

@@ -1,9 +1,9 @@
module VerificationHelper module VerificationHelper
def document_types def document_types
[[t('verification.residence.new.document_type.spanish_id'), 1], [[t("verification.residence.new.document_type.spanish_id"), 1],
[t('verification.residence.new.document_type.passport'), 2], [t("verification.residence.new.document_type.passport"), 2],
[t('verification.residence.new.document_type.residence_card'), 3]] [t("verification.residence.new.document_type.residence_card"), 3]]
end end
def mask_phone(number) def mask_phone(number)

View File

@@ -6,9 +6,9 @@ module VotesHelper
def votes_percentage(vote, debate) def votes_percentage(vote, debate)
return "0%" if debate.total_votes == 0 return "0%" if debate.total_votes == 0
if vote == 'likes' if vote == "likes"
debate_percentage_of_likes(debate).to_s + "%" debate_percentage_of_likes(debate).to_s + "%"
elsif vote == 'dislikes' elsif vote == "dislikes"
(100 - debate_percentage_of_likes(debate)).to_s + "%" (100 - debate_percentage_of_likes(debate)).to_s + "%"
end end
end end

View File

@@ -15,7 +15,7 @@ module WelcomeHelper
when "Proposal" when "Proposal"
proposal_path(recommended) proposal_path(recommended)
else else
'#' "#"
end end
end end

View File

@@ -1,5 +1,5 @@
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
helper :settings helper :settings
default from: "#{Setting['mailer_from_name']} <#{Setting['mailer_from_address']}>" default from: "#{Setting['mailer_from_name']} <#{Setting['mailer_from_address']}>"
layout 'mailer' layout "mailer"
end end

View File

@@ -1,7 +1,7 @@
class DeviseMailer < Devise::Mailer class DeviseMailer < Devise::Mailer
helper :application, :settings helper :application, :settings
include Devise::Controllers::UrlHelpers include Devise::Controllers::UrlHelpers
default template_path: 'devise/mailer' default template_path: "devise/mailer"
protected protected

View File

@@ -11,7 +11,7 @@ class Mailer < ApplicationMailer
@email_to = @commentable.author.email @email_to = @commentable.author.email
with_user(@commentable.author) do with_user(@commentable.author) do
subject = t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase) subject = t("mailers.comment.subject", commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)
mail(to: @email_to, subject: subject) if @commentable.present? && @commentable.author.present? mail(to: @email_to, subject: subject) if @commentable.present? && @commentable.author.present?
end end
end end
@@ -33,7 +33,7 @@ class Mailer < ApplicationMailer
@document_number = document_number @document_number = document_number
with_user(user) do with_user(user) do
mail(to: @email_to, subject: t('mailers.email_verification.subject')) mail(to: @email_to, subject: t("mailers.email_verification.subject"))
end end
end end
@@ -43,7 +43,7 @@ class Mailer < ApplicationMailer
@email_to = @author.email @email_to = @author.email
with_user(@author) do with_user(@author) do
mail(to: @email_to, subject: t('mailers.unfeasible_spending_proposal.subject', code: @spending_proposal.code)) mail(to: @email_to, subject: t("mailers.unfeasible_spending_proposal.subject", code: @spending_proposal.code))
end end
end end
@@ -53,7 +53,7 @@ class Mailer < ApplicationMailer
@email_to = @receiver.email @email_to = @receiver.email
with_user(@receiver) do with_user(@receiver) do
mail(to: @email_to, subject: t('mailers.direct_message_for_receiver.subject')) mail(to: @email_to, subject: t("mailers.direct_message_for_receiver.subject"))
end end
end end
@@ -63,7 +63,7 @@ class Mailer < ApplicationMailer
@email_to = @sender.email @email_to = @sender.email
with_user(@sender) do with_user(@sender) do
mail(to: @email_to, subject: t('mailers.direct_message_for_sender.subject')) mail(to: @email_to, subject: t("mailers.direct_message_for_sender.subject"))
end end
end end
@@ -72,7 +72,7 @@ class Mailer < ApplicationMailer
@email_to = user.email @email_to = user.email
with_user(user) do with_user(user) do
mail(to: @email_to, subject: t('mailers.proposal_notification_digest.title', org_name: Setting['org_name'])) mail(to: @email_to, subject: t("mailers.proposal_notification_digest.title", org_name: Setting["org_name"]))
end end
end end
@@ -80,7 +80,7 @@ class Mailer < ApplicationMailer
@email_to = email @email_to = email
I18n.with_locale(I18n.default_locale) do I18n.with_locale(I18n.default_locale) do
mail(to: @email_to, subject: t('mailers.user_invite.subject', org_name: Setting["org_name"])) mail(to: @email_to, subject: t("mailers.user_invite.subject", org_name: Setting["org_name"]))
end end
end end
@@ -89,7 +89,7 @@ class Mailer < ApplicationMailer
@email_to = @investment.author.email @email_to = @investment.author.email
with_user(@investment.author) do with_user(@investment.author) do
mail(to: @email_to, subject: t('mailers.budget_investment_created.subject')) mail(to: @email_to, subject: t("mailers.budget_investment_created.subject"))
end end
end end
@@ -99,7 +99,7 @@ class Mailer < ApplicationMailer
@email_to = @author.email @email_to = @author.email
with_user(@author) do with_user(@author) do
mail(to: @email_to, subject: t('mailers.budget_investment_unfeasible.subject', code: @investment.code)) mail(to: @email_to, subject: t("mailers.budget_investment_unfeasible.subject", code: @investment.code))
end end
end end
@@ -109,7 +109,7 @@ class Mailer < ApplicationMailer
@email_to = @author.email @email_to = @author.email
with_user(@author) do with_user(@author) do
mail(to: @email_to, subject: t('mailers.budget_investment_selected.subject', code: @investment.code)) mail(to: @email_to, subject: t("mailers.budget_investment_selected.subject", code: @investment.code))
end end
end end
@@ -119,7 +119,7 @@ class Mailer < ApplicationMailer
@email_to = @author.email @email_to = @author.email
with_user(@author) do with_user(@author) do
mail(to: @email_to, subject: t('mailers.budget_investment_unselected.subject', code: @investment.code)) mail(to: @email_to, subject: t("mailers.budget_investment_unselected.subject", code: @investment.code))
end end
end end

View File

@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__) require ::File.expand_path("../config/environment", __FILE__)
run Rails.application run Rails.application

View File

@@ -1,7 +1,6 @@
require File.expand_path("../boot", __FILE__)
require File.expand_path('../boot', __FILE__) require "rails/all"
require 'rails/all'
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
@@ -44,13 +43,13 @@ module Consul
"zh-TW"] "zh-TW"]
config.i18n.available_locales = available_locales config.i18n.available_locales = available_locales
config.i18n.fallbacks = { config.i18n.fallbacks = {
'fr' => 'es', "fr" => "es",
'gl' => 'es', "gl" => "es",
'it' => 'es', "it" => "es",
'pt-BR' => 'es' "pt-BR" => "es"
} }
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] config.i18n.load_path += Dir[Rails.root.join("config", "locales", "**", "*.{rb,yml}")]
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'custom', '**', '*.{rb,yml}')] config.i18n.load_path += Dir[Rails.root.join("config", "locales", "custom", "**", "*.{rb,yml}")]
config.after_initialize { Globalize.set_fallbacks_to_all_available_locales } config.after_initialize { Globalize.set_fallbacks_to_all_available_locales }
@@ -60,8 +59,8 @@ module Consul
config.active_record.raise_in_transactional_callbacks = true config.active_record.raise_in_transactional_callbacks = true
# Add lib to the autoload path # Add lib to the autoload path
config.autoload_paths << Rails.root.join('lib') config.autoload_paths << Rails.root.join("lib")
config.time_zone = 'Madrid' config.time_zone = "Madrid"
config.active_job.queue_adapter = :delayed_job config.active_job.queue_adapter = :delayed_job
# CONSUL specific custom overrides # CONSUL specific custom overrides
@@ -71,7 +70,7 @@ module Consul
# #
config.autoload_paths << "#{Rails.root}/app/controllers/custom" config.autoload_paths << "#{Rails.root}/app/controllers/custom"
config.autoload_paths << "#{Rails.root}/app/models/custom" config.autoload_paths << "#{Rails.root}/app/models/custom"
config.paths['app/views'].unshift(Rails.root.join('app', 'views', 'custom')) config.paths["app/views"].unshift(Rails.root.join("app", "views", "custom"))
end end
end end

View File

@@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require "bundler/setup" # Set up gems listed in the Gemfile.

View File

@@ -1,19 +1,19 @@
# config valid only for current version of Capistrano # config valid only for current version of Capistrano
lock '~> 3.10.1' lock "~> 3.10.1"
def deploysecret(key) def deploysecret(key)
@deploy_secrets_yml ||= YAML.load_file('config/deploy-secrets.yml')[fetch(:stage).to_s] @deploy_secrets_yml ||= YAML.load_file("config/deploy-secrets.yml")[fetch(:stage).to_s]
@deploy_secrets_yml.fetch(key.to_s, 'undefined') @deploy_secrets_yml.fetch(key.to_s, "undefined")
end end
set :rails_env, fetch(:stage) set :rails_env, fetch(:stage)
set :rvm1_ruby_version, '2.3.2' set :rvm1_ruby_version, "2.3.2"
set :application, 'consul' set :application, "consul"
set :full_app_name, deploysecret(:full_app_name) set :full_app_name, deploysecret(:full_app_name)
set :server_name, deploysecret(:server_name) set :server_name, deploysecret(:server_name)
set :repo_url, 'https://github.com/consul/consul.git' set :repo_url, "https://github.com/consul/consul.git"
set :revision, `git rev-parse --short #{fetch(:branch)}`.strip set :revision, `git rev-parse --short #{fetch(:branch)}`.strip
@@ -26,7 +26,7 @@ set :linked_dirs, %w{log tmp public/system public/assets public/ckeditor_assets}
set :keep_releases, 5 set :keep_releases, 5
set :local_user, ENV['USER'] set :local_user, ENV["USER"]
set :delayed_job_workers, 2 set :delayed_job_workers, 2
set :delayed_job_roles, :background set :delayed_job_roles, :background
@@ -41,15 +41,15 @@ set(:config_files, %w(
set :whenever_roles, -> { :app } set :whenever_roles, -> { :app }
namespace :deploy do namespace :deploy do
#before :starting, 'rvm1:install:rvm' # install/update RVM #before :starting, "rvm1:install:rvm" # install/update RVM
#before :starting, 'rvm1:install:ruby' # install Ruby and create gemset #before :starting, "rvm1:install:ruby" # install Ruby and create gemset
#before :starting, 'install_bundler_gem' # install bundler gem #before :starting, "install_bundler_gem" # install bundler gem
after :publishing, 'deploy:restart' after :publishing, "deploy:restart"
after :published, 'delayed_job:restart' after :published, "delayed_job:restart"
after :published, 'refresh_sitemap' after :published, "refresh_sitemap"
after :finishing, 'deploy:cleanup' after :finishing, "deploy:cleanup"
end end
task :install_bundler_gem do task :install_bundler_gem do
@@ -62,7 +62,7 @@ task :refresh_sitemap do
on roles(:app) do on roles(:app) do
within release_path do within release_path do
with rails_env: fetch(:rails_env) do with rails_env: fetch(:rails_env) do
execute :rake, 'sitemap:refresh:no_ping' execute :rake, "sitemap:refresh:no_ping"
end end
end end
end end

View File

@@ -1,7 +1,7 @@
set :deploy_to, deploysecret(:deploy_to) set :deploy_to, deploysecret(:deploy_to)
set :server_name, deploysecret(:server_name) set :server_name, deploysecret(:server_name)
set :db_server, deploysecret(:db_server) set :db_server, deploysecret(:db_server)
set :branch, ENV['branch'] || :master set :branch, ENV["branch"] || :master
set :ssh_options, port: deploysecret(:ssh_port) set :ssh_options, port: deploysecret(:ssh_port)
set :stage, :preproduction set :stage, :preproduction
set :rails_env, :preproduction set :rails_env, :preproduction

View File

@@ -1,7 +1,7 @@
set :deploy_to, deploysecret(:deploy_to) set :deploy_to, deploysecret(:deploy_to)
set :server_name, deploysecret(:server_name) set :server_name, deploysecret(:server_name)
set :db_server, deploysecret(:db_server) set :db_server, deploysecret(:db_server)
set :branch, ENV['branch'] || :master set :branch, ENV["branch"] || :master
set :ssh_options, port: deploysecret(:ssh_port) set :ssh_options, port: deploysecret(:ssh_port)
set :stage, :staging set :stage, :staging
set :rails_env, :staging set :rails_env, :staging

View File

@@ -1,5 +1,5 @@
# Load the Rails application. # Load the Rails application.
require File.expand_path('../application', __FILE__) require File.expand_path("../application", __FILE__)
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!

View File

@@ -15,7 +15,7 @@ Rails.application.configure do
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
config.action_mailer.asset_host = "http://localhost:3000" config.action_mailer.asset_host = "http://localhost:3000"
# Deliver emails to a development mailbox at /letter_opener # Deliver emails to a development mailbox at /letter_opener
@@ -49,7 +49,7 @@ Rails.application.configure do
config.after_initialize do config.after_initialize do
Bullet.enable = true Bullet.enable = true
Bullet.bullet_logger = true Bullet.bullet_logger = true
if ENV['BULLET'] if ENV["BULLET"]
Bullet.rails_logger = true Bullet.rails_logger = true
Bullet.add_footer = true Bullet.add_footer = true
end end

View File

@@ -22,7 +22,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@@ -38,8 +38,8 @@ Rails.application.configure do
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
@@ -58,7 +58,7 @@ Rails.application.configure do
config.cache_store = :dalli_store, { value_max_bytes: 2000000 } config.cache_store = :dalli_store, { value_max_bytes: 2000000 }
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com' # config.action_controller.asset_host = "http://assets.example.com"
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -70,12 +70,12 @@ Rails.application.configure do
# Uncomment the following block of code and add your SMTP service credentials # Uncomment the following block of code and add your SMTP service credentials
# config.action_mailer.delivery_method = :smtp # config.action_mailer.delivery_method = :smtp
# config.action_mailer.smtp_settings = { # config.action_mailer.smtp_settings = {
# address: 'smtp.example.com', # address: "smtp.example.com",
# port: 587, # port: 587,
# domain: 'example.com', # domain: "example.com",
# user_name: '<username>', # user_name: "<username>",
# password: '<password>', # password: "<password>",
# authentication: 'plain', # authentication: "plain",
# enable_starttls_auto: true } # enable_starttls_auto: true }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to

View File

@@ -22,7 +22,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@@ -38,8 +38,8 @@ Rails.application.configure do
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
@@ -58,7 +58,7 @@ Rails.application.configure do
config.cache_store = :dalli_store, { value_max_bytes: 2000000 } config.cache_store = :dalli_store, { value_max_bytes: 2000000 }
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com' # config.action_controller.asset_host = "http://assets.example.com"
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -70,12 +70,12 @@ Rails.application.configure do
# Uncomment the following block of code and add your SMTP service credentials # Uncomment the following block of code and add your SMTP service credentials
# config.action_mailer.delivery_method = :smtp # config.action_mailer.delivery_method = :smtp
# config.action_mailer.smtp_settings = { # config.action_mailer.smtp_settings = {
# address: 'smtp.example.com', # address: "smtp.example.com",
# port: 587, # port: 587,
# domain: 'example.com', # domain: "example.com",
# user_name: '<username>', # user_name: "<username>",
# password: '<password>', # password: "<password>",
# authentication: 'plain', # authentication: "plain",
# enable_starttls_auto: true } # enable_starttls_auto: true }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to

View File

@@ -22,7 +22,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@@ -38,8 +38,8 @@ Rails.application.configure do
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
@@ -58,7 +58,7 @@ Rails.application.configure do
config.cache_store = :dalli_store config.cache_store = :dalli_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com' # config.action_controller.asset_host = "http://assets.example.com"
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -70,12 +70,12 @@ Rails.application.configure do
# Uncomment the following block of code and add your SMTP service credentials # Uncomment the following block of code and add your SMTP service credentials
# config.action_mailer.delivery_method = :smtp # config.action_mailer.delivery_method = :smtp
# config.action_mailer.smtp_settings = { # config.action_mailer.smtp_settings = {
# address: 'smtp.example.com', # address: "smtp.example.com",
# port: 587, # port: 587,
# domain: 'example.com', # domain: "example.com",
# user_name: '<username>', # user_name: "<username>",
# password: '<password>', # password: "<password>",
# authentication: 'plain', # authentication: "plain",
# enable_starttls_auto: true } # enable_starttls_auto: true }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to

View File

@@ -19,7 +19,7 @@ Rails.application.configure do
# Configure static file server for tests with Cache-Control for performance. # Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600' config.static_cache_control = "public, max-age=3600"
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
@@ -36,9 +36,9 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = { config.action_mailer.default_url_options = {
host: 'test' host: "test"
} }
config.action_mailer.asset_host = 'http://consul.test' config.action_mailer.asset_host = "http://consul.test"
# Randomize the order test cases are executed. # Randomize the order test cases are executed.
config.active_support.test_order = :random config.active_support.test_order = :random
@@ -54,7 +54,7 @@ Rails.application.configure do
config.after_initialize do config.after_initialize do
Bullet.enable = true Bullet.enable = true
Bullet.bullet_logger = true Bullet.bullet_logger = true
if ENV['BULLET'] if ENV["BULLET"]
Bullet.raise = true # raise an error if n+1 query occurs Bullet.raise = true # raise an error if n+1 query occurs
end end
end end

View File

@@ -108,95 +108,95 @@ search:
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}' # - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
# - '{devise,simple_form}.*' # - '{devise,simple_form}.*'
ignore_missing: ignore_missing:
- 'unauthorized.*' - "unauthorized.*"
- 'activerecord.models.proposal' - "activerecord.models.proposal"
- 'activerecord.models.spending_proposal' - "activerecord.models.spending_proposal"
- 'activerecord.errors.models.proposal_notification.*' - "activerecord.errors.models.proposal_notification.*"
- 'activerecord.errors.models.direct_message.*' - "activerecord.errors.models.direct_message.*"
- 'errors.messages.blank' - "errors.messages.blank"
- 'errors.messages.taken' - "errors.messages.taken"
- 'devise.failure.invalid' - "devise.failure.invalid"
- 'devise.registrations.destroyed' - "devise.registrations.destroyed"
- 'devise.password_expired.*' - "devise.password_expired.*"
## Consider these keys used: ## Consider these keys used:
ignore_unused: ignore_unused:
- 'budgets.phase.*' - "budgets.phase.*"
- 'budgets.investments.index.orders.*' - "budgets.investments.index.orders.*"
- 'budgets.index.section_header.*' - "budgets.index.section_header.*"
- 'activerecord.*' - "activerecord.*"
- 'activemodel.*' - "activemodel.*"
- 'date.order' - "date.order"
- 'unauthorized.*' - "unauthorized.*"
- 'admin.officials.level_*' - "admin.officials.level_*"
- 'admin.comments.index.filter*' - "admin.comments.index.filter*"
- 'admin.banners.index.filters.*' - "admin.banners.index.filters.*"
- 'admin.debates.index.filter*' - "admin.debates.index.filter*"
- 'admin.hidden_proposals.index.filter*' - "admin.hidden_proposals.index.filter*"
- 'admin.proposal_notifications.index.filter*' - "admin.proposal_notifications.index.filter*"
- 'admin.budgets.index.filter*' - "admin.budgets.index.filter*"
- 'admin.budget_investments.index.filter*' - "admin.budget_investments.index.filter*"
- 'admin.spending_proposals.index.filter*' - "admin.spending_proposals.index.filter*"
- 'admin.organizations.index.filter*' - "admin.organizations.index.filter*"
- 'admin.hidden_users.index.filter*' - "admin.hidden_users.index.filter*"
- 'admin.hidden_budget_investments.index.filter*' - "admin.hidden_budget_investments.index.filter*"
- 'admin.activity.show.filter*' - "admin.activity.show.filter*"
- 'admin.legislation.processes.index.filter*' - "admin.legislation.processes.index.filter*"
- 'admin.legislation.processes.*.submit_button' - "admin.legislation.processes.*.submit_button"
- 'admin.legislation.processes.proposals.orders.*' - "admin.legislation.processes.proposals.orders.*"
- 'admin.legislation.processes.proposals.select_order' - "admin.legislation.processes.proposals.select_order"
- 'admin.legislation.draft_versions.*.submit_button' - "admin.legislation.draft_versions.*.submit_button"
- 'admin.legislation.questions.*.submit_button' - "admin.legislation.questions.*.submit_button"
- 'admin.comments.index.hidden_*' - "admin.comments.index.hidden_*"
- 'admin.settings.index.features.*' - "admin.settings.index.features.*"
- 'admin.polls.*.submit_button' - "admin.polls.*.submit_button"
- 'admin.booths.*.submit_button' - "admin.booths.*.submit_button"
- 'admin.admin_notifications.*.submit_button' - "admin.admin_notifications.*.submit_button"
- 'admin.homepage.*' - "admin.homepage.*"
- 'moderation.comments.index.filter*' - "moderation.comments.index.filter*"
- 'moderation.comments.index.order*' - "moderation.comments.index.order*"
- 'moderation.debates.index.filter*' - "moderation.debates.index.filter*"
- 'moderation.proposals.index.filter*' - "moderation.proposals.index.filter*"
- 'moderation.proposals.index.order*' - "moderation.proposals.index.order*"
- 'moderation.debates.index.filter*' - "moderation.debates.index.filter*"
- 'moderation.debates.index.order*' - "moderation.debates.index.order*"
- 'moderation.budget_investments.index.filter*' - "moderation.budget_investments.index.filter*"
- 'moderation.budget_investments.index.order*' - "moderation.budget_investments.index.order*"
- 'moderation.proposal_notifications.index.filter*' - "moderation.proposal_notifications.index.filter*"
- 'moderation.proposal_notifications.index.order*' - "moderation.proposal_notifications.index.order*"
- 'valuation.spending_proposals.index.filter*' - "valuation.spending_proposals.index.filter*"
- 'valuation.budgets.index.filter*' - "valuation.budgets.index.filter*"
- 'valuation.budget_investments.index.filter*' - "valuation.budget_investments.index.filter*"
- 'users.show.filters.*' - "users.show.filters.*"
- 'polls.index.filters.*' - "polls.index.filters.*"
- 'polls.index.section_header.*' - "polls.index.section_header.*"
- 'polls.index.orders.*' - "polls.index.orders.*"
- 'debates.index.select_order' - "debates.index.select_order"
- 'debates.index.orders.*' - "debates.index.orders.*"
- 'debates.index.section_header.*' - "debates.index.section_header.*"
- 'proposals.index.select_order' - "proposals.index.select_order"
- 'proposals.index.orders.*' - "proposals.index.orders.*"
- 'proposals.index.section_header.*' - "proposals.index.section_header.*"
- 'spending_proposals.index.search_form.*' - "spending_proposals.index.search_form.*"
- '*.index.search_form.*' - "*.index.search_form.*"
- 'notifications.notification.action.*' - "notifications.notification.action.*"
- 'legislation.processes.index.filter*' - "legislation.processes.index.filter*"
- 'legislation.processes.index.section_header.*' - "legislation.processes.index.section_header.*"
- 'legislation.processes.proposals.filters.*' - "legislation.processes.proposals.filters.*"
- 'helpers.page_entries_info.*' # kaminari - "helpers.page_entries_info.*" # kaminari
- 'views.pagination.*' # kaminari - "views.pagination.*" # kaminari
- 'shared.suggest.*' - "shared.suggest.*"
- 'invisible_captcha.*' - "invisible_captcha.*"
- 'admin.site_customization.pages.page.status_*' - "admin.site_customization.pages.page.status_*"
- 'admin.legislation.processes.process.*' - "admin.legislation.processes.process.*"
- 'legislation.processes.index.*' - "legislation.processes.index.*"
- 'votes.budget_investments.different_heading_assigned*' - "votes.budget_investments.different_heading_assigned*"
- '*.form.map_skip_checkbox' - "*.form.map_skip_checkbox"
# - '{devise,kaminari,will_paginate}.*' # - "{devise,kaminari,will_paginate}.*"
# - 'simple_form.{yes,no}' # - "simple_form.{yes,no}"
# - 'simple_form.{placeholders,hints,labels}.*' # - "simple_form.{placeholders,hints,labels}.*"
# - 'simple_form.{error_notification,required}.:' # - "simple_form.{error_notification,required}.:"
## Exclude these keys from the `i18n-tasks eq-base' report: ## Exclude these keys from the `i18n-tasks eq-base" report:
# ignore_eq_base: # ignore_eq_base:
# all: # all:
# - common.ok # - common.ok

View File

@@ -9,7 +9,7 @@ module ActsAsTaggableOn
where(%{taggings.tag_id in (?) and where(%{taggings.tag_id in (?) and
(taggings.taggable_type = 'Debate' and taggings.taggable_id in (?)) or (taggings.taggable_type = 'Debate' and taggings.taggable_id in (?)) or
(taggings.taggable_type = 'Proposal' and taggings.taggable_id in (?))}, (taggings.taggable_type = 'Proposal' and taggings.taggable_id in (?))},
Tag.where('kind IS NULL or kind = ?', 'category').pluck(:id), Tag.where("kind IS NULL or kind = ?", "category").pluck(:id),
Debate.public_for_api.pluck(:id), Debate.public_for_api.pluck(:id),
Proposal.public_for_api.pluck(:id)) Proposal.public_for_api.pluck(:id))
end end
@@ -38,9 +38,9 @@ module ActsAsTaggableOn
include Graphqlable include Graphqlable
scope :public_for_api, -> do scope :public_for_api, -> do
where('(tags.kind IS NULL or tags.kind = ?) and tags.id in (?)', where("(tags.kind IS NULL or tags.kind = ?) and tags.id in (?)",
'category', "category",
Tagging.public_for_api.pluck('DISTINCT taggings.tag_id')) Tagging.public_for_api.pluck("DISTINCT taggings.tag_id"))
end end
include PgSearch include PgSearch
@@ -64,7 +64,7 @@ module ActsAsTaggableOn
end end
def recalculate_custom_counter_for(taggable_type) def recalculate_custom_counter_for(taggable_type)
visible_taggables = taggable_type.constantize.includes(:taggings).where('taggings.taggable_type' => taggable_type, 'taggings.tag_id' => id) visible_taggables = taggable_type.constantize.includes(:taggings).where("taggings.taggable_type" => taggable_type, "taggings.tag_id" => id)
update(custom_counter_field_name_for(taggable_type) => visible_taggables.count) update(custom_counter_field_name_for(taggable_type) => visible_taggables.count)
end end
@@ -74,7 +74,7 @@ module ActsAsTaggableOn
end end
def self.spending_proposal_tags def self.spending_proposal_tags
ActsAsTaggableOn::Tag.where('taggings.taggable_type' => 'SpendingProposal').includes(:taggings).order(:name).uniq ActsAsTaggableOn::Tag.where("taggings.taggable_type" => "SpendingProposal").includes(:taggings).order(:name).uniq
end end
def self.graphql_field_name def self.graphql_field_name
@@ -86,7 +86,7 @@ module ActsAsTaggableOn
end end
def self.graphql_type_name def self.graphql_type_name
'Tag' "Tag"
end end
private private

View File

@@ -1 +1 @@
require 'age' require "age"

View File

@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path # Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path

View File

@@ -8,6 +8,6 @@ Delayed::Worker.sleep_delay = 2
Delayed::Worker.max_attempts = 3 Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = 1500.minutes Delayed::Worker.max_run_time = 1500.minutes
Delayed::Worker.read_ahead = 10 Delayed::Worker.read_ahead = 10
Delayed::Worker.default_queue_name = 'default' Delayed::Worker.default_queue_name = "default"
Delayed::Worker.raise_signal_exceptions = :term Delayed::Worker.raise_signal_exceptions = :term
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log')) Delayed::Worker.logger = Logger.new(File.join(Rails.root, "log", "delayed_job.log"))

View File

@@ -12,20 +12,20 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer, # Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class # note that it will be overwritten if you use your own mailer class
# with default "from" parameter. # with default "from" parameter.
if Rails.env.test? || !ActiveRecord::Base.connection.table_exists?('settings') if Rails.env.test? || !ActiveRecord::Base.connection.table_exists?("settings")
config.mailer_sender = "noreply@consul.dev" config.mailer_sender = "noreply@consul.dev"
else else
config.mailer_sender = "'#{Setting['mailer_from_name']}' <#{Setting['mailer_from_address']}>" config.mailer_sender = "'#{Setting['mailer_from_name']}' <#{Setting['mailer_from_address']}>"
end end
# Configure the class responsible to send e-mails. # Configure the class responsible to send e-mails.
config.mailer = 'DeviseMailer' config.mailer = "DeviseMailer"
# ==> ORM configuration # ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and # Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be # :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems. # available as additional gems.
require 'devise/orm/active_record' require "devise/orm/active_record"
# ==> Configuration for any authentication mechanism # ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is # Configure which keys are used when authenticating a user. The default is
@@ -244,7 +244,7 @@ Devise.setup do |config|
# up on your models and hooks. # up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
config.omniauth :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret config.omniauth :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret
config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret, scope: 'email', info_fields: 'email,name,verified' config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret, scope: "email", info_fields: "email,name,verified"
config.omniauth :google_oauth2, Rails.application.secrets.google_oauth2_key, Rails.application.secrets.google_oauth2_secret config.omniauth :google_oauth2, Rails.application.secrets.google_oauth2_key, Rails.application.secrets.google_oauth2_secret
# ==> Warden configuration # ==> Warden configuration

View File

@@ -1,4 +1,4 @@
if ActiveRecord::Base.connection.tables.any? if ActiveRecord::Base.connection.tables.any?
api_config = YAML.load_file('./config/api.yml') api_config = YAML.load_file("./config/api.yml")
API_TYPE_DEFINITIONS = GraphQL::ApiTypesCreator::parse_api_config_file(api_config) API_TYPE_DEFINITIONS = GraphQL::ApiTypesCreator::parse_api_config_file(api_config)
end end

View File

@@ -1,5 +1,5 @@
require 'i18n/exceptions' require "i18n/exceptions"
require 'action_view/helpers/tag_helper' require "action_view/helpers/tag_helper"
module ActionView module ActionView
module Helpers module Helpers

View File

@@ -17,5 +17,5 @@
ActiveSupport::Inflector.inflections(:en) do |inflect| ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.plural(/^(\d+)$/i, '\1') inflect.plural(/^(\d+)$/i, '\1')
inflect.irregular 'organización', 'organizaciones' inflect.irregular "organización", "organizaciones"
end end

View File

@@ -1,4 +1,4 @@
require 'rollbar/rails' require "rollbar/rails"
Rollbar.configure do |config| Rollbar.configure do |config|
# Without configuration, Rollbar is enabled in all environments. # Without configuration, Rollbar is enabled in all environments.
# To disable in specific environments, set config.enabled=false. # To disable in specific environments, set config.enabled=false.

View File

@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_consul_session' Rails.application.config.session_store :cookie_store, key: "_consul_session"

View File

@@ -13,23 +13,23 @@ ActsAsVotable::Vote.class_eval do
end end
def self.for_debates(debates) def self.for_debates(debates)
where(votable_type: 'Debate', votable_id: debates) where(votable_type: "Debate", votable_id: debates)
end end
def self.for_proposals(proposals) def self.for_proposals(proposals)
where(votable_type: 'Proposal', votable_id: proposals) where(votable_type: "Proposal", votable_id: proposals)
end end
def self.for_legislation_proposals(proposals) def self.for_legislation_proposals(proposals)
where(votable_type: 'Legislation::Proposal', votable_id: proposals) where(votable_type: "Legislation::Proposal", votable_id: proposals)
end end
def self.for_spending_proposals(spending_proposals) def self.for_spending_proposals(spending_proposals)
where(votable_type: 'SpendingProposal', votable_id: spending_proposals) where(votable_type: "SpendingProposal", votable_id: spending_proposals)
end end
def self.for_budget_investments(budget_investments=Budget::Investment.all) def self.for_budget_investments(budget_investments=Budget::Investment.all)
where(votable_type: 'Budget::Investment', votable_id: budget_investments) where(votable_type: "Budget::Investment", votable_id: budget_investments)
end end
def value def value

View File

@@ -1,5 +1,5 @@
--- ---
app_root: '.' app_root: "."
allowed_ips: allowed_ips:
- 127.0.0.1 - 127.0.0.1
- x.x.x.x - x.x.x.x
@@ -7,6 +7,6 @@ allowed_ips:
allowed_paths: allowed_paths:
- your/custom/route - your/custom/route
reason: 'Website down for maintenance' reason: "Website down for maintenance"
response_code: 503 response_code: 503
retry_after: 3600 retry_after: 3600

View File

@@ -1,10 +1,10 @@
Rails.application.routes.draw do Rails.application.routes.draw do
mount Ckeditor::Engine => '/ckeditor' mount Ckeditor::Engine => "/ckeditor"
if Rails.env.development? || Rails.env.staging? if Rails.env.development? || Rails.env.staging?
get '/sandbox' => 'sandbox#index' get "/sandbox" => "sandbox#index"
get '/sandbox/*template' => 'sandbox#show' get "/sandbox/*template" => "sandbox#show"
end end
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development? mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
@@ -33,9 +33,9 @@ Rails.application.routes.draw do
draw :valuation draw :valuation
draw :verification draw :verification
root 'welcome#index' root "welcome#index"
get '/welcome', to: 'welcome#welcome' get "/welcome", to: "welcome#welcome"
get '/consul.json', to: "installation#details" get "/consul.json", to: "installation#details"
resources :stats, only: [:index] resources :stats, only: [:index]
resources :images, only: [:destroy] resources :images, only: [:destroy]
@@ -43,10 +43,10 @@ Rails.application.routes.draw do
resources :follows, only: [:create, :destroy] resources :follows, only: [:create, :destroy]
# More info pages # More info pages
get 'help', to: 'pages#show', id: 'help/index', as: 'help' get "help", to: "pages#show", id: "help/index", as: "help"
get 'help/how-to-use', to: 'pages#show', id: 'help/how_to_use/index', as: 'how_to_use' get "help/how-to-use", to: "pages#show", id: "help/how_to_use/index", as: "how_to_use"
get "help/faq", to: "pages#show", id: "faq", as: "faq" get "help/faq", to: "pages#show", id: "faq", as: "faq"
# Static pages # Static pages
resources :pages, path: '/', only: [:show] resources :pages, path: "/", only: [:show]
end end

View File

@@ -67,7 +67,7 @@ namespace :admin do
end end
resources :budget_investments, only: [:index, :show, :edit, :update] do resources :budget_investments, only: [:index, :show, :edit, :update] do
resources :milestones, controller: 'budget_investment_milestones' resources :milestones, controller: "budget_investment_milestones"
resources :progress_bars, except: :show, controller: "budget_investment_progress_bars" resources :progress_bars, except: :show, controller: "budget_investment_progress_bars"
member { patch :toggle_selection } member { patch :toggle_selection }
end end
@@ -152,12 +152,12 @@ namespace :admin do
end end
resources :questions, shallow: true do resources :questions, shallow: true do
resources :answers, except: [:index, :destroy], controller: 'questions/answers' do resources :answers, except: [:index, :destroy], controller: "questions/answers" do
resources :images, controller: 'questions/answers/images' resources :images, controller: "questions/answers/images"
resources :videos, controller: 'questions/answers/videos' resources :videos, controller: "questions/answers/videos"
get :documents, to: 'questions/answers#documents' get :documents, to: "questions/answers#documents"
end end
post '/answers/order_answers', to: 'questions/answers#order_answers' post "/answers/order_answers", to: "questions/answers#order_answers"
end end
resource :active_polls, only: [:create, :edit, :update] resource :active_polls, only: [:create, :edit, :update]
@@ -224,9 +224,9 @@ namespace :admin do
end end
resources :images, only: [:index, :update, :destroy] resources :images, only: [:index, :update, :destroy]
resources :content_blocks, except: [:show] resources :content_blocks, except: [:show]
delete '/heading_content_blocks/:id', to: 'content_blocks#delete_heading_content_block', as: 'delete_heading_content_block' delete "/heading_content_blocks/:id", to: "content_blocks#delete_heading_content_block", as: "delete_heading_content_block"
get '/edit_heading_content_blocks/:id', to: 'content_blocks#edit_heading_content_block', as: 'edit_heading_content_block' get "/edit_heading_content_blocks/:id", to: "content_blocks#edit_heading_content_block", as: "edit_heading_content_block"
put '/update_heading_content_blocks/:id', to: 'content_blocks#update_heading_content_block', as: 'update_heading_content_block' put "/update_heading_content_blocks/:id", to: "content_blocks#update_heading_content_block", as: "update_heading_content_block"
resources :information_texts, only: [:index] do resources :information_texts, only: [:index] do
post :update, on: :collection post :update, on: :collection
end end

View File

@@ -15,14 +15,14 @@ resources :budgets, only: [:show, :index] do
end end
resource :results, only: :show, controller: "budgets/results" resource :results, only: :show, controller: "budgets/results"
resource :executions, only: :show, controller: 'budgets/executions' resource :executions, only: :show, controller: "budgets/executions"
end end
scope '/participatory_budget' do scope "/participatory_budget" do
resources :spending_proposals, only: [:index, :new, :create, :show, :destroy], path: 'investment_projects' do resources :spending_proposals, only: [:index, :new, :create, :show, :destroy], path: "investment_projects" do
post :vote, on: :member post :vote, on: :member
end end
end end
get 'investments/:id/json_data', action: :json_data, controller: 'budgets/investments' get "investments/:id/json_data", action: :json_data, controller: "budgets/investments"
get '/budgets/:budget_id/investments/:id/json_data', action: :json_data, controller: 'budgets/investments' get "/budgets/:budget_id/investments/:id/json_data", action: :json_data, controller: "budgets/investments"

View File

@@ -10,6 +10,6 @@ resources :debates do
collection do collection do
get :map get :map
get :suggest get :suggest
put 'recommendations/disable', only: :index, controller: 'debates', action: :disable_recommendations put "recommendations/disable", only: :index, controller: "debates", action: :disable_recommendations
end end
end end

View File

@@ -1,27 +1,27 @@
devise_for :users, controllers: { devise_for :users, controllers: {
registrations: 'users/registrations', registrations: "users/registrations",
sessions: 'users/sessions', sessions: "users/sessions",
confirmations: 'users/confirmations', confirmations: "users/confirmations",
omniauth_callbacks: 'users/omniauth_callbacks' omniauth_callbacks: "users/omniauth_callbacks"
} }
devise_scope :user do devise_scope :user do
patch '/user/confirmation', to: 'users/confirmations#update', as: :update_user_confirmation patch "/user/confirmation", to: "users/confirmations#update", as: :update_user_confirmation
get '/user/registrations/check_username', to: 'users/registrations#check_username' get "/user/registrations/check_username", to: "users/registrations#check_username"
get 'users/sign_up/success', to: 'users/registrations#success' get "users/sign_up/success", to: "users/registrations#success"
get 'users/registrations/delete_form', to: 'users/registrations#delete_form' get "users/registrations/delete_form", to: "users/registrations#delete_form"
delete 'users/registrations', to: 'users/registrations#delete' delete "users/registrations", to: "users/registrations#delete"
get :finish_signup, to: 'users/registrations#finish_signup' get :finish_signup, to: "users/registrations#finish_signup"
patch :do_finish_signup, to: 'users/registrations#do_finish_signup' patch :do_finish_signup, to: "users/registrations#do_finish_signup"
end end
devise_for :organizations, class_name: 'User', devise_for :organizations, class_name: "User",
controllers: { controllers: {
registrations: 'organizations/registrations', registrations: "organizations/registrations",
sessions: 'devise/sessions', sessions: "devise/sessions",
}, },
skip: [:omniauth_callbacks] skip: [:omniauth_callbacks]
devise_scope :organization do devise_scope :organization do
get 'organizations/sign_up/success', to: 'organizations/registrations#success' get "organizations/sign_up/success", to: "organizations/registrations#success"
end end

View File

@@ -1,3 +1,3 @@
get '/graphql', to: 'graphql#query' get "/graphql", to: "graphql#query"
post '/graphql', to: 'graphql#query' post "/graphql", to: "graphql#query"
mount GraphiQL::Rails::Engine, at: '/graphiql', graphql_path: '/graphql' mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"

View File

@@ -24,7 +24,7 @@ namespace :management do
end end
resource :session, only: [:create, :destroy] resource :session, only: [:create, :destroy]
get 'sign_in', to: 'sessions#create', as: :sign_in get "sign_in", to: "sessions#create", as: :sign_in
resources :proposals, only: [:index, :new, :create, :show] do resources :proposals, only: [:index, :new, :create, :show] do
post :vote, on: :member post :vote, on: :member
@@ -43,7 +43,7 @@ namespace :management do
get :print_investments get :print_investments
end end
resources :investments, only: [:index, :new, :create, :show, :destroy], controller: 'budgets/investments' do resources :investments, only: [:index, :new, :create, :show, :destroy], controller: "budgets/investments" do
post :vote, on: :member post :vote, on: :member
get :print, on: :collection get :print, on: :collection
end end

View File

@@ -28,7 +28,7 @@ namespace :moderation do
put :moderate, on: :collection put :moderate, on: :collection
end end
resources :budget_investments, only: :index, controller: 'budgets/investments' do resources :budget_investments, only: :index, controller: "budgets/investments" do
put :hide, on: :member put :hide, on: :member
put :moderate, on: :collection put :moderate, on: :collection
end end

View File

@@ -4,7 +4,7 @@ resources :polls, only: [:show, :index] do
get :results get :results
end end
resources :questions, controller: 'polls/questions', shallow: true do resources :questions, controller: "polls/questions", shallow: true do
post :answer, on: :member post :answer, on: :member
end end
end end

View File

@@ -13,6 +13,6 @@ resources :proposals do
get :map get :map
get :suggest get :suggest
get :summary get :summary
put 'recommendations/disable', only: :index, controller: 'proposals', action: :disable_recommendations put "recommendations/disable", only: :index, controller: "proposals", action: :disable_recommendations
end end
end end

View File

@@ -23,10 +23,10 @@ every 1.minute do
command "date > ~/cron-test.txt" command "date > ~/cron-test.txt"
end end
every 1.day, at: '5:00 am' do every 1.day, at: "5:00 am" do
rake "-s sitemap:refresh" rake "-s sitemap:refresh"
end end
every 1.day, at: '3:00 am', roles: [:cron] do every 1.day, at: "3:00 am", roles: [:cron] do
rake "votes:reset_hot_score" rake "votes:reset_hot_score"
end end

View File

@@ -2,7 +2,7 @@
class SitemapGenerator::FileAdapter class SitemapGenerator::FileAdapter
def gzip(stream, data); stream.write(data); stream.close end def gzip(stream, data); stream.write(data); stream.close end
end end
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, extension: '.xml') SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, extension: ".xml")
# default host # default host
SitemapGenerator::Sitemap.verbose = false if Rails.env.test? SitemapGenerator::Sitemap.verbose = false if Rails.env.test?

View File

@@ -17,7 +17,7 @@ section "Creating Spending Proposals" do
feasible: feasible, feasible: feasible,
feasible_explanation: feasible_explanation, feasible_explanation: feasible_explanation,
valuation_finished: valuation_finished, valuation_finished: valuation_finished,
tag_list: tags.sample(3).join(','), tag_list: tags.sample(3).join(","),
price: rand(1000000), price: rand(1000000),
terms_of_service: "1") terms_of_service: "1")
end end

View File

@@ -1,9 +1,9 @@
require 'http' require "http"
API_ENDPOINT = 'https://decide.madrid.es/graphql'.freeze API_ENDPOINT = "https://decide.madrid.es/graphql".freeze
def make_request(query_string) def make_request(query_string)
HTTP.headers('User-Agent' => 'Mozilla/5.0', accept: 'application/json') HTTP.headers("User-Agent" => "Mozilla/5.0", accept: "application/json")
.get( .get(
API_ENDPOINT, API_ENDPOINT,
params: { query: query_string.delete("\n").delete(" ") } params: { query: query_string.delete("\n").delete(" ") }

View File

@@ -1,9 +1,9 @@
require 'http' require "http"
API_ENDPOINT = 'https://decide.madrid.es/graphql'.freeze API_ENDPOINT = "https://decide.madrid.es/graphql".freeze
def make_request(query_string) def make_request(query_string)
HTTP.headers('User-Agent' => 'Mozilla/5.0', accept: 'application/json') HTTP.headers("User-Agent" => "Mozilla/5.0", accept: "application/json")
.get( .get(
API_ENDPOINT, API_ENDPOINT,
params: { query: query_string.delete("\n").delete(" ") } params: { query: query_string.delete("\n").delete(" ") }
@@ -48,15 +48,15 @@ loop do
response = make_request(query) response = make_request(query)
response_hash = JSON.parse(response.body) response_hash = JSON.parse(response.body)
page_info = response_hash['data']['proposals']['pageInfo'] page_info = response_hash["data"]["proposals"]["pageInfo"]
has_next_page = page_info['hasNextPage'] has_next_page = page_info["hasNextPage"]
next_cursor = page_info['endCursor'] next_cursor = page_info["endCursor"]
proposal_edges = response_hash['data']['proposals']['edges'] proposal_edges = response_hash["data"]["proposals"]["edges"]
puts "\tHTTP code: #{response.code}" puts "\tHTTP code: #{response.code}"
proposal_edges.each do |edge| proposal_edges.each do |edge|
proposals << edge['node'] proposals << edge["node"]
end end
page_number += 1 page_number += 1

View File

@@ -1,4 +1,4 @@
version: '3' version: "3"
services: services:
# service configuration for our database # service configuration for our database
database: database:
@@ -17,7 +17,7 @@ services:
# use the Dockerfile next to this file # use the Dockerfile next to this file
build: . build: .
entrypoint: /usr/local/bin/entrypoint.sh entrypoint: /usr/local/bin/entrypoint.sh
command: bundle exec rails s -p 3000 -b '0.0.0.0' command: bundle exec rails s -p 3000 -b "0.0.0.0"
working_dir: /var/www/consul working_dir: /var/www/consul
# rely on the RAILS_ENV value of the host machine # rely on the RAILS_ENV value of the host machine

View File

@@ -1,5 +1,5 @@
namespace :deploy do namespace :deploy do
desc 'Restart Unicorn' desc "Restart Unicorn"
task :restart do task :restart do
on roles(:app) do on roles(:app) do
execute "kill -QUIT `cat /home/deploy/consul/pids/unicorn.pid`; true" execute "kill -QUIT `cat /home/deploy/consul/pids/unicorn.pid`; true"

View File

@@ -4,7 +4,7 @@ class CommentTree
attr_accessor :root_comments, :comments, :commentable, :page, :order attr_accessor :root_comments, :comments, :commentable, :page, :order
def initialize(commentable, page, order = 'confidence_score', valuations: false) def initialize(commentable, page, order = "confidence_score", valuations: false)
@commentable = commentable @commentable = commentable
@page = page @page = page
@order = order @order = order
@@ -17,7 +17,7 @@ class CommentTree
end end
def base_comments def base_comments
if @valuations && commentable.respond_to?('valuations') if @valuations && commentable.respond_to?("valuations")
commentable.valuations commentable.valuations
else else
commentable.comments commentable.comments

View File

@@ -2,7 +2,7 @@ module DocumentParser
def get_document_number_variants(document_type, document_number) def get_document_number_variants(document_type, document_number)
# Delete all non-alphanumerics # Delete all non-alphanumerics
document_number = document_number.to_s.gsub(/[^0-9A-Za-z]/i, '') document_number = document_number.to_s.gsub(/[^0-9A-Za-z]/i, "")
variants = [] variants = []
if dni?(document_type) if dni?(document_type)
@@ -34,7 +34,7 @@ module DocumentParser
# ['1234', '01234', '001234', '0001234'] # ['1234', '01234', '001234', '0001234']
def get_number_variants_with_leading_zeroes_from(document_number, digits = 8) def get_number_variants_with_leading_zeroes_from(document_number, digits = 8)
document_number = document_number.to_s.last(digits) # Keep only the last x digits document_number = document_number.to_s.last(digits) # Keep only the last x digits
document_number = document_number.gsub(/^0+/, '') # Removes leading zeros document_number = document_number.gsub(/^0+/, "") # Removes leading zeros
variants = [] variants = []
variants << document_number if document_number.present? variants << document_number if document_number.present?

View File

@@ -1,4 +1,4 @@
require 'graphql' require "graphql"
module GraphQL module GraphQL
class ApiTypesCreator class ApiTypesCreator
@@ -65,7 +65,7 @@ module GraphQL
model = api_type_model.constantize model = api_type_model.constantize
fields = {} fields = {}
api_type_info['fields'].each do |field_name, field_type| api_type_info["fields"].each do |field_name, field_type|
if field_type.is_a?(Array) # paginated association if field_type.is_a?(Array) # paginated association
fields[field_name.to_sym] = [field_type.first.constantize] fields[field_name.to_sym] = [field_type.first.constantize]
elsif SCALAR_TYPES[field_type.to_sym] elsif SCALAR_TYPES[field_type.to_sym]

View File

@@ -1,20 +1,20 @@
require 'graphql' require "graphql"
module GraphQL module GraphQL
class QueryTypeCreator class QueryTypeCreator
def self.create(api_types) def self.create(api_types)
GraphQL::ObjectType.define do GraphQL::ObjectType.define do
name 'QueryType' name "QueryType"
description 'The root query for the schema' description "The root query for the schema"
api_types.each do |model, created_type| api_types.each do |model, created_type|
if created_type.fields['id'] if created_type.fields["id"]
field model.graphql_field_name do field model.graphql_field_name do
type created_type type created_type
description model.graphql_field_description description model.graphql_field_description
argument :id, !types.ID argument :id, !types.ID
resolve ->(object, arguments, context) { model.public_for_api.find_by(id: arguments['id'])} resolve ->(object, arguments, context) { model.public_for_api.find_by(id: arguments["id"])}
end end
end end

View File

@@ -1,7 +1,7 @@
class MergedCommentTree < CommentTree class MergedCommentTree < CommentTree
attr_accessor :commentables, :array_order attr_accessor :commentables, :array_order
def initialize(commentables, page, order = 'confidence_score') def initialize(commentables, page, order = "confidence_score")
@commentables = commentables @commentables = commentables
@commentable = commentables.first @commentable = commentables.first
@page = page @page = page

View File

@@ -9,20 +9,20 @@ class MigrateSpendingProposalsToInvestments
if sp.geozone_id.present? if sp.geozone_id.present?
group = budget.groups.find_or_create_by!(name: "Barrios") group = budget.groups.find_or_create_by!(name: "Barrios")
heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000, heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000,
latitude: '40.416775', longitude: '-3.703790') latitude: "40.416775", longitude: "-3.703790")
else else
group = budget.groups.find_or_create_by!(name: "Toda la ciudad") group = budget.groups.find_or_create_by!(name: "Toda la ciudad")
heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000, heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000,
latitude: '40.416775', longitude: '-3.703790') latitude: "40.416775", longitude: "-3.703790")
end end
feasibility = case sp.feasible feasibility = case sp.feasible
when FalseClass when FalseClass
'unfeasible' "unfeasible"
when TrueClass when TrueClass
'feasible' "feasible"
else else
'undecided' "undecided"
end end
investment = Budget::Investment.create!( investment = Budget::Investment.create!(
@@ -49,14 +49,14 @@ class MigrateSpendingProposalsToInvestments
investment.valuators = sp.valuation_assignments.map(&:valuator) investment.valuators = sp.valuation_assignments.map(&:valuator)
votes = ActsAsVotable::Vote.where(votable_type: 'SpendingProposal', votable_id: sp.id) votes = ActsAsVotable::Vote.where(votable_type: "SpendingProposal", votable_id: sp.id)
votes.each {|v| investment.vote_by(voter: v.voter, vote: 'yes') } votes.each {|v| investment.vote_by(voter: v.voter, vote: "yes") }
# Spending proposals are not commentable in Consul so we can not test this # Spending proposals are not commentable in Consul so we can not test this
# #
# Comment.where(commentable_type: 'SpendingProposal', commentable_id: sp.id).update_all( # Comment.where(commentable_type: "SpendingProposal", commentable_id: sp.id).update_all(
# commentable_type: 'Budget::Investment', commentable_id: investment.id # commentable_type: "Budget::Investment", commentable_id: investment.id
# ) # )
# Budget::Investment.reset_counters(investment.id, :comments) # Budget::Investment.reset_counters(investment.id, :comments)

View File

@@ -4,7 +4,7 @@ module ScoreCalculator
return 0 unless resource.created_at return 0 unless resource.created_at
period = [ period = [
Setting['hot_score_period_in_days'].to_i, Setting["hot_score_period_in_days"].to_i,
((Time.current - resource.created_at) / 1.day).ceil ((Time.current - resource.created_at) / 1.day).ceil
].min ].min

View File

@@ -1,4 +1,4 @@
require 'open-uri' require "open-uri"
class SMSApi class SMSApi
attr_accessor :client attr_accessor :client

View File

@@ -5,9 +5,9 @@ namespace :homepage do
%w(proposals debates processes).each do |kind| %w(proposals debates processes).each do |kind|
Widget::Feed.create(kind: kind) Widget::Feed.create(kind: kind)
Setting['feature.homepage.widgets.feeds.proposals'] = true Setting["feature.homepage.widgets.feeds.proposals"] = true
Setting['feature.homepage.widgets.feeds.debates'] = true Setting["feature.homepage.widgets.feeds.debates"] = true
Setting['feature.homepage.widgets.feeds.processes'] = true Setting["feature.homepage.widgets.feeds.processes"] = true
end end
end end
end end

View File

@@ -1,5 +1,5 @@
namespace :locales do namespace :locales do
desc 'Migrate all localization files to new structure for a given locale name as argument' desc "Migrate all localization files to new structure for a given locale name as argument"
task :migrate_structure, [:locale] => [:environment] do |_t, args| task :migrate_structure, [:locale] => [:environment] do |_t, args|
locale = args[:locale] locale = args[:locale]
puts "Moving files for locale: #{locale}" puts "Moving files for locale: #{locale}"

View File

@@ -1,5 +1,5 @@
namespace :map_locations do namespace :map_locations do
desc 'Destroy all empty MapLocation instances found in the database' desc "Destroy all empty MapLocation instances found in the database"
task destroy: :environment do task destroy: :environment do
MapLocation.where(longitude: nil, latitude: nil, zoom: nil).each do |map_location| MapLocation.where(longitude: nil, latitude: nil, zoom: nil).each do |map_location|
map_location.destroy map_location.destroy

View File

@@ -1,11 +1,11 @@
namespace :milestones do namespace :milestones do
def generate_table_migration_sql(new_table:, old_table:, columns:) def generate_table_migration_sql(new_table:, old_table:, columns:)
from_cols = ['id', *columns.keys] from_cols = ["id", *columns.keys]
to_cols = ['id', *columns.values] to_cols = ["id", *columns.values]
<<~SQL <<~SQL
INSERT INTO #{new_table} (#{to_cols.join(', ')}) INSERT INTO #{new_table} (#{to_cols.join(", ")})
SELECT #{from_cols.join(', ')} FROM #{old_table}; SELECT #{from_cols.join(", ")} FROM #{old_table};
SQL SQL
end end
@@ -48,36 +48,36 @@ namespace :milestones do
start = Time.now start = Time.now
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
migrate_table! old_table: 'budget_investment_statuses', migrate_table! old_table: "budget_investment_statuses",
new_table: 'milestone_statuses', new_table: "milestone_statuses",
columns: {'name' => 'name', columns: {"name" => "name",
'description' => 'description', "description" => "description",
'hidden_at' => 'hidden_at', "hidden_at" => "hidden_at",
'created_at' => 'created_at', "created_at" => "created_at",
'updated_at' => 'updated_at'} "updated_at" => "updated_at"}
migrate_table! old_table: 'budget_investment_milestones', migrate_table! old_table: "budget_investment_milestones",
new_table: 'milestones', new_table: "milestones",
columns: {'investment_id' => 'milestoneable_id', columns: {"investment_id" => "milestoneable_id",
'title' => 'title', "title" => "title",
'description' => 'description', "description" => "description",
'created_at' => 'created_at', "created_at" => "created_at",
'updated_at' => 'updated_at', "updated_at" => "updated_at",
'publication_date' => 'publication_date', "publication_date" => "publication_date",
'status_id' => 'status_id'} "status_id" => "status_id"}
populate_column! table: 'milestones', populate_column! table: "milestones",
column: 'milestoneable_type', column: "milestoneable_type",
value: 'Budget::Investment' value: "Budget::Investment"
migrate_table! old_table: 'budget_investment_milestone_translations', migrate_table! old_table: "budget_investment_milestone_translations",
new_table: 'milestone_translations', new_table: "milestone_translations",
columns: {'budget_investment_milestone_id' => 'milestone_id', columns: {"budget_investment_milestone_id" => "milestone_id",
'locale' => 'locale', "locale" => "locale",
'created_at' => 'created_at', "created_at" => "created_at",
'updated_at' => 'updated_at', "updated_at" => "updated_at",
'title' => 'title', "title" => "title",
'description' => 'description'} "description" => "description"}
Image.where(imageable_type: "Budget::Investment::Milestone"). Image.where(imageable_type: "Budget::Investment::Milestone").
update_all(imageable_type: "Milestone") update_all(imageable_type: "Milestone")

View File

@@ -1,10 +1,10 @@
namespace :web_sections do namespace :web_sections do
desc "Generate web sections for banners" desc "Generate web sections for banners"
task generate: :environment do task generate: :environment do
WebSection.create(name: 'homepage') WebSection.create(name: "homepage")
WebSection.create(name: 'debates') WebSection.create(name: "debates")
WebSection.create(name: 'proposals') WebSection.create(name: "proposals")
WebSection.create(name: 'budgets') WebSection.create(name: "budgets")
WebSection.create(name: 'help_page') WebSection.create(name: "help_page")
end end
end end

View File

@@ -41,9 +41,9 @@ class UserSegments
def self.not_supported_on_current_budget def self.not_supported_on_current_budget
author_ids( author_ids(
User.where( User.where(
'id NOT IN (SELECT DISTINCT(voter_id) FROM votes'\ "id NOT IN (SELECT DISTINCT(voter_id) FROM votes"\
' WHERE votable_type = ? AND votes.votable_id IN (?))', " WHERE votable_type = ? AND votes.votable_id IN (?))",
'Budget::Investment', "Budget::Investment",
current_budget_investments.pluck(:id) current_budget_investments.pluck(:id)
) )
) )