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 ds = Ahoy::DataSource.new
if params[:events].present? if params[:events].present?
event_types = params[:events].split ',' event_types = params[:events].split ","
event_types.each do |event| event_types.each do |event|
ds.add event.titleize, Ahoy::Event.where(name: event).group_by_day(:time).count ds.add event.titleize, Ahoy::Event.where(name: event).group_by_day(:time).count
end end

View File

@@ -47,13 +47,13 @@ class Admin::BannersController < Admin::BaseController
def banner_styles def banner_styles
@banner_styles = Setting.all.banner_style.map do |banner_style| @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
end end
def banner_imgs def banner_imgs
@banner_imgs = Setting.all.banner_img.map do |banner_img| @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
end end

View File

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

View File

@@ -21,7 +21,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
def create def create
@heading = @group.headings.new(budget_heading_params) @heading = @group.headings.new(budget_heading_params)
if @heading.save 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 else
render :new render :new
end end
@@ -29,7 +29,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
def update def update
if @heading.update(budget_heading_params) 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 else
render :edit render :edit
end end
@@ -38,9 +38,9 @@ class Admin::BudgetHeadingsController < Admin::BaseController
def destroy def destroy
if @heading.can_be_deleted? if @heading.can_be_deleted?
@heading.destroy @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 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
end end

View File

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

View File

@@ -23,13 +23,13 @@ class Admin::BudgetsController < Admin::BaseController
def calculate_winners def calculate_winners
return unless @budget.balloting_process? return unless @budget.balloting_process?
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners } @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") notice: I18n.t("admin.budgets.winners.calculated")
end end
def update def update
if @budget.update(budget_params) 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 else
render :edit render :edit
end end
@@ -38,7 +38,7 @@ class Admin::BudgetsController < Admin::BaseController
def create def create
@budget = Budget.new(budget_params) @budget = Budget.new(budget_params)
if @budget.save 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 else
render :new render :new
end end
@@ -46,10 +46,10 @@ class Admin::BudgetsController < Admin::BaseController
def destroy def destroy
if @budget.investments.any? 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 else
@budget.destroy @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
end end

View File

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

View File

@@ -35,9 +35,9 @@ class Admin::GeozonesController < Admin::BaseController
def destroy def destroy
if @geozone.safe_to_destroy? if @geozone.safe_to_destroy?
@geozone.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 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
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,7 +3,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
before_action :load_poll, except: [:create, :destroy] before_action :load_poll, except: [:create, :destroy]
def index 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) .page(params[:page]).per(50)
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -26,7 +26,7 @@ class Admin::ProgressBarsController < Admin::BaseController
def update def update
if @progress_bar.update(progress_bar_params) 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 else
render :edit render :edit
end end
@@ -34,7 +34,7 @@ class Admin::ProgressBarsController < Admin::BaseController
def destroy def destroy
@progress_bar.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 end
private private

View File

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

View File

@@ -13,7 +13,7 @@ class Admin::SignatureSheetsController < Admin::BaseController
@signature_sheet.author = current_user @signature_sheet.author = current_user
if @signature_sheet.save if @signature_sheet.save
@signature_sheet.delay.verify_signatures @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 else
render :new render :new
end end

View File

@@ -15,17 +15,17 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
if is_heading_content_block?(@content_block.name) if is_heading_content_block?(@content_block.name)
heading_content_block = new_heading_content_block heading_content_block = new_heading_content_block
if heading_content_block.save 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 redirect_to admin_site_customization_content_blocks_path, notice: notice
else 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 render :new
end end
elsif @content_block.save 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 redirect_to admin_site_customization_content_blocks_path, notice: notice
else 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 render :new
end end
end end
@@ -43,31 +43,31 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
heading_content_block = new_heading_content_block heading_content_block = new_heading_content_block
if heading_content_block.save if heading_content_block.save
@content_block.destroy @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 redirect_to admin_site_customization_content_blocks_path, notice: notice
else 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 render :new
end end
elsif @content_block.update(content_block_params) 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 redirect_to admin_site_customization_content_blocks_path, notice: notice
else 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 render :edit
end end
end end
def destroy def destroy
@content_block.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 redirect_to admin_site_customization_content_blocks_path, notice: notice
end end
def delete_heading_content_block def delete_heading_content_block
heading_content_block = Budget::ContentBlock.find(params[:id]) heading_content_block = Budget::ContentBlock.find(params[:id])
heading_content_block.destroy if heading_content_block 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 redirect_to admin_site_customization_content_blocks_path, notice: notice
end end
@@ -88,10 +88,10 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
heading_content_block.locale = params[:locale] heading_content_block.locale = params[:locale]
heading_content_block.body = params[:body] heading_content_block.body = params[:body]
if heading_content_block.save 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 redirect_to admin_site_customization_content_blocks_path, notice: notice
else 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 render :edit
end end
else else
@@ -101,10 +101,10 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
@content_block.body = params[:body] @content_block.body = params[:body]
if @content_block.save if @content_block.save
heading_content_block.destroy 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 redirect_to admin_site_customization_content_blocks_path, notice: notice
else 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 render :edit
end end
end end
@@ -121,14 +121,14 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
end end
def is_heading_content_block?(name) def is_heading_content_block?(name)
name.start_with?('hcb_') name.start_with?("hcb_")
end end
def new_heading_content_block def new_heading_content_block
heading_content_block = Budget::ContentBlock.new heading_content_block = Budget::ContentBlock.new
heading_content_block.body = params[:site_customization_content_block][:body] heading_content_block.body = params[:site_customization_content_block][:body]
heading_content_block.locale = params[:site_customization_content_block][:locale] 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.heading_id = block_heading_id
heading_content_block heading_content_block
end end

