Use double quotes in controllers/

This commit is contained in:
Julian Herrero
2019-03-13 22:19:49 +01:00
parent 3c313c9c52
commit d24376f6ad
78 changed files with 236 additions and 236 deletions

View File

@@ -11,7 +11,7 @@ class Admin::Api::StatsController < Admin::Api::BaseController
ds = Ahoy::DataSource.new
if params[:events].present?
event_types = params[:events].split ','
event_types = params[:events].split ","
event_types.each do |event|
ds.add event.titleize, Ahoy::Event.where(name: event).group_by_day(:time).count
end

View File

@@ -47,13 +47,13 @@ class Admin::BannersController < Admin::BaseController
def banner_styles
@banner_styles = Setting.all.banner_style.map do |banner_style|
[banner_style.value, banner_style.key.split('.')[1]]
[banner_style.value, banner_style.key.split(".")[1]]
end
end
def banner_imgs
@banner_imgs = Setting.all.banner_img.map do |banner_img|
[banner_img.value, banner_img.key.split('.')[1]]
[banner_img.value, banner_img.key.split(".")[1]]
end
end

View File

@@ -1,5 +1,5 @@
class Admin::BaseController < ApplicationController
layout 'admin'
layout "admin"
before_action :authenticate_user!
skip_authorization_check

View File

@@ -21,7 +21,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
def create
@heading = @group.headings.new(budget_heading_params)
if @heading.save
redirect_to headings_index, notice: t('admin.budget_headings.create.notice')
redirect_to headings_index, notice: t("admin.budget_headings.create.notice")
else
render :new
end
@@ -29,7 +29,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
def update
if @heading.update(budget_heading_params)
redirect_to headings_index, notice: t('admin.budget_headings.update.notice')
redirect_to headings_index, notice: t("admin.budget_headings.update.notice")
else
render :edit
end
@@ -38,9 +38,9 @@ class Admin::BudgetHeadingsController < Admin::BaseController
def destroy
if @heading.can_be_deleted?
@heading.destroy
redirect_to headings_index, notice: t('admin.budget_headings.destroy.success_notice')
redirect_to headings_index, notice: t("admin.budget_headings.destroy.success_notice")
else
redirect_to headings_index, alert: t('admin.budget_headings.destroy.unable_notice')
redirect_to headings_index, alert: t("admin.budget_headings.destroy.unable_notice")
end
end

View File

@@ -21,7 +21,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
format.js
format.csv do
send_data Budget::Investment::Exporter.new(@investments).to_csv,
filename: 'budget_investments.csv'
filename: "budget_investments.csv"
end
end
end
@@ -71,7 +71,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def resource_name
resource_model.parameterize('_')
resource_model.parameterize("_")
end
def load_investments

View File

@@ -23,13 +23,13 @@ class Admin::BudgetsController < Admin::BaseController
def calculate_winners
return unless @budget.balloting_process?
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners }
redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'winners'),
redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: "winners"),
notice: I18n.t("admin.budgets.winners.calculated")
end
def update
if @budget.update(budget_params)
redirect_to admin_budgets_path, notice: t('admin.budgets.update.notice')
redirect_to admin_budgets_path, notice: t("admin.budgets.update.notice")
else
render :edit
end
@@ -38,7 +38,7 @@ class Admin::BudgetsController < Admin::BaseController
def create
@budget = Budget.new(budget_params)
if @budget.save
redirect_to admin_budget_path(@budget), notice: t('admin.budgets.create.notice')
redirect_to admin_budget_path(@budget), notice: t("admin.budgets.create.notice")
else
render :new
end
@@ -46,10 +46,10 @@ class Admin::BudgetsController < Admin::BaseController
def destroy
if @budget.investments.any?
redirect_to admin_budgets_path, alert: t('admin.budgets.destroy.unable_notice')
redirect_to admin_budgets_path, alert: t("admin.budgets.destroy.unable_notice")
else
@budget.destroy
redirect_to admin_budgets_path, notice: t('admin.budgets.destroy.success_notice')
redirect_to admin_budgets_path, notice: t("admin.budgets.destroy.success_notice")
end
end

View File

@@ -13,6 +13,6 @@ class Admin::EmailsDownloadController < Admin::BaseController
private
def users_segment_emails_csv(users_segment)
UserSegments.user_segment_emails(users_segment).join(',')
UserSegments.user_segment_emails(users_segment).join(",")
end
end

View File

@@ -35,9 +35,9 @@ class Admin::GeozonesController < Admin::BaseController
def destroy
if @geozone.safe_to_destroy?
@geozone.destroy
redirect_to admin_geozones_path, notice: t('admin.geozones.delete.success')
redirect_to admin_geozones_path, notice: t("admin.geozones.delete.success")
else
redirect_to admin_geozones_path, flash: { error: t('admin.geozones.delete.error') }
redirect_to admin_geozones_path, flash: { error: t("admin.geozones.delete.error") }
end
end

View File

@@ -14,7 +14,7 @@ class Admin::HomepageController < Admin::BaseController
end
def load_recommendations
@recommendations = Setting.where(key: 'feature.user.recommendations').first
@recommendations = Setting.where(key: "feature.user.recommendations").first
end
def load_cards
@@ -25,4 +25,4 @@ class Admin::HomepageController < Admin::BaseController
@feeds = Widget::Feed.order("created_at")
end
end
end

View File

@@ -11,10 +11,10 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
def create
if @draft_version.save
link = legislation_process_draft_version_path(@process, @draft_version).html_safe
notice = t('admin.legislation.draft_versions.create.notice', link: link)
notice = t("admin.legislation.draft_versions.create.notice", link: link)
redirect_to admin_legislation_process_draft_versions_path, notice: notice
else
flash.now[:error] = t('admin.legislation.draft_versions.create.error')
flash.now[:error] = t("admin.legislation.draft_versions.create.error")
render :new
end
end
@@ -22,18 +22,18 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
def update
if @draft_version.update(draft_version_params)
link = legislation_process_draft_version_path(@process, @draft_version).html_safe
notice = t('admin.legislation.draft_versions.update.notice', link: link)
notice = t("admin.legislation.draft_versions.update.notice", link: link)
edit_path = edit_admin_legislation_process_draft_version_path(@process, @draft_version)
redirect_to edit_path, notice: notice
else
flash.now[:error] = t('admin.legislation.draft_versions.update.error')
flash.now[:error] = t("admin.legislation.draft_versions.update.error")
render :edit
end
end
def destroy
@draft_version.destroy
notice = t('admin.legislation.draft_versions.destroy.notice')
notice = t("admin.legislation.draft_versions.destroy.notice")
redirect_to admin_legislation_process_draft_versions_path, notice: notice
end

View File

@@ -9,9 +9,9 @@ class Admin::Legislation::HomepagesController < Admin::Legislation::BaseControll
def update
if @process.update(process_params)
link = legislation_process_path(@process).html_safe
redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link)
redirect_to :back, notice: t("admin.legislation.processes.update.notice", link: link)
else
flash.now[:error] = t('admin.legislation.processes.update.error')
flash.now[:error] = t("admin.legislation.processes.update.error")
render :edit
end
end

View File