View File

@@ -12,10 +12,10 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas
end end
if @image.update(image_params) 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 redirect_to admin_site_customization_images_path, notice: notice
else 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 @images = SiteCustomization::Image.all_images
idx = @images.index {|e| e.name == @image.name } idx = @images.index {|e| e.name == @image.name }
@@ -28,10 +28,10 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas
def destroy def destroy
@image.image = nil @image.image = nil
if @image.save 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 redirect_to admin_site_customization_images_path, notice: notice
else 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 redirect_to admin_site_customization_images_path, notice: notice
end end
end end

View File

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

View File

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

View File

@@ -8,9 +8,9 @@ class Admin::StatsController < Admin::BaseController
@proposals = Proposal.with_hidden.count @proposals = Proposal.with_hidden.count
@comments = Comment.not_valuations.with_hidden.count @comments = Comment.not_valuations.with_hidden.count
@debate_votes = Vote.where(votable_type: 'Debate').count @debate_votes = Vote.where(votable_type: "Debate").count
@proposal_votes = Vote.where(votable_type: 'Proposal').count @proposal_votes = Vote.where(votable_type: "Proposal").count
@comment_votes = Vote.where(votable_type: 'Comment').count @comment_votes = Vote.where(votable_type: "Comment").count
@votes = Vote.count @votes = Vote.count
@user_level_two = User.active.level_two_verified.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 @unverified_users = User.active.unverified.count
@users = User.active.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 .distinct
.count(:voter_id) .count(:voter_id)
@user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals @user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals
@spending_proposals = SpendingProposal.count @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 @budgets = budgets_ids.size
@investments = Budget::Investment.where(budget_id: budgets_ids).count @investments = Budget::Investment.where(budget_id: budgets_ids).count
end end

View File

@@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base
def verify_lock def verify_lock
if current_user.locked? if current_user.locked?
redirect_to account_path, alert: t('verification.alert.lock') redirect_to account_path, alert: t("verification.alert.lock")
end end
end end
@@ -94,13 +94,13 @@ class ApplicationController < ActionController::Base
def verify_resident! def verify_resident!
unless current_user.residence_verified? 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
end end
def verify_verified! def verify_verified!
if current_user.level_three_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
end end
@@ -112,7 +112,7 @@ class ApplicationController < ActionController::Base
end end
def set_return_url 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) store_location_for(:user, request.path)
end end
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -46,9 +46,9 @@ class DebatesController < ApplicationController
def disable_recommendations def disable_recommendations
if current_user.update(recommended_debates: false) 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 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
end end
@@ -67,7 +67,7 @@ class DebatesController < ApplicationController
end end
def debates_recommendations 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) @recommended_debates = Debate.recommendations(current_user).sort_by_random.limit(3)
end end
end end

View File

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

View File

@@ -4,7 +4,7 @@ class InstallationController < ApplicationController
def details def details
respond_to do |format| 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
end end
@@ -17,7 +17,7 @@ class InstallationController < ApplicationController
end end
def settings_feature_flags 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
end end

View File

@@ -18,7 +18,7 @@ class Legislation::AnnotationsController < ApplicationController
@commentable = @annotation @commentable = @annotation
if params[:sub_annotation_ids].present? 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] annotations = [@commentable, @sub_annotations]
else else
annotations = [@commentable] annotations = [@commentable]

View File