@@ -14,10 +14,10 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
def create
if @process.save
link = legislation_process_path(@process).html_safe
notice = t('admin.legislation.processes.create.notice', link: link)
notice = t("admin.legislation.processes.create.notice", link: link)
redirect_to edit_admin_legislation_process_path(@process), notice: notice
else
flash.now[:error] = t('admin.legislation.processes.create.error')
flash.now[:error] = t("admin.legislation.processes.create.error")
render :new
end
end
@@ -27,16 +27,16 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
set_tag_list
link = legislation_process_path(@process).html_safe
redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link)
redirect_to :back, notice: t("admin.legislation.processes.update.notice", link: link)
else
flash.now[:error] = t('admin.legislation.processes.update.error')
flash.now[:error] = t("admin.legislation.processes.update.error")
render :edit
end
end
def destroy
@process.destroy
notice = t('admin.legislation.processes.destroy.notice')
notice = t("admin.legislation.processes.destroy.notice")
redirect_to admin_legislation_processes_path, notice: notice
end

View File

@@ -14,27 +14,27 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
def create
@question.author = current_user
if @question.save
notice = t('admin.legislation.questions.create.notice', link: question_path)
notice = t("admin.legislation.questions.create.notice", link: question_path)
redirect_to admin_legislation_process_questions_path, notice: notice
else
flash.now[:error] = t('admin.legislation.questions.create.error')
flash.now[:error] = t("admin.legislation.questions.create.error")
render :new
end
end
def update
if @question.update(question_params)
notice = t('admin.legislation.questions.update.notice', link: question_path)
notice = t("admin.legislation.questions.update.notice", link: question_path)
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: notice
else
flash.now[:error] = t('admin.legislation.questions.update.error')
flash.now[:error] = t("admin.legislation.questions.update.error")
render :edit
end
end
def destroy
@question.destroy
notice = t('admin.legislation.questions.destroy.notice')
notice = t("admin.legislation.questions.destroy.notice")
redirect_to admin_legislation_process_questions_path, notice: notice
end

View File

@@ -15,7 +15,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
if @status.save
redirect_to admin_milestone_statuses_path,
notice: t('admin.statuses.create.notice')
notice: t("admin.statuses.create.notice")
else
render :new
end
@@ -27,7 +27,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
def update
if @status.update(status_params)
redirect_to admin_milestone_statuses_path,
notice: t('admin.statuses.update.notice')
notice: t("admin.statuses.update.notice")
else
render :edit
end
@@ -36,7 +36,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
def destroy
@status.destroy
redirect_to admin_milestone_statuses_path,
notice: t('admin.statuses.delete.notice')
notice: t("admin.statuses.delete.notice")
end
private

View File

@@ -17,7 +17,7 @@ class Admin::MilestonesController < Admin::BaseController
def create
@milestone = @milestoneable.milestones.new(milestone_params)
if @milestone.save
redirect_to milestoneable_path, notice: t('admin.milestones.create.notice')
redirect_to milestoneable_path, notice: t("admin.milestones.create.notice")
else
render :new
end
@@ -28,7 +28,7 @@ class Admin::MilestonesController < Admin::BaseController
def update
if @milestone.update(milestone_params)
redirect_to milestoneable_path, notice: t('admin.milestones.update.notice')
redirect_to milestoneable_path, notice: t("admin.milestones.update.notice")
else
render :edit
end
@@ -36,7 +36,7 @@ class Admin::MilestonesController < Admin::BaseController
def destroy
@milestone.destroy
redirect_to milestoneable_path, notice: t('admin.milestones.delete.notice')
redirect_to milestoneable_path, notice: t("admin.milestones.delete.notice")
end
private

View File

@@ -6,14 +6,14 @@ class Admin::OrganizationsController < Admin::BaseController
def index
@organizations = @organizations.send(@current_filter)
@organizations = @organizations.includes(:user)
.order('users.created_at', :name, 'users.email')
.order("users.created_at", :name, "users.email")
.page(params[:page])
end
def search
@organizations = Organization.includes(:user)
.search(params[:term])
.order('users.created_at', :name, 'users.email')
.order("users.created_at", :name, "users.email")
.page(params[:page])
end
@@ -27,4 +27,4 @@ class Admin::OrganizationsController < Admin::BaseController
redirect_to request.query_parameters.merge(action: :index)
end
end
end

View File

@@ -3,7 +3,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
before_action :load_poll, except: [:create, :destroy]
def index
@booth_assignments = @poll.booth_assignments.includes(:booth).order('poll_booths.name')
@booth_assignments = @poll.booth_assignments.includes(:booth).order("poll_booths.name")
.page(params[:page]).per(50)
end

View File

@@ -1,5 +1,5 @@
class Admin::Poll::BoothsController < Admin::Poll::BaseController
load_and_authorize_resource class: 'Poll::Booth'
load_and_authorize_resource class: "Poll::Booth"
def index
@booths = @booths.order(name: :asc).page(params[:page])

View File

@@ -7,7 +7,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
def index
@officers = ::Poll::Officer.
includes(:user).
order('users.username').
order("users.username").
where(
id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id)
).page(params[:page]).per(50)

View File

@@ -12,7 +12,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
def show
@poll = Poll.includes(:questions).
order('poll_questions.title').
order("poll_questions.title").
find(params[:id])
end

View File

@@ -39,7 +39,7 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
def documents
@documents = @answer.documents
render 'admin/poll/questions/answers/documents'
render "admin/poll/questions/answers/documents"
end
def order_answers

View File

@@ -3,7 +3,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
include Translatable
load_and_authorize_resource :poll
load_and_authorize_resource :question, class: 'Poll::Question'
load_and_authorize_resource :question, class: "Poll::Question"
def index
@polls = Poll.all

View File

@@ -26,7 +26,7 @@ class Admin::ProgressBarsController < Admin::BaseController
def update
if @progress_bar.update(progress_bar_params)
redirect_to progress_bars_index, notice: t('admin.progress_bars.update.notice')
redirect_to progress_bars_index, notice: t("admin.progress_bars.update.notice")
else
render :edit
end
@@ -34,7 +34,7 @@ class Admin::ProgressBarsController < Admin::BaseController
def destroy
@progress_bar.destroy
redirect_to progress_bars_index, notice: t('admin.progress_bars.delete.notice')
redirect_to progress_bars_index, notice: t("admin.progress_bars.delete.notice")
end
private

View File

@@ -2,8 +2,8 @@ class Admin::SettingsController < Admin::BaseController
def index
all_settings = Setting.all.group_by { |s| s.type }
@settings = all_settings['common']
@feature_flags = all_settings['feature']
@settings = all_settings["common"]
@feature_flags = all_settings["feature"]
end
def update

View File

@@ -13,7 +13,7 @@ class Admin::SignatureSheetsController < Admin::BaseController
@signature_sheet.author = current_user
if @signature_sheet.save
@signature_sheet.delay.verify_signatures
redirect_to [:admin, @signature_sheet], notice: I18n.t('flash.actions.create.signature_sheet')
redirect_to [:admin, @signature_sheet], notice: I18n.t("flash.actions.create.signature_sheet")
else
render :new
end

View File