@@ -18,7 +18,7 @@ class Legislation::AnswersController < Legislation::BaseController
format.html { redirect_to legislation_process_question_path(@process, @question) } format.html { redirect_to legislation_process_question_path(@process, @question) }
end end
else else
alert = t('legislation.questions.participation.phase_not_open') alert = t("legislation.questions.participation.phase_not_open")
respond_to do |format| respond_to do |format|
format.js { render json: {}, status: :not_found } format.js { render json: {}, status: :not_found }
format.html { redirect_to legislation_process_question_path(@process, @question), alert: alert } 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 def go_to_version
version = visible_draft_versions.find(params[:draft_version_id]) 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) 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) redirect_to legislation_process_draft_version_annotations_path(@process, version)
else else
redirect_to legislation_process_draft_version_path(@process, version) 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 before_action :set_random_seed, only: :proposals
def index def index
@current_filter ||= 'open' @current_filter ||= "open"
@processes = ::Legislation::Process.send(@current_filter).published @processes = ::Legislation::Process.send(@current_filter).published
.not_in_draft.order(start_date: :desc).page(params[:page]) .not_in_draft.order(start_date: :desc).page(params[:page])
end end

View File

@@ -33,7 +33,7 @@ class Legislation::ProposalsController < Legislation::BaseController
@proposal = Legislation::Proposal.new(proposal_params.merge(author: current_user)) @proposal = Legislation::Proposal.new(proposal_params.merge(author: current_user))
if @proposal.save 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 else
render :new render :new
end end
@@ -64,7 +64,7 @@ class Legislation::ProposalsController < Legislation::BaseController
end end
def resource_name def resource_name
'proposal' "proposal"
end end
def load_successful_proposals def load_successful_proposals

View File

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

View File

@@ -1,7 +1,7 @@
class Management::Budgets::InvestmentsController < Management::BaseController class Management::Budgets::InvestmentsController < Management::BaseController
load_resource :budget 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 before_action :only_verified_users, except: :print
@@ -19,7 +19,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
@investment.author = managed_user @investment.author = managed_user
if @investment.save 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 redirect_to management_budget_investment_path(@budget, @investment), notice: notice
else else
load_categories load_categories

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ class Management::UsersController < Management::BaseController
user_with_email user_with_email
end end
@user.terms_of_service = '1' @user.terms_of_service = "1"
@user.residence_verified_at = Time.current @user.residence_verified_at = Time.current
@user.verified_at = Time.current @user.verified_at = Time.current
@@ -25,7 +25,7 @@ class Management::UsersController < Management::BaseController
end end
def erase 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 destroy_session
redirect_to management_document_verifications_path, notice: t("management.users.erased_notice") redirect_to management_document_verifications_path, notice: t("management.users.erased_notice")
end end
@@ -48,7 +48,7 @@ class Management::UsersController < Management::BaseController
end end
def user_without_email def user_without_email
new_password = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789$!".split('').sample(10).join('') new_password = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789$!".split("").sample(10).join("")
@user.password = new_password @user.password = new_password
@user.password_confirmation = new_password @user.password_confirmation = new_password

View File

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

View File

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

View File

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

View File

@@ -10,7 +10,7 @@ class Moderation::UsersController < Moderation::BaseController
def hide_in_moderation_screen def hide_in_moderation_screen
block_user 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 end
def hide def hide

View File

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

View File

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

View File

@@ -6,7 +6,7 @@ class PagesController < ApplicationController
def show def show
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id]) @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? if @custom_page.present?
@cards = @custom_page.cards @cards = @custom_page.cards

View File

@@ -1,7 +1,7 @@
class Polls::QuestionsController < ApplicationController class Polls::QuestionsController < ApplicationController
load_and_authorize_resource :poll 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 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)) @proposal = Proposal.new(proposal_params.merge(author: current_user))
if @proposal.save 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 else
render :new render :new
end end
@@ -49,13 +49,13 @@ class ProposalsController < ApplicationController
end end
def vote def vote
@proposal.register_vote(current_user, 'yes') @proposal.register_vote(current_user, "yes")
set_proposal_votes(@proposal) set_proposal_votes(@proposal)
end end
def retire def retire
if valid_retired_params? && @proposal.update(retired_params.merge(retired_at: Time.current)) 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 else
render action: :retire_form render action: :retire_form
end end
@@ -65,7 +65,7 @@ class ProposalsController < ApplicationController
end end
def vote_featured def vote_featured
@proposal.register_vote(current_user, 'yes') @proposal.register_vote(current_user, "yes")
set_featured_proposal_votes(@proposal) set_featured_proposal_votes(@proposal)
end end
@@ -76,9 +76,9 @@ class ProposalsController < ApplicationController
def disable_recommendations def disable_recommendations
if current_user.update(recommended_proposals: false) 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 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
end end
@@ -97,8 +97,8 @@ class ProposalsController < ApplicationController
end end
def valid_retired_params? def valid_retired_params?
@proposal.errors.add(:retired_reason, I18n.t('errors.messages.blank')) if params[:proposal][:retired_reason].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.add(:retired_explanation, I18n.t("errors.messages.blank")) if params[:proposal][:retired_explanation].blank?
@proposal.errors.empty? @proposal.errors.empty?
end end
@@ -125,12 +125,12 @@ class ProposalsController < ApplicationController
def load_featured def load_featured
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? && @current_order != "recommendations" 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 @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? if @featured_proposals.present?
set_featured_proposal_votes(@featured_proposals) 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 end
end end
@@ -147,7 +147,7 @@ class ProposalsController < ApplicationController
end end
def proposals_recommendations 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) @recommended_proposals = Proposal.recommendations(current_user).sort_by_random.limit(3)
end end
end end

View File

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

View File

@@ -6,14 +6,14 @@ class SandboxController < ApplicationController
helper_method(:namespace) helper_method(:namespace)
def index 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 = 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.compact
end end
def show def show
if params[:template].index('.') # CVE-2014-0130 if params[:template].index(".") # CVE-2014-0130
render action: "index" render action: "index"
elsif lookup_context.exists?("sandbox/#{params[:template]}") elsif lookup_context.exists?("sandbox/#{params[:template]}")
if params[:template] == "index" if params[:template] == "index"

View File

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

View File

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

View File

@@ -16,7 +16,7 @@ class TopicsController < ApplicationController
def create def create
@topic = Topic.new(topic_params.merge(author: current_user, community_id: params[:community_id])) @topic = Topic.new(topic_params.merge(author: current_user, community_id: params[:community_id]))
if @topic.save 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 else
render :new render :new
end end
@@ -33,7 +33,7 @@ class TopicsController < ApplicationController
def update def update
if @topic.update(topic_params) 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 else
render :edit render :edit
end end
@@ -41,7 +41,7 @@ class TopicsController < ApplicationController
def destroy def destroy
@topic.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 end
private private

View File

@@ -53,7 +53,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
private private
def set_official_position 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
end end

View File

@@ -23,7 +23,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
private private
def sign_in_with(feature, provider) 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"] auth = env["omniauth.auth"]

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,9 +7,9 @@ class Verification::EmailController < ApplicationController
def show def show
if Verification::Email.find(current_user, params[:email_verification_token]) if Verification::Email.find(current_user, params[:email_verification_token])
current_user.update(verified_at: Time.current) 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 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
end end
@@ -22,9 +22,9 @@ class Verification::EmailController < ApplicationController
@email.encrypted_token, @email.encrypted_token,
@verified_user.document_type, @verified_user.document_type,
@verified_user.document_number).deliver_later @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 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
end end

View File

@@ -30,7 +30,7 @@ class Verification::LetterController < ApplicationController
@letter = Verification::Letter.new(letter_params.merge(user: current_user, verify: true)) @letter = Verification::Letter.new(letter_params.merge(user: current_user, verify: true))
if @letter.valid? if @letter.valid?
current_user.update(verified_at: Time.current) 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 else
Lock.increase_tries(@letter.user) if @letter.user Lock.increase_tries(@letter.user) if @letter.user
render :edit render :edit
@@ -45,7 +45,7 @@ class Verification::LetterController < ApplicationController
def verify_phone! def verify_phone!
unless current_user.sms_verified? 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
end end

View File

@@ -11,7 +11,7 @@ class Verification::ResidenceController < ApplicationController
def create def create
@residence = Verification::Residence.new(residence_params.merge(user: current_user)) @residence = Verification::Residence.new(residence_params.merge(user: current_user))
if @residence.save 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 else
render :new render :new
end end

View File

@@ -14,7 +14,7 @@ class Verification::SmsController < ApplicationController
def create def create
@sms = Verification::Sms.new(phone: @phone, user: current_user) @sms = Verification::Sms.new(phone: @phone, user: current_user)
if @sms.save 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 else
render :new render :new
end end
@@ -36,7 +36,7 @@ class Verification::SmsController < ApplicationController
redirect_to_next_path redirect_to_next_path
else else
@error = t('verification.sms.update.error') @error = t("verification.sms.update.error")
render :edit render :edit
end end
end end
@@ -63,9 +63,9 @@ class Verification::SmsController < ApplicationController
def redirect_to_next_path def redirect_to_next_path
current_user.reload current_user.reload
if current_user.level_three_verified? 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 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
end end

View File

@@ -14,7 +14,7 @@ class VerificationController < ApplicationController
if user.organization? if user.organization?
{ path: account_path } { path: account_path }
elsif user.level_three_verified? 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? elsif user.verification_letter_sent?
{ path: edit_letter_path } { path: edit_letter_path }
elsif user.level_two_verified? elsif user.level_two_verified?
@@ -22,7 +22,7 @@ class VerificationController < ApplicationController
elsif user.verification_sms_sent? elsif user.verification_sms_sent?
{ path: edit_sms_path } { path: edit_sms_path }
elsif user.verification_email_sent? 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? elsif user.residence_verified?
{ path: verified_user_path } { path: verified_user_path }
else else

View File

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