@@ -15,17 +15,17 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
if is_heading_content_block?(@content_block.name)
heading_content_block = new_heading_content_block
if heading_content_block.save
notice = t('admin.site_customization.content_blocks.create.notice')
notice = t("admin.site_customization.content_blocks.create.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.content_blocks.create.error')
flash.now[:error] = t("admin.site_customization.content_blocks.create.error")
render :new
end
elsif @content_block.save
notice = t('admin.site_customization.content_blocks.create.notice')
notice = t("admin.site_customization.content_blocks.create.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.content_blocks.create.error')
flash.now[:error] = t("admin.site_customization.content_blocks.create.error")
render :new
end
end
@@ -43,31 +43,31 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
heading_content_block = new_heading_content_block
if heading_content_block.save
@content_block.destroy
notice = t('admin.site_customization.content_blocks.create.notice')
notice = t("admin.site_customization.content_blocks.create.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.content_blocks.create.error')
flash.now[:error] = t("admin.site_customization.content_blocks.create.error")
render :new
end
elsif @content_block.update(content_block_params)
notice = t('admin.site_customization.content_blocks.update.notice')
notice = t("admin.site_customization.content_blocks.update.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.content_blocks.update.error')
flash.now[:error] = t("admin.site_customization.content_blocks.update.error")
render :edit
end
end
def destroy
@content_block.destroy
notice = t('admin.site_customization.content_blocks.destroy.notice')
notice = t("admin.site_customization.content_blocks.destroy.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
end
def delete_heading_content_block
heading_content_block = Budget::ContentBlock.find(params[:id])
heading_content_block.destroy if heading_content_block
notice = t('admin.site_customization.content_blocks.destroy.notice')
notice = t("admin.site_customization.content_blocks.destroy.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
end
@@ -88,10 +88,10 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
heading_content_block.locale = params[:locale]
heading_content_block.body = params[:body]
if heading_content_block.save
notice = t('admin.site_customization.content_blocks.update.notice')
notice = t("admin.site_customization.content_blocks.update.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.content_blocks.update.error')
flash.now[:error] = t("admin.site_customization.content_blocks.update.error")
render :edit
end
else
@@ -101,10 +101,10 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
@content_block.body = params[:body]
if @content_block.save
heading_content_block.destroy
notice = t('admin.site_customization.content_blocks.update.notice')
notice = t("admin.site_customization.content_blocks.update.notice")
redirect_to admin_site_customization_content_blocks_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.content_blocks.update.error')
flash.now[:error] = t("admin.site_customization.content_blocks.update.error")
render :edit
end
end
@@ -121,14 +121,14 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
end
def is_heading_content_block?(name)
name.start_with?('hcb_')
name.start_with?("hcb_")
end
def new_heading_content_block
heading_content_block = Budget::ContentBlock.new
heading_content_block.body = params[:site_customization_content_block][:body]
heading_content_block.locale = params[:site_customization_content_block][:locale]
block_heading_id = params[:site_customization_content_block][:name].sub('hcb_', '').to_i
block_heading_id = params[:site_customization_content_block][:name].sub("hcb_", "").to_i
heading_content_block.heading_id = block_heading_id
heading_content_block
end

View File

@@ -12,10 +12,10 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas
end
if @image.update(image_params)
notice = t('admin.site_customization.images.update.notice')
notice = t("admin.site_customization.images.update.notice")
redirect_to admin_site_customization_images_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.images.update.error')
flash.now[:error] = t("admin.site_customization.images.update.error")
@images = SiteCustomization::Image.all_images
idx = @images.index {|e| e.name == @image.name }
@@ -28,10 +28,10 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas
def destroy
@image.image = nil
if @image.save
notice = t('admin.site_customization.images.destroy.notice')
notice = t("admin.site_customization.images.destroy.notice")
redirect_to admin_site_customization_images_path, notice: notice
else
notice = t('admin.site_customization.images.destroy.error')
notice = t("admin.site_customization.images.destroy.error")
redirect_to admin_site_customization_images_path, notice: notice
end
end

View File

@@ -13,7 +13,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
unless values.empty?
values.each do |key, value|
locale = key.split('_').last
locale = key.split("_").last
if value == t(content[:id], locale: locale) || value.match(/translation missing/)
next
@@ -28,7 +28,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
end
redirect_to admin_site_customization_information_texts_path,
notice: t('flash.actions.update.translation')
notice: t("flash.actions.update.translation")
end
private
@@ -42,7 +42,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
end
def delete_translations
languages_to_delete = params[:enabled_translations].select { |_, v| v == '0' }
languages_to_delete = params[:enabled_translations].select { |_, v| v == "0" }
.keys
languages_to_delete.each do |locale|
@@ -81,7 +81,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
def enabled_translations
params.fetch(:enabled_translations, {})
.select { |_, v| v == '1' }
.select { |_, v| v == "1" }
.keys
end
end

View File

@@ -3,32 +3,32 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::Base
load_and_authorize_resource :page, class: "SiteCustomization::Page"
def index
@pages = SiteCustomization::Page.order('slug').page(params[:page])
@pages = SiteCustomization::Page.order("slug").page(params[:page])
end
def create
if @page.save
notice = t('admin.site_customization.pages.create.notice')
notice = t("admin.site_customization.pages.create.notice")
redirect_to admin_site_customization_pages_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.pages.create.error')
flash.now[:error] = t("admin.site_customization.pages.create.error")
render :new
end
end
def update
if @page.update(page_params)
notice = t('admin.site_customization.pages.update.notice')
notice = t("admin.site_customization.pages.update.notice")
redirect_to admin_site_customization_pages_path, notice: notice
else
flash.now[:error] = t('admin.site_customization.pages.update.error')
flash.now[:error] = t("admin.site_customization.pages.update.error")
render :edit
end
end
def destroy
@page.destroy
notice = t('admin.site_customization.pages.destroy.notice')
notice = t("admin.site_customization.pages.destroy.notice")
redirect_to admin_site_customization_pages_path, notice: notice
end

View File

@@ -8,9 +8,9 @@ class Admin::StatsController < Admin::BaseController
@proposals = Proposal.with_hidden.count
@comments = Comment.not_valuations.with_hidden.count
@debate_votes = Vote.where(votable_type: 'Debate').count
@proposal_votes = Vote.where(votable_type: 'Proposal').count
@comment_votes = Vote.where(votable_type: 'Comment').count
@debate_votes = Vote.where(votable_type: "Debate").count
@proposal_votes = Vote.where(votable_type: "Proposal").count
@comment_votes = Vote.where(votable_type: "Comment").count
@votes = Vote.count
@user_level_two = User.active.level_two_verified.count
@@ -19,14 +19,14 @@ class Admin::StatsController < Admin::BaseController
@unverified_users = User.active.unverified.count
@users = User.active.count
@user_ids_who_voted_proposals = ActsAsVotable::Vote.where(votable_type: 'Proposal')
@user_ids_who_voted_proposals = ActsAsVotable::Vote.where(votable_type: "Proposal")
.distinct
.count(:voter_id)
@user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals
@spending_proposals = SpendingProposal.count
budgets_ids = Budget.where.not(phase: 'finished').pluck(:id)
budgets_ids = Budget.where.not(phase: "finished").pluck(:id)
@budgets = budgets_ids.size
@investments = Budget::Investment.where(budget_id: budgets_ids).count
end

View File

@@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base
def verify_lock
if current_user.locked?
redirect_to account_path, alert: t('verification.alert.lock')
redirect_to account_path, alert: t("verification.alert.lock")
end
end
@@ -94,13 +94,13 @@ class ApplicationController < ActionController::Base
def verify_resident!
unless current_user.residence_verified?
redirect_to new_residence_path, alert: t('verification.residence.alert.unconfirmed_residency')
redirect_to new_residence_path, alert: t("verification.residence.alert.unconfirmed_residency")
end
end
def verify_verified!
if current_user.level_three_verified?
redirect_to(account_path, notice: t('verification.redirect_notices.already_verified'))
redirect_to(account_path, notice: t("verification.redirect_notices.already_verified"))
end
end
@@ -112,7 +112,7 @@ class ApplicationController < ActionController::Base
end
def set_return_url
if !devise_controller? && controller_name != 'welcome' && is_navigational_format?
if !devise_controller? && controller_name != "welcome" && is_navigational_format?
store_location_for(:user, request.path)
end
end

View File

@@ -67,7 +67,7 @@ module Budgets
if @investment.save
Mailer.budget_investment_created(@investment).deliver_later
redirect_to budget_investment_path(@budget, @investment),
notice: t('flash.actions.create.budget_investment')
notice: t("flash.actions.create.budget_investment")
else
render :new
end
@@ -75,7 +75,7 @@ module Budgets
def destroy
@investment.destroy
redirect_to user_path(current_user, filter: 'budget_investments'), notice: t('flash.actions.destroy.budget_investment')
redirect_to user_path(current_user, filter: "budget_investments"), notice: t("flash.actions.destroy.budget_investment")
end
def vote
@@ -159,7 +159,7 @@ module Budgets
end
def investments
if @current_order == 'random'
if @current_order == "random"
@budget.investments.apply_filters_and_search(@budget, params, @current_filter)
.sort_by_random(session[:random_seed])
else

View File

@@ -10,13 +10,13 @@ class BudgetsController < ApplicationController
respond_to :html, :js
def show
raise ActionController::RoutingError, 'Not Found' unless budget_published?(@budget)
raise ActionController::RoutingError, "Not Found" unless budget_published?(@budget)
end
def index
@finished_budgets = @budgets.finished.order(created_at: :desc)
@budgets_coordinates = current_budget_map_locations
@banners = Banner.in_section('budgets').with_active
@banners = Banner.in_section("budgets").with_active
end
end

View File

@@ -36,13 +36,13 @@ class CommentsController < ApplicationController
def flag
Flag.flag(current_user, @comment)
set_comment_flags(@comment)
respond_with @comment, template: 'comments/_refresh_flag_actions'
respond_with @comment, template: "comments/_refresh_flag_actions"
end
def unflag
Flag.unflag(current_user, @comment)
set_comment_flags(@comment)
respond_with @comment, template: 'comments/_refresh_flag_actions'
respond_with @comment, template: "comments/_refresh_flag_actions"
end
private
@@ -103,7 +103,7 @@ class CommentsController < ApplicationController
return if current_user.administrator? || current_user.moderator?
if @commentable.respond_to?(:comments_closed?) && @commentable.comments_closed?
redirect_to @commentable, alert: t('comments.comments_closed')
redirect_to @commentable, alert: t("comments.comments_closed")
end
end

View File

@@ -7,8 +7,8 @@ class CommunitiesController < ApplicationController
skip_authorization_check
def show
raise ActionController::RoutingError, 'Not Found' unless communitable_exists?
redirect_to root_path if Setting['feature.community'].blank?
raise ActionController::RoutingError, "Not Found" unless communitable_exists?
redirect_to root_path if Setting["feature.community"].blank?
end
private

View File

@@ -117,9 +117,9 @@ module CommentableActions
def section(resource_name)
case resource_name
when "Proposal"
'proposals'
"proposals"
when "Debate"
'debates'
"debates"
end
end

View File

@@ -4,7 +4,7 @@ module FlagActions
def flag
Flag.flag(current_user, flaggable)
if controller_name == 'investments'
if controller_name == "investments"
respond_with flaggable, template: "budgets/#{controller_name}/_refresh_flag_actions"
else
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
@@ -14,7 +14,7 @@ module FlagActions
def unflag
Flag.unflag(current_user, flaggable)
if controller_name == 'investments'
if controller_name == "investments"
respond_with flaggable, template: "budgets/#{controller_name}/_refresh_flag_actions"
else
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
@@ -24,7 +24,7 @@ module FlagActions
private
def flaggable
if resource_model.to_s == 'Budget::Investment'
if resource_model.to_s == "Budget::Investment"
instance_variable_get("@investment")
else
instance_variable_get("@#{resource_model.to_s.downcase}")

View File

@@ -3,7 +3,7 @@ module Polymorphic
private
def resource
if resource_model.to_s == 'Budget::Investment'
if resource_model.to_s == "Budget::Investment"
@resource ||= instance_variable_get("@investment")
else
@resource ||= instance_variable_get("@#{resource_name}")

View File

@@ -27,13 +27,13 @@ module Search
def search_start_date
case params[:advanced_search][:date_min]
when '1'
when "1"
24.hours.ago
when '2'
when "2"
1.week.ago
when '3'
when "3"
1.month.ago
when '4'
when "4"
1.year.ago
else
Date.parse(params[:advanced_search][:date_min]) rescue 100.years.ago
@@ -50,7 +50,7 @@ module Search
def set_search_order
if params[:search].present? && params[:order].blank?
params[:order] = 'relevance'
params[:order] = "relevance"
end
end

View File

@@ -46,9 +46,9 @@ class DebatesController < ApplicationController
def disable_recommendations
if current_user.update(recommended_debates: false)
redirect_to debates_path, notice: t('debates.index.recommendations.actions.success')
redirect_to debates_path, notice: t("debates.index.recommendations.actions.success")
else
redirect_to debates_path, error: t('debates.index.recommendations.actions.error')
redirect_to debates_path, error: t("debates.index.recommendations.actions.error")
end
end
@@ -67,7 +67,7 @@ class DebatesController < ApplicationController
end
def debates_recommendations
if Setting['feature.user.recommendations_on_debates'] && current_user.recommended_debates
if Setting["feature.user.recommendations_on_debates"] && current_user.recommended_debates
@recommended_debates = Debate.recommendations(current_user).sort_by_random.limit(3)
end
end

View File

@@ -12,11 +12,11 @@ class GraphqlController < ApplicationController
response = consul_schema.execute query_string, variables: query_variables
render json: response, status: :ok
rescue GraphqlController::QueryStringError
render json: { message: 'Query string not present' }, status: :bad_request
render json: { message: "Query string not present" }, status: :bad_request
rescue JSON::ParserError
render json: { message: 'Error parsing JSON' }, status: :bad_request
render json: { message: "Error parsing JSON" }, status: :bad_request
rescue GraphQL::ParseError
render json: { message: 'Query string is not valid JSON' }, status: :bad_request
render json: { message: "Query string is not valid JSON" }, status: :bad_request
rescue
unless Rails.env.production? then raise end
end
@@ -36,7 +36,7 @@ class GraphqlController < ApplicationController
end
def query_string
if request.headers["CONTENT_TYPE"] == 'application/graphql'
if request.headers["CONTENT_TYPE"] == "application/graphql"
request.body.string # request.body.class => StringIO
else
params[:query]
@@ -44,7 +44,7 @@ class GraphqlController < ApplicationController
end
def query_variables
if params[:variables].blank? || params[:variables] == 'null'
if params[:variables].blank? || params[:variables] == "null"
{}
else
JSON.parse(params[:variables])

View File

@@ -4,7 +4,7 @@ class InstallationController < ApplicationController
def details
respond_to do |format|
format.any { render json: consul_installation_details.to_json, content_type: 'application/json' }
format.any { render json: consul_installation_details.to_json, content_type: "application/json" }
end
end
@@ -17,7 +17,7 @@ class InstallationController < ApplicationController
end
def settings_feature_flags
Setting.where("key LIKE 'feature.%'").each_with_object({}) { |x, n| n[x.key.remove('feature.')] = x.value }
Setting.where("key LIKE 'feature.%'").each_with_object({}) { |x, n| n[x.key.remove("feature.")] = x.value }
end
end

View File

@@ -18,7 +18,7 @@ class Legislation::AnnotationsController < ApplicationController
@commentable = @annotation
if params[:sub_annotation_ids].present?
@sub_annotations = Legislation::Annotation.where(id: params[:sub_annotation_ids].split(','))
@sub_annotations = Legislation::Annotation.where(id: params[:sub_annotation_ids].split(","))
annotations = [@commentable, @sub_annotations]
else
annotations = [@commentable]

View File

@@ -18,7 +18,7 @@ class Legislation::AnswersController < Legislation::BaseController
format.html { redirect_to legislation_process_question_path(@process, @question) }
end
else
alert = t('legislation.questions.participation.phase_not_open')
alert = t("legislation.questions.participation.phase_not_open")
respond_to do |format|
format.js { render json: {}, status: :not_found }
format.html { redirect_to legislation_process_question_path(@process, @question), alert: alert }

View File

@@ -18,9 +18,9 @@ class Legislation::DraftVersionsController < Legislation::BaseController
def go_to_version
version = visible_draft_versions.find(params[:draft_version_id])
if params[:redirect_action] == 'changes'
if params[:redirect_action] == "changes"
redirect_to legislation_process_draft_version_changes_path(@process, version)
elsif params[:redirect_action] == 'annotations'
elsif params[:redirect_action] == "annotations"
redirect_to legislation_process_draft_version_annotations_path(@process, version)
else
redirect_to legislation_process_draft_version_path(@process, version)

View File

@@ -9,7 +9,7 @@ class Legislation::ProcessesController < Legislation::BaseController
before_action :set_random_seed, only: :proposals
def index
@current_filter ||= 'open'
@current_filter ||= "open"
@processes = ::Legislation::Process.send(@current_filter).published
.not_in_draft.order(start_date: :desc).page(params[:page])
end

View File

@@ -33,7 +33,7 @@ class Legislation::ProposalsController < Legislation::BaseController
@proposal = Legislation::Proposal.new(proposal_params.merge(author: current_user))
if @proposal.save
redirect_to legislation_process_proposal_path(params[:process_id], @proposal), notice: I18n.t('flash.actions.create.proposal')
redirect_to legislation_process_proposal_path(params[:process_id], @proposal), notice: I18n.t("flash.actions.create.proposal")
else
render :new
end
@@ -64,7 +64,7 @@ class Legislation::ProposalsController < Legislation::BaseController
end
def resource_name
'proposal'
"proposal"
end
def load_successful_proposals

View File

@@ -1,5 +1,5 @@
class Management::BaseController < ActionController::Base
layout 'management'
layout "management"
before_action :verify_manager
before_action :set_locale
@@ -11,7 +11,7 @@ class Management::BaseController < ActionController::Base
private
def verify_manager
raise ActionController::RoutingError.new('Not Found') if current_manager.blank?
raise ActionController::RoutingError.new("Not Found") if current_manager.blank?
end
def current_manager

View File

@@ -1,7 +1,7 @@
class Management::Budgets::InvestmentsController < Management::BaseController
load_resource :budget
load_resource :investment, through: :budget, class: 'Budget::Investment'
load_resource :investment, through: :budget, class: "Budget::Investment"
before_action :only_verified_users, except: :print
@@ -19,7 +19,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
@investment.author = managed_user
if @investment.save
notice = t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1)
notice = t("flash.actions.create.notice", resource_name: Budget::Investment.model_name.human, count: 1)
redirect_to management_budget_investment_path(@budget, @investment), notice: notice
else
load_categories

View File

@@ -20,7 +20,7 @@ class Management::ProposalsController < Management::BaseController
end
def vote
@proposal.register_vote(managed_user, 'yes')
@proposal.register_vote(managed_user, "yes")
set_proposal_votes(@proposal)
end

View File

@@ -17,7 +17,7 @@ class Management::SpendingProposalsController < Management::BaseController
@spending_proposal.author = managed_user
if @spending_proposal.save
notice = t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1))
notice = t("flash.actions.create.notice", resource_name: t("activerecord.models.spending_proposal", count: 1))
redirect_to management_spending_proposal_path(@spending_proposal), notice: notice
else
render :new
@@ -29,12 +29,12 @@ class Management::SpendingProposalsController < Management::BaseController
end
def vote
@spending_proposal.register_vote(managed_user, 'yes')
@spending_proposal.register_vote(managed_user, "yes")
set_spending_proposal_votes(@spending_proposal)
end
def print
params[:geozone] ||= 'all'
params[:geozone] ||= "all"
@spending_proposals = apply_filters_and_search(SpendingProposal).order(cached_votes_up: :desc).for_render.limit(15)
set_spending_proposal_votes(@spending_proposals)
end
@@ -59,8 +59,8 @@ class Management::SpendingProposalsController < Management::BaseController
end
def set_geozone_name
if params[:geozone] == 'all'
@geozone_name = t('geozones.none')
if params[:geozone] == "all"
@geozone_name = t("geozones.none")
else
@geozone_name = Geozone.find(params[:geozone]).name
end

View File

@@ -13,7 +13,7 @@ class Management::UsersController < Management::BaseController
user_with_email
end
@user.terms_of_service = '1'
@user.terms_of_service = "1"
@user.residence_verified_at = Time.current
@user.verified_at = Time.current
@@ -25,7 +25,7 @@ class Management::UsersController < Management::BaseController
end
def erase
managed_user.erase(t("management.users.erased_by_manager", manager: current_manager['login'])) if current_manager.present?
managed_user.erase(t("management.users.erased_by_manager", manager: current_manager["login"])) if current_manager.present?
destroy_session
redirect_to management_document_verifications_path, notice: t("management.users.erased_notice")
end
@@ -48,7 +48,7 @@ class Management::UsersController < Management::BaseController
end
def user_without_email
new_password = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789$!".split('').sample(10).join('')
new_password = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789$!".split("").sample(10).join("")
@user.password = new_password
@user.password_confirmation = new_password

View File

@@ -1,5 +1,5 @@
class Moderation::BaseController < ApplicationController
layout 'admin'
layout "admin"
before_action :authenticate_user!
before_action :verify_moderator

View File

@@ -9,12 +9,12 @@ class Moderation::Budgets::InvestmentsController < Moderation::BaseController
before_action :load_resources, only: [:index, :moderate]
load_and_authorize_resource class: 'Budget::Investment'
load_and_authorize_resource class: "Budget::Investment"
private
def resource_name
'budget_investment'
"budget_investment"
end
def resource_model

View File

@@ -15,7 +15,7 @@ class Moderation::ProposalNotificationsController < Moderation::BaseController
private
def resource_name
'proposal_notification'
"proposal_notification"
end
def resource_model

View File

@@ -10,7 +10,7 @@ class Moderation::UsersController < Moderation::BaseController
def hide_in_moderation_screen
block_user
redirect_to request.query_parameters.merge(action: :index), notice: I18n.t('moderation.users.notice_hide')
redirect_to request.query_parameters.merge(action: :index), notice: I18n.t("moderation.users.notice_hide")
end
def hide
@@ -30,4 +30,4 @@ class Moderation::UsersController < Moderation::BaseController
Activity.log(current_user, :block, @user)
end
end
end

View File

@@ -1,5 +1,5 @@
class Officing::BaseController < ApplicationController
layout 'admin'
layout "admin"
before_action :authenticate_user!
before_action :verify_officer
@@ -9,4 +9,4 @@ class Officing::BaseController < ApplicationController
def verify_officer
raise CanCan::AccessDenied unless current_user.try(:poll_officer?)
end
end
end

View File

@@ -57,7 +57,7 @@ class Officing::ResultsController < Officing::BaseController
partial_result.officer_assignment_id = @officer_assignment.id
partial_result.amount = count.to_i
partial_result.author = current_user
partial_result.origin = 'booth'
partial_result.origin = "booth"
@results << partial_result
end
end
@@ -70,7 +70,7 @@ class Officing::ResultsController < Officing::BaseController
date: Date.current)
recount.officer_assignment_id = @officer_assignment.id
recount.author = current_user
recount.origin = 'booth'
recount.origin = "booth"
[:whites, :nulls, :total].each do |recount_type|
if results_params[recount_type].present?
recount["#{recount_type.to_s.singularize}_amount"] = results_params[recount_type].to_i

View File

@@ -6,7 +6,7 @@ class PagesController < ApplicationController
def show
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
@banners = Banner.in_section('help_page').with_active
@banners = Banner.in_section("help_page").with_active
if @custom_page.present?
@cards = @custom_page.cards

View File

@@ -1,7 +1,7 @@
class Polls::QuestionsController < ApplicationController
load_and_authorize_resource :poll
load_and_authorize_resource :question, class: 'Poll::Question'
load_and_authorize_resource :question, class: "Poll::Question"
has_orders %w{most_voted newest oldest}, only: :show

View File

@@ -36,7 +36,7 @@ class ProposalsController < ApplicationController
@proposal = Proposal.new(proposal_params.merge(author: current_user))
if @proposal.save
redirect_to share_proposal_path(@proposal), notice: I18n.t('flash.actions.create.proposal')
redirect_to share_proposal_path(@proposal), notice: I18n.t("flash.actions.create.proposal")
else
render :new
end
@@ -49,13 +49,13 @@ class ProposalsController < ApplicationController
end
def vote
@proposal.register_vote(current_user, 'yes')
@proposal.register_vote(current_user, "yes")
set_proposal_votes(@proposal)
end
def retire
if valid_retired_params? && @proposal.update(retired_params.merge(retired_at: Time.current))
redirect_to proposal_path(@proposal), notice: t('proposals.notice.retired')
redirect_to proposal_path(@proposal), notice: t("proposals.notice.retired")
else
render action: :retire_form
end
@@ -65,7 +65,7 @@ class ProposalsController < ApplicationController
end
def vote_featured
@proposal.register_vote(current_user, 'yes')
@proposal.register_vote(current_user, "yes")
set_featured_proposal_votes(@proposal)
end
@@ -76,9 +76,9 @@ class ProposalsController < ApplicationController
def disable_recommendations
if current_user.update(recommended_proposals: false)
redirect_to proposals_path, notice: t('proposals.index.recommendations.actions.success')
redirect_to proposals_path, notice: t("proposals.index.recommendations.actions.success")
else
redirect_to proposals_path, error: t('proposals.index.recommendations.actions.error')
redirect_to proposals_path, error: t("proposals.index.recommendations.actions.error")
end
end
@@ -97,8 +97,8 @@ class ProposalsController < ApplicationController
end
def valid_retired_params?
@proposal.errors.add(:retired_reason, I18n.t('errors.messages.blank')) if params[:proposal][:retired_reason].blank?
@proposal.errors.add(:retired_explanation, I18n.t('errors.messages.blank')) if params[:proposal][:retired_explanation].blank?
@proposal.errors.add(:retired_reason, I18n.t("errors.messages.blank")) if params[:proposal][:retired_reason].blank?
@proposal.errors.add(:retired_explanation, I18n.t("errors.messages.blank")) if params[:proposal][:retired_explanation].blank?
@proposal.errors.empty?
end
@@ -125,12 +125,12 @@ class ProposalsController < ApplicationController
def load_featured
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? && @current_order != "recommendations"
if Setting['feature.featured_proposals']
if Setting["feature.featured_proposals"]
@featured_proposals = Proposal.not_archived.unsuccessful
.sort_by_confidence_score.limit(Setting['featured_proposals_number'])
.sort_by_confidence_score.limit(Setting["featured_proposals_number"])
if @featured_proposals.present?
set_featured_proposal_votes(@featured_proposals)
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))
@resources = @resources.where("proposals.id NOT IN (?)", @featured_proposals.map(&:id))
end
end
end
@@ -147,7 +147,7 @@ class ProposalsController < ApplicationController
end
def proposals_recommendations
if Setting['feature.user.recommendations_on_proposals'] && current_user.recommended_proposals
if Setting["feature.user.recommendations_on_proposals"] && current_user.recommended_proposals
@recommended_proposals = Proposal.recommendations(current_user).sort_by_random.limit(3)
end
end

View File

@@ -9,13 +9,13 @@ class RelatedContentsController < ApplicationController
if relationable_object.url != related_object.url
RelatedContent.create(parent_relationable: @relationable, child_relationable: @related, author: current_user)
flash[:success] = t('related_content.success')
flash[:success] = t("related_content.success")
else
flash[:error] = t('related_content.error_itself')
flash[:error] = t("related_content.error_itself")
end
else
flash[:error] = t('related_content.error', url: Setting['url'])
flash[:error] = t("related_content.error", url: Setting["url"])
end
redirect_to @relationable.url
end
@@ -34,11 +34,11 @@ class RelatedContentsController < ApplicationController
@related = RelatedContent.find params[:id]
@related.send("score_#{action}", current_user)
render template: 'relationable/_refresh_score_actions'
render template: "relationable/_refresh_score_actions"
end
def valid_url?
params[:url].start_with?(Setting['url'])
params[:url].start_with?(Setting["url"])
end
def relationable_object

View File

@@ -6,14 +6,14 @@ class SandboxController < ApplicationController
helper_method(:namespace)
def index
@templates = Dir.glob(Rails.root.join('app', 'views', 'sandbox', '*.html.erb').to_s).map do |filename|
@templates = Dir.glob(Rails.root.join("app", "views", "sandbox", "*.html.erb").to_s).map do |filename|
filename = File.basename(filename, File.extname(filename))
filename unless filename.starts_with?('_') || filename == 'index.html'
filename unless filename.starts_with?("_") || filename == "index.html"
end.compact
end
def show
if params[:template].index('.') # CVE-2014-0130
if params[:template].index(".") # CVE-2014-0130
render action: "index"
elsif lookup_context.exists?("sandbox/#{params[:template]}")
if params[:template] == "index"

View File

@@ -31,7 +31,7 @@ class SpendingProposalsController < ApplicationController
if @spending_proposal.save
activity = "<a href='#{user_path(current_user, filter: :spending_proposals)}'>#{t('layouts.header.my_activity_link')}</a>"
notice = t('flash.actions.create.spending_proposal', activity: activity)
notice = t("flash.actions.create.spending_proposal", activity: activity)
redirect_to @spending_proposal, notice: notice, flash: { html_safe: true }
else
render :new
@@ -41,11 +41,11 @@ class SpendingProposalsController < ApplicationController
def destroy
spending_proposal = SpendingProposal.find(params[:id])
spending_proposal.destroy
redirect_to user_path(current_user, filter: 'spending_proposals'), notice: t('flash.actions.destroy.spending_proposal')
redirect_to user_path(current_user, filter: "spending_proposals"), notice: t("flash.actions.destroy.spending_proposal")
end
def vote
@spending_proposal.register_vote(current_user, 'yes')
@spending_proposal.register_vote(current_user, "yes")
set_spending_proposal_votes(@spending_proposal)
end
@@ -56,8 +56,8 @@ class SpendingProposalsController < ApplicationController
end
def set_geozone_name
if params[:geozone] == 'all'
@geozone_name = t('geozones.none')
if params[:geozone] == "all"
@geozone_name = t("geozones.none")
else
@geozone_name = Geozone.find(params[:geozone]).name
end

View File

@@ -6,19 +6,19 @@ class StatsController < ApplicationController
skip_authorization_check
def index
@visits = daily_cache('visits') { Visit.count }
@debates = daily_cache('debates') { Debate.with_hidden.count }
@proposals = daily_cache('proposals') { Proposal.with_hidden.count }
@comments = daily_cache('comments') { Comment.not_valuations.with_hidden.count }
@visits = daily_cache("visits") { Visit.count }
@debates = daily_cache("debates") { Debate.with_hidden.count }
@proposals = daily_cache("proposals") { Proposal.with_hidden.count }
@comments = daily_cache("comments") { Comment.not_valuations.with_hidden.count }
@debate_votes = daily_cache('debate_votes') { Vote.where(votable_type: 'Debate').count }
@proposal_votes = daily_cache('proposal_votes') { Vote.where(votable_type: 'Proposal').count }
@comment_votes = daily_cache('comment_votes') { Vote.where(votable_type: 'Comment').count }
@investment_votes = daily_cache('budget_investment_votes') { Vote.where(votable_type: 'Budget::Investment').count }
@votes = daily_cache('votes') { Vote.count }
@debate_votes = daily_cache("debate_votes") { Vote.where(votable_type: "Debate").count }
@proposal_votes = daily_cache("proposal_votes") { Vote.where(votable_type: "Proposal").count }
@comment_votes = daily_cache("comment_votes") { Vote.where(votable_type: "Comment").count }
@investment_votes = daily_cache("budget_investment_votes") { Vote.where(votable_type: "Budget::Investment").count }
@votes = daily_cache("votes") { Vote.count }
@verified_users = daily_cache('verified_users') { User.with_hidden.level_two_or_three_verified.count }
@unverified_users = daily_cache('unverified_users') { User.with_hidden.unverified.count }
@verified_users = daily_cache("verified_users") { User.with_hidden.level_two_or_three_verified.count }
@unverified_users = daily_cache("unverified_users") { User.with_hidden.unverified.count }
end
private

View File

@@ -16,7 +16,7 @@ class TopicsController < ApplicationController
def create
@topic = Topic.new(topic_params.merge(author: current_user, community_id: params[:community_id]))
if @topic.save
redirect_to community_path(@community), notice: I18n.t('flash.actions.create.topic')
redirect_to community_path(@community), notice: I18n.t("flash.actions.create.topic")
else
render :new
end
@@ -33,7 +33,7 @@ class TopicsController < ApplicationController
def update
if @topic.update(topic_params)
redirect_to community_path(@community), notice: t('flash.actions.update.topic')
redirect_to community_path(@community), notice: t("flash.actions.update.topic")
else
render :edit
end
@@ -41,7 +41,7 @@ class TopicsController < ApplicationController
def destroy
@topic.destroy
redirect_to community_path(@community), notice: I18n.t('flash.actions.destroy.topic')
redirect_to community_path(@community), notice: I18n.t("flash.actions.destroy.topic")
end
private

View File

@@ -53,7 +53,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
private
def set_official_position
resource.add_official_position! (Setting['official_level_1_name']), 1
resource.add_official_position! (Setting["official_level_1_name"]), 1
end
end

View File

@@ -23,7 +23,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
private
def sign_in_with(feature, provider)
raise ActionController::RoutingError.new('Not Found') unless Setting["feature.#{feature}"]
raise ActionController::RoutingError.new("Not Found") unless Setting["feature.#{feature}"]
auth = env["omniauth.auth"]

View File

@@ -14,8 +14,8 @@ class UsersController < ApplicationController
def set_activity_counts
@activity_counts = HashWithIndifferentAccess.new(
proposals: Proposal.where(author_id: @user.id).count,
debates: (Setting['feature.debates'] ? Debate.where(author_id: @user.id).count : 0),
budget_investments: (Setting['feature.budgets'] ? Budget::Investment.where(author_id: @user.id).count : 0),
debates: (Setting["feature.debates"] ? Debate.where(author_id: @user.id).count : 0),
budget_investments: (Setting["feature.budgets"] ? Budget::Investment.where(author_id: @user.id).count : 0),
comments: only_active_commentables.count,
follows: @user.follows.map(&:followable).compact.count)
end
@@ -93,8 +93,8 @@ class UsersController < ApplicationController
def only_active_commentables
disabled_commentables = []
disabled_commentables << "Debate" unless Setting['feature.debates']
disabled_commentables << "Budget::Investment" unless Setting['feature.budgets']
disabled_commentables << "Debate" unless Setting["feature.debates"]
disabled_commentables << "Budget::Investment" unless Setting["feature.budgets"]
if disabled_commentables.present?
all_user_comments.where("commentable_type NOT IN (?)", disabled_commentables)
else

View File

@@ -1,5 +1,5 @@
class Valuation::BaseController < ApplicationController
layout 'admin'
layout "admin"
before_action :authenticate_user!
before_action :verify_valuator

View File

@@ -33,7 +33,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end
Activity.log(current_user, :valuate, @investment)
notice = t('valuation.budget_investments.notice.valuate')
notice = t("valuation.budget_investments.notice.valuate")
redirect_to valuation_budget_budget_investment_path(@budget, @investment), notice: notice
else
render action: :edit
@@ -61,7 +61,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end
def resource_name
resource_model.parameterize('_')
resource_model.parameterize("_")
end
def load_budget
@@ -81,7 +81,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
all_headings_filter = [
{
name: t('valuation.budget_investments.index.headings_filter_all'),
name: t("valuation.budget_investments.index.headings_filter_all"),
id: nil,
count: investments.size
}
@@ -109,7 +109,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
def restrict_access
unless current_user.administrator? || current_budget.valuating?
raise CanCan::AccessDenied.new(I18n.t('valuation.budget_investments.not_in_valuating_phase'))
raise CanCan::AccessDenied.new(I18n.t("valuation.budget_investments.not_in_valuating_phase"))
end
end
@@ -117,16 +117,16 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
return if current_user.administrator? ||
Budget::ValuatorAssignment.exists?(investment_id: params[:id],
valuator_id: current_user.valuator.id)
raise ActionController::RoutingError.new('Not Found')
raise ActionController::RoutingError.new("Not Found")
end
def valid_price_params?
if /\D/.match params[:budget_investment][:price]
@investment.errors.add(:price, I18n.t('budgets.investments.wrong_price_format'))
@investment.errors.add(:price, I18n.t("budgets.investments.wrong_price_format"))
end
if /\D/.match params[:budget_investment][:price_first_year]
@investment.errors.add(:price_first_year, I18n.t('budgets.investments.wrong_price_format'))
@investment.errors.add(:price_first_year, I18n.t("budgets.investments.wrong_price_format"))
end
@investment.errors.empty?

View File

@@ -26,7 +26,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
@spending_proposal.send_unfeasible_email
end
redirect_to valuation_spending_proposal_path(@spending_proposal), notice: t('valuation.spending_proposals.notice.valuate')
redirect_to valuation_spending_proposal_path(@spending_proposal), notice: t("valuation.spending_proposals.notice.valuate")
else
render action: :edit
end
@@ -37,12 +37,12 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
def geozone_filters
spending_proposals = SpendingProposal.by_valuator(current_user.valuator.try(:id)).valuation_open.all.to_a
[ { name: t('valuation.spending_proposals.index.geozone_filter_all'),
[ { name: t("valuation.spending_proposals.index.geozone_filter_all"),
id: nil,
pending_count: spending_proposals.size
},
{ name: t('geozones.none'),
id: 'all',
{ name: t("geozones.none"),
id: "all",
pending_count: spending_proposals.count{|x| x.geozone_id.nil?}
}
] + Geozone.all.order(name: :asc).collect do |g|
@@ -54,7 +54,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
end
def valuation_params
params[:spending_proposal][:feasible] = nil if params[:spending_proposal][:feasible] == 'nil'
params[:spending_proposal][:feasible] = nil if params[:spending_proposal][:feasible] == "nil"
params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation,
:time_scope, :valuation_finished, :internal_comments)
@@ -67,16 +67,16 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
def restrict_access_to_assigned_items
return if current_user.administrator? ||
ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id)
raise ActionController::RoutingError.new('Not Found')
raise ActionController::RoutingError.new("Not Found")
end
def valid_price_params?
if /\D/.match params[:spending_proposal][:price]
@spending_proposal.errors.add(:price, I18n.t('spending_proposals.wrong_price_format'))
@spending_proposal.errors.add(:price, I18n.t("spending_proposals.wrong_price_format"))
end
if /\D/.match params[:spending_proposal][:price_first_year]
@spending_proposal.errors.add(:price_first_year, I18n.t('spending_proposals.wrong_price_format'))
@spending_proposal.errors.add(:price_first_year, I18n.t("spending_proposals.wrong_price_format"))
end
@spending_proposal.errors.empty?

View File

@@ -7,9 +7,9 @@ class Verification::EmailController < ApplicationController
def show
if Verification::Email.find(current_user, params[:email_verification_token])
current_user.update(verified_at: Time.current)
redirect_to account_path, notice: t('verification.email.show.flash.success')
redirect_to account_path, notice: t("verification.email.show.flash.success")
else
redirect_to verified_user_path, alert: t('verification.email.show.alert.failure')
redirect_to verified_user_path, alert: t("verification.email.show.alert.failure")
end
end
@@ -22,9 +22,9 @@ class Verification::EmailController < ApplicationController
@email.encrypted_token,
@verified_user.document_type,
@verified_user.document_number).deliver_later
redirect_to account_path, notice: t('verification.email.create.flash.success', email: @verified_user.email)
redirect_to account_path, notice: t("verification.email.create.flash.success", email: @verified_user.email)
else
redirect_to verified_user_path, alert: t('verification.email.create.alert.failure')
redirect_to verified_user_path, alert: t("verification.email.create.alert.failure")
end
end

View File

@@ -30,7 +30,7 @@ class Verification::LetterController < ApplicationController
@letter = Verification::Letter.new(letter_params.merge(user: current_user, verify: true))
if @letter.valid?
current_user.update(verified_at: Time.current)
redirect_to account_path, notice: t('verification.letter.update.flash.success')
redirect_to account_path, notice: t("verification.letter.update.flash.success")
else
Lock.increase_tries(@letter.user) if @letter.user
render :edit
@@ -45,7 +45,7 @@ class Verification::LetterController < ApplicationController
def verify_phone!
unless current_user.sms_verified?
redirect_to verified_user_path, alert: t('verification.letter.alert.unconfirmed_code')
redirect_to verified_user_path, alert: t("verification.letter.alert.unconfirmed_code")
end
end

View File

@@ -11,7 +11,7 @@ class Verification::ResidenceController < ApplicationController
def create
@residence = Verification::Residence.new(residence_params.merge(user: current_user))
if @residence.save
redirect_to verified_user_path, notice: t('verification.residence.create.flash.success')
redirect_to verified_user_path, notice: t("verification.residence.create.flash.success")
else
render :new
end
@@ -22,4 +22,4 @@ class Verification::ResidenceController < ApplicationController
def residence_params
params.require(:residence).permit(:document_number, :document_type, :date_of_birth, :postal_code, :terms_of_service)
end
end
end

View File

@@ -14,7 +14,7 @@ class Verification::SmsController < ApplicationController
def create
@sms = Verification::Sms.new(phone: @phone, user: current_user)
if @sms.save
redirect_to edit_sms_path, notice: t('verification.sms.create.flash.success')
redirect_to edit_sms_path, notice: t("verification.sms.create.flash.success")
else
render :new
end
@@ -36,7 +36,7 @@ class Verification::SmsController < ApplicationController
redirect_to_next_path
else
@error = t('verification.sms.update.error')
@error = t("verification.sms.update.error")
render :edit
end
end
@@ -63,9 +63,9 @@ class Verification::SmsController < ApplicationController
def redirect_to_next_path
current_user.reload
if current_user.level_three_verified?
redirect_to account_path, notice: t('verification.sms.update.flash.level_three.success')
redirect_to account_path, notice: t("verification.sms.update.flash.level_three.success")
else
redirect_to new_letter_path, notice: t('verification.sms.update.flash.level_two.success')
redirect_to new_letter_path, notice: t("verification.sms.update.flash.level_two.success")
end
end

View File

@@ -14,7 +14,7 @@ class VerificationController < ApplicationController
if user.organization?
{ path: account_path }
elsif user.level_three_verified?
{ path: account_path, notice: t('verification.redirect_notices.already_verified') }
{ path: account_path, notice: t("verification.redirect_notices.already_verified") }
elsif user.verification_letter_sent?
{ path: edit_letter_path }
elsif user.level_two_verified?
@@ -22,7 +22,7 @@ class VerificationController < ApplicationController
elsif user.verification_sms_sent?
{ path: edit_sms_path }
elsif user.verification_email_sent?
{ path: verified_user_path, notice: t('verification.redirect_notices.email_already_sent') }
{ path: verified_user_path, notice: t("verification.redirect_notices.email_already_sent") }
elsif user.residence_verified?
{ path: verified_user_path }
else
@@ -30,4 +30,4 @@ class VerificationController < ApplicationController
end
end
end
end

View File

@@ -8,7 +8,7 @@ class WelcomeController < ApplicationController
@header = Widget::Card.header.first
@feeds = Widget::Feed.active
@cards = Widget::Card.body
@banners = Banner.in_section('homepage').with_active
@banners = Banner.in_section("homepage").with_active
end
def welcome