@@ -6,8 +6,12 @@ linters:
|
||||
enabled: false
|
||||
SpaceAroundErbTag:
|
||||
enabled: true
|
||||
SpaceIndentation:
|
||||
enabled: true
|
||||
SpaceInHtmlTag:
|
||||
enabled: true
|
||||
TrailingWhitespace:
|
||||
enabled: true
|
||||
Rubocop:
|
||||
enabled: true
|
||||
only:
|
||||
|
||||
@@ -353,6 +353,3 @@ Security/MarshalLoad:
|
||||
|
||||
Security/YAMLLoad:
|
||||
Enabled: true
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: true
|
||||
|
||||
@@ -3,9 +3,6 @@ require: rubocop-rspec
|
||||
AllCops:
|
||||
DisplayCopNames: true
|
||||
DisplayStyleGuide: true
|
||||
Include:
|
||||
- "**/Rakefile"
|
||||
- "**/config.ru"
|
||||
Exclude:
|
||||
- "db/migrate/**/*"
|
||||
- "db/schema.rb"
|
||||
@@ -29,6 +26,9 @@ Layout/IndentationConsistency:
|
||||
Layout/IndentationWidth:
|
||||
Enabled: true
|
||||
|
||||
Layout/EmptyLines:
|
||||
Enabled: true
|
||||
|
||||
Layout/EndOfLine:
|
||||
EnforcedStyle: lf
|
||||
|
||||
@@ -71,5 +71,8 @@ Rails/TimeZone:
|
||||
RSpec/NotToNot:
|
||||
Enabled: true
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: true
|
||||
|
||||
Style/StringLiterals:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin::ActivityController < Admin::BaseController
|
||||
has_filters %w{all on_users on_proposals on_debates on_comments on_system_emails}
|
||||
has_filters %w[all on_users on_proposals on_debates on_comments on_system_emails]
|
||||
|
||||
def show
|
||||
@activity = Activity.for_render.send(@current_filter)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Admin::BannersController < Admin::BaseController
|
||||
include Translatable
|
||||
|
||||
has_filters %w{all with_active with_inactive}, only: :index
|
||||
has_filters %w[all with_active with_inactive], only: :index
|
||||
|
||||
before_action :banner_sections, only: [:edit, :new, :create, :update]
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ class Admin::BudgetPhasesController < Admin::BaseController
|
||||
|
||||
private
|
||||
|
||||
def load_phase
|
||||
@phase = Budget::Phase.find(params[:id])
|
||||
end
|
||||
def load_phase
|
||||
@phase = Budget::Phase.find(params[:id])
|
||||
end
|
||||
|
||||
def budget_phase_params
|
||||
valid_attributes = [:starts_at, :ends_at, :enabled]
|
||||
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
||||
end
|
||||
def budget_phase_params
|
||||
valid_attributes = [:starts_at, :ends_at, :enabled]
|
||||
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
has_filters %w{open finished}, only: :index
|
||||
has_filters %w[open finished], only: :index
|
||||
|
||||
before_action :load_budget, except: [:index, :new, :create]
|
||||
load_and_authorize_resource
|
||||
|
||||
@@ -3,4 +3,4 @@ class Admin::DashboardController < Admin::BaseController
|
||||
def index
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,8 +13,8 @@ class Admin::DebatesController < Admin::BaseController
|
||||
|
||||
private
|
||||
|
||||
def resource_model
|
||||
Debate
|
||||
end
|
||||
def resource_model
|
||||
Debate
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class Admin::EmailsDownloadController < Admin::BaseController
|
||||
|
||||
private
|
||||
|
||||
def users_segment_emails_csv(users_segment)
|
||||
UserSegments.user_segment_emails(users_segment).join(",")
|
||||
end
|
||||
def users_segment_emails_csv(users_segment)
|
||||
UserSegments.user_segment_emails(users_segment).join(",")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Admin::HiddenBudgetInvestmentsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w{all with_confirmed_hide without_confirmed_hide}, only: :index
|
||||
has_filters %w[all with_confirmed_hide without_confirmed_hide], only: :index
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin::HiddenCommentsController < Admin::BaseController
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide]
|
||||
|
||||
before_action :load_comment, only: [:confirm_hide, :restore]
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class Admin::HiddenDebatesController < Admin::BaseController
|
||||
|
||||
feature_flag :debates
|
||||
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
|
||||
before_action :load_debate, only: [:confirm_hide, :restore]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin::HiddenUsersController < Admin::BaseController
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
|
||||
before_action :load_user, only: [:confirm_hide, :restore]
|
||||
|
||||
|
||||
@@ -9,20 +9,20 @@ class Admin::HomepageController < Admin::BaseController
|
||||
|
||||
private
|
||||
|
||||
def load_header
|
||||
@header = ::Widget::Card.header
|
||||
end
|
||||
def load_header
|
||||
@header = ::Widget::Card.header
|
||||
end
|
||||
|
||||
def load_recommendations
|
||||
@recommendations = Setting.where(key: "feature.user.recommendations").first
|
||||
end
|
||||
def load_recommendations
|
||||
@recommendations = Setting.where(key: "feature.user.recommendations").first
|
||||
end
|
||||
|
||||
def load_cards
|
||||
@cards = ::Widget::Card.body
|
||||
end
|
||||
def load_cards
|
||||
@cards = ::Widget::Card.body
|
||||
end
|
||||
|
||||
def load_feeds
|
||||
@feeds = Widget::Feed.order("created_at")
|
||||
end
|
||||
def load_feeds
|
||||
@feeds = Widget::Feed.order("created_at")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -41,11 +41,11 @@ class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
|
||||
private
|
||||
|
||||
def load_status
|
||||
@status = Milestone::Status.find(params[:id])
|
||||
end
|
||||
def load_status
|
||||
@status = Milestone::Status.find(params[:id])
|
||||
end
|
||||
|
||||
def status_params
|
||||
params.require(:milestone_status).permit([:name, :description])
|
||||
end
|
||||
def status_params
|
||||
params.require(:milestone_status).permit([:name, :description])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,4 +30,4 @@ class Admin::OfficialsController < Admin::BaseController
|
||||
params.require(:user).permit(:official_position, :official_level)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin::OrganizationsController < Admin::BaseController
|
||||
has_filters %w{pending all verified rejected}, only: :index
|
||||
has_filters %w[pending all verified rejected], only: :index
|
||||
|
||||
load_and_authorize_resource except: :search
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ class Admin::Poll::ActivePollsController < Admin::Poll::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def load_active_poll
|
||||
|
||||
@@ -34,9 +34,9 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
|
||||
|
||||
def destroy
|
||||
notice = if @video.destroy
|
||||
t("flash.actions.destroy.poll_question_answer_video")
|
||||
t("flash.actions.destroy.poll_question_answer_video")
|
||||
else
|
||||
t("flash.actions.destroy.error")
|
||||
t("flash.actions.destroy.error")
|
||||
end
|
||||
redirect_back(fallback_location: (request.referrer || root_path), notice: notice)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Admin::ProposalNotificationsController < Admin::BaseController
|
||||
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
|
||||
before_action :load_proposal, only: [:confirm_hide, :restore]
|
||||
|
||||
|
||||
@@ -49,4 +49,4 @@ class Admin::ValuatorGroupsController < Admin::BaseController
|
||||
params.require(:valuator_group).permit(:name)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,4 +21,4 @@ module Budgets
|
||||
@group = @budget.groups.find_by_slug_or_id! params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ module Budgets
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
|
||||
|
||||
valid_filters = %w[not_unfeasible feasible unfeasible unselected selected winners]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class CommunitiesController < ApplicationController
|
||||
TOPIC_ORDERS = %w{newest most_commented oldest}.freeze
|
||||
TOPIC_ORDERS = %w[newest most_commented oldest].freeze
|
||||
before_action :set_order, :set_community, :load_topics, :load_participants
|
||||
|
||||
has_orders TOPIC_ORDERS
|
||||
@@ -13,27 +13,27 @@ class CommunitiesController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def set_order
|
||||
@order = valid_order? ? params[:order] : "newest"
|
||||
end
|
||||
def set_order
|
||||
@order = valid_order? ? params[:order] : "newest"
|
||||
end
|
||||
|
||||
def set_community
|
||||
@community = Community.find(params[:id])
|
||||
end
|
||||
def set_community
|
||||
@community = Community.find(params[:id])
|
||||
end
|
||||
|
||||
def load_topics
|
||||
@topics = @community.topics.send("sort_by_#{@order}").page(params[:page])
|
||||
end
|
||||
def load_topics
|
||||
@topics = @community.topics.send("sort_by_#{@order}").page(params[:page])
|
||||
end
|
||||
|
||||
def load_participants
|
||||
@participants = @community.participants
|
||||
end
|
||||
def load_participants
|
||||
@participants = @community.participants
|
||||
end
|
||||
|
||||
def valid_order?
|
||||
params[:order].present? && TOPIC_ORDERS.include?(params[:order])
|
||||
end
|
||||
def valid_order?
|
||||
params[:order].present? && TOPIC_ORDERS.include?(params[:order])
|
||||
end
|
||||
|
||||
def communitable_exists?
|
||||
@community.proposal.present? || @community.investment.present?
|
||||
end
|
||||
def communitable_exists?
|
||||
@community.proposal.present? || @community.investment.present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,6 @@ class Dashboard::SupportsController < Dashboard::BaseController
|
||||
accumulate_supports(grouped_votes)
|
||||
end
|
||||
|
||||
|
||||
def supports
|
||||
@supports ||= Vote
|
||||
.where(votable: proposal,
|
||||
|
||||
@@ -14,7 +14,7 @@ class DebatesController < ApplicationController
|
||||
invisible_captcha only: [:create, :update], honeypot: :subtitle
|
||||
|
||||
has_orders ->(c) { Debate.debates_orders(c.current_user) }, only: :index
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
|
||||
load_and_authorize_resource
|
||||
helper_method :resource_model, :resource_name
|
||||
|
||||
@@ -33,4 +33,4 @@ class DirectMessagesController < ApplicationController
|
||||
def parsed_params
|
||||
direct_message_params.merge(sender: @sender, receiver: @receiver)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,10 +39,10 @@ class DirectUploadsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def direct_upload_params
|
||||
params.require(:direct_upload)
|
||||
.permit(:resource, :resource_type, :resource_id, :resource_relation,
|
||||
:attachment, :cached_attachment, attachment_attributes: [])
|
||||
end
|
||||
def direct_upload_params
|
||||
params.require(:direct_upload)
|
||||
.permit(:resource, :resource_type, :resource_id, :resource_relation,
|
||||
:attachment, :cached_attachment, attachment_attributes: [])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,12 +17,12 @@ class FollowsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def find_followable
|
||||
params[:followable_type].constantize.find(params[:followable_id])
|
||||
end
|
||||
def find_followable
|
||||
params[:followable_type].constantize.find(params[:followable_id])
|
||||
end
|
||||
|
||||
def followable_translation_key(followable)
|
||||
followable.class.name.parameterize(separator: "_")
|
||||
end
|
||||
def followable_translation_key(followable)
|
||||
followable.class.name.parameterize(separator: "_")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,14 +10,14 @@ class InstallationController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def consul_installation_details
|
||||
{
|
||||
release: "1.0.0"
|
||||
}.merge(features: settings_feature_flags)
|
||||
end
|
||||
def consul_installation_details
|
||||
{
|
||||
release: "1.0.0"
|
||||
}.merge(features: settings_feature_flags)
|
||||
end
|
||||
|
||||
def settings_feature_flags
|
||||
Setting.where("key LIKE 'feature.%'").each_with_object({}) { |x, n| n[x.key.remove("feature.")] = x.value }
|
||||
end
|
||||
def settings_feature_flags
|
||||
Setting.where("key LIKE 'feature.%'").each_with_object({}) { |x, n| n[x.key.remove("feature.")] = x.value }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,6 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
before_action :set_random_seed, only: :proposals
|
||||
before_action :check_past, only: :resume
|
||||
|
||||
|
||||
def index
|
||||
@current_filter ||= "open"
|
||||
@processes = ::Legislation::Process.send(@current_filter).published
|
||||
|
||||
@@ -13,8 +13,8 @@ class Legislation::ProposalsController < Legislation::BaseController
|
||||
|
||||
invisible_captcha only: [:create, :update], honeypot: :subtitle
|
||||
|
||||
has_orders %w{confidence_score created_at}, only: :index
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
has_orders %w[confidence_score created_at], only: :index
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
|
||||
helper_method :resource_model, :resource_name
|
||||
respond_to :html, :js
|
||||
|
||||
@@ -2,7 +2,7 @@ class Legislation::QuestionsController < Legislation::BaseController
|
||||
load_and_authorize_resource :process
|
||||
load_and_authorize_resource :question, through: :process
|
||||
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
|
||||
def show
|
||||
@commentable = @question
|
||||
|
||||
@@ -3,4 +3,4 @@ class Management::DashboardController < Management::BaseController
|
||||
def index
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,4 +20,4 @@ class Management::EmailVerificationsController < Management::BaseController
|
||||
params.require(:email_verification).permit(:document_type, :document_number, :email)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,4 +10,4 @@ class Management::UserInvitesController < Management::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ class Moderation::Budgets::InvestmentsController < Moderation::BaseController
|
||||
include FeatureFlags
|
||||
include ModerateActions
|
||||
|
||||
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
||||
has_orders %w{flags created_at}, only: :index
|
||||
has_filters %w[pending_flag_review all with_ignored_flag], only: :index
|
||||
has_orders %w[flags created_at], only: :index
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Moderation::CommentsController < Moderation::BaseController
|
||||
include ModerateActions
|
||||
|
||||
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
||||
has_orders %w{flags newest}, only: :index
|
||||
has_filters %w[pending_flag_review all with_ignored_flag], only: :index
|
||||
has_orders %w[flags newest], only: :index
|
||||
|
||||
before_action :load_resources, only: [:index, :moderate]
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ class Moderation::DebatesController < Moderation::BaseController
|
||||
include ModerateActions
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
||||
has_orders %w{flags created_at}, only: :index
|
||||
has_filters %w[pending_flag_review all with_ignored_flag], only: :index
|
||||
has_orders %w[flags created_at], only: :index
|
||||
|
||||
feature_flag :debates
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Moderation::ProposalNotificationsController < Moderation::BaseController
|
||||
include ModerateActions
|
||||
|
||||
has_filters %w{pending_review all ignored}, only: :index
|
||||
has_orders %w{created_at moderated}, only: :index
|
||||
has_filters %w[pending_review all ignored], only: :index
|
||||
has_orders %w[created_at moderated], only: :index
|
||||
|
||||
before_action :load_resources, only: [:index, :moderate]
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ class Moderation::ProposalsController < Moderation::BaseController
|
||||
include ModerateActions
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
||||
has_orders %w{flags created_at}, only: :index
|
||||
has_filters %w[pending_flag_review all with_ignored_flag], only: :index
|
||||
has_orders %w[flags created_at], only: :index
|
||||
|
||||
feature_flag :proposals
|
||||
|
||||
|
||||
@@ -32,39 +32,39 @@ class Officing::BallotSheetsController < Officing::BaseController
|
||||
|
||||
private
|
||||
|
||||
def namespace
|
||||
"officing"
|
||||
end
|
||||
def namespace
|
||||
"officing"
|
||||
end
|
||||
|
||||
def load_poll
|
||||
@poll = Poll.find(params[:poll_id])
|
||||
end
|
||||
def load_poll
|
||||
@poll = Poll.find(params[:poll_id])
|
||||
end
|
||||
|
||||
def load_ballot_sheets
|
||||
@ballot_sheets = Poll::BallotSheet.where(poll: @poll)
|
||||
end
|
||||
def load_ballot_sheets
|
||||
@ballot_sheets = Poll::BallotSheet.where(poll: @poll)
|
||||
end
|
||||
|
||||
def load_ballot_sheet
|
||||
@ballot_sheet = Poll::BallotSheet.find(params[:id])
|
||||
end
|
||||
def load_ballot_sheet
|
||||
@ballot_sheet = Poll::BallotSheet.find(params[:id])
|
||||
end
|
||||
|
||||
def load_officer_assignments
|
||||
@officer_assignments = ::Poll::OfficerAssignment.
|
||||
includes(booth_assignment: [:booth]).
|
||||
joins(:booth_assignment).
|
||||
final.
|
||||
where(id: current_user.poll_officer.officer_assignment_ids).
|
||||
where("poll_booth_assignments.poll_id = ?", @poll.id).
|
||||
where(date: Date.current)
|
||||
end
|
||||
def load_officer_assignments
|
||||
@officer_assignments = ::Poll::OfficerAssignment.
|
||||
includes(booth_assignment: [:booth]).
|
||||
joins(:booth_assignment).
|
||||
final.
|
||||
where(id: current_user.poll_officer.officer_assignment_ids).
|
||||
where("poll_booth_assignments.poll_id = ?", @poll.id).
|
||||
where(date: Date.current)
|
||||
end
|
||||
|
||||
def load_officer_assignment
|
||||
@officer_assignment = current_user.poll_officer.officer_assignments.final
|
||||
.find_by(id: ballot_sheet_params[:officer_assignment_id])
|
||||
end
|
||||
def load_officer_assignment
|
||||
@officer_assignment = current_user.poll_officer.officer_assignments.final
|
||||
.find_by(id: ballot_sheet_params[:officer_assignment_id])
|
||||
end
|
||||
|
||||
def ballot_sheet_params
|
||||
params.permit(:data, :poll_id, :officer_assignment_id)
|
||||
end
|
||||
def ballot_sheet_params
|
||||
params.permit(:data, :poll_id, :officer_assignment_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,12 +13,12 @@ class Officing::BoothController < Officing::BaseController
|
||||
|
||||
private
|
||||
|
||||
def booth_params
|
||||
params.require(:booth).permit(:id)
|
||||
end
|
||||
def booth_params
|
||||
params.require(:booth).permit(:id)
|
||||
end
|
||||
|
||||
def set_booth(booth)
|
||||
session[:booth_id] = booth.id
|
||||
end
|
||||
def set_booth(booth)
|
||||
session[:booth_id] = booth.id
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -30,22 +30,22 @@ class RelatedContentsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def score(action)
|
||||
@related = RelatedContent.find params[:id]
|
||||
@related.send("score_#{action}", current_user)
|
||||
def score(action)
|
||||
@related = RelatedContent.find params[:id]
|
||||
@related.send("score_#{action}", current_user)
|
||||
|
||||
render template: "relationable/_refresh_score_actions"
|
||||
end
|
||||
render template: "relationable/_refresh_score_actions"
|
||||
end
|
||||
|
||||
def valid_url?
|
||||
params[:url].start_with?(Setting["url"])
|
||||
end
|
||||
def valid_url?
|
||||
params[:url].start_with?(Setting["url"])
|
||||
end
|
||||
|
||||
def relationable_object
|
||||
@relationable = params[:relationable_klass].singularize.camelize.constantize.find_by(id: params[:relationable_id])
|
||||
end
|
||||
def relationable_object
|
||||
@relationable = params[:relationable_klass].singularize.camelize.constantize.find_by(id: params[:relationable_id])
|
||||
end
|
||||
|
||||
def related_object
|
||||
def related_object
|
||||
if valid_url?
|
||||
url = params[:url]
|
||||
|
||||
@@ -55,7 +55,7 @@ class RelatedContentsController < ApplicationController
|
||||
|
||||
@related = related_klass.singularize.camelize.constantize.find_by(id: related_id)
|
||||
end
|
||||
rescue
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,15 +31,15 @@ class SandboxController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def set_layout
|
||||
if params[:template] && params[:template].split("_").first == "admin"
|
||||
"admin"
|
||||
else
|
||||
"application"
|
||||
def set_layout
|
||||
if params[:template] && params[:template].split("_").first == "admin"
|
||||
"admin"
|
||||
else
|
||||
"application"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def namespace
|
||||
"admin"
|
||||
end
|
||||
def namespace
|
||||
"admin"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class TopicsController < ApplicationController
|
||||
before_action :load_community
|
||||
before_action :load_topic, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
|
||||
skip_authorization_check only: :show
|
||||
load_and_authorize_resource except: :show
|
||||
@@ -46,15 +46,15 @@ class TopicsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def topic_params
|
||||
params.require(:topic).permit(:title, :description)
|
||||
end
|
||||
def topic_params
|
||||
params.require(:topic).permit(:title, :description)
|
||||
end
|
||||
|
||||
def load_community
|
||||
@community = Community.find(params[:community_id])
|
||||
end
|
||||
def load_community
|
||||
@community = Community.find(params[:community_id])
|
||||
end
|
||||
|
||||
def load_topic
|
||||
@topic = Topic.find(params[:id])
|
||||
end
|
||||
def load_topic
|
||||
@topic = Topic.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
||||
before_action :load_budget
|
||||
before_action :load_investment, only: [:show, :edit]
|
||||
|
||||
has_orders %w{oldest}, only: [:show, :edit]
|
||||
has_orders %w[oldest], only: [:show, :edit]
|
||||
|
||||
load_and_authorize_resource :investment, class: "Budget::Investment"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class UsersController < ApplicationController
|
||||
has_filters %w{proposals debates budget_investments comments follows}, only: :show
|
||||
has_filters %w[proposals debates budget_investments comments follows], only: :show
|
||||
|
||||
load_and_authorize_resource
|
||||
helper_method :author?
|
||||
|
||||
@@ -9,8 +9,8 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
before_action :load_budget
|
||||
before_action :load_investment, only: [:show, :edit, :valuate]
|
||||
|
||||
has_orders %w{oldest}, only: [:show, :edit]
|
||||
has_filters %w{valuating valuation_finished}, only: :index
|
||||
has_orders %w[oldest], only: [:show, :edit]
|
||||
has_filters %w[valuating valuation_finished], only: :index
|
||||
|
||||
load_and_authorize_resource :investment, class: "Budget::Investment"
|
||||
|
||||
|
||||
@@ -21,4 +21,4 @@ class Verification::VerifiedUserController < ApplicationController
|
||||
data
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,9 +33,9 @@ class WelcomeController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def set_user_recommendations
|
||||
@recommended_debates = Debate.recommendations(current_user).sort_by_recommendations.limit(3)
|
||||
@recommended_proposals = Proposal.recommendations(current_user).sort_by_recommendations.limit(3)
|
||||
end
|
||||
def set_user_recommendations
|
||||
@recommended_debates = Debate.recommendations(current_user).sort_by_recommendations.limit(3)
|
||||
@recommended_proposals = Proposal.recommendations(current_user).sort_by_recommendations.limit(3)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -27,4 +27,4 @@ module CacheKeysHelper
|
||||
"#{commentable.class.name}-#{commentable.id}"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,4 +13,4 @@ module DirectUploadsHelper
|
||||
class: "delete remove-cached-attachment"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,20 +10,20 @@ module FlagsHelper
|
||||
|
||||
private
|
||||
|
||||
def flagged?(flaggable)
|
||||
if flaggable.is_a? Comment
|
||||
@comment_flags[flaggable.id] unless flaggable.commentable_type == "Poll"
|
||||
else
|
||||
Flag.flagged?(current_user, flaggable)
|
||||
def flagged?(flaggable)
|
||||
if flaggable.is_a? Comment
|
||||
@comment_flags[flaggable.id] unless flaggable.commentable_type == "Poll"
|
||||
else
|
||||
Flag.flagged?(current_user, flaggable)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def own_flaggable?(flaggable)
|
||||
if flaggable.is_a? Comment
|
||||
flaggable.user_id == current_user.id
|
||||
else
|
||||
flaggable.author_id == current_user.id
|
||||
def own_flaggable?(flaggable)
|
||||
if flaggable.is_a? Comment
|
||||
flaggable.user_id == current_user.id
|
||||
else
|
||||
flaggable.author_id == current_user.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -47,24 +47,24 @@ module MapLocationsHelper
|
||||
|
||||
private
|
||||
|
||||
def prepare_map_settings(map_location, editable, parent_class, investments_coordinates=nil)
|
||||
options = {
|
||||
map: "",
|
||||
map_center_latitude: map_location_latitude(map_location),
|
||||
map_center_longitude: map_location_longitude(map_location),
|
||||
map_zoom: map_location_zoom(map_location),
|
||||
map_tiles_provider: Rails.application.secrets.map_tiles_provider,
|
||||
map_tiles_provider_attribution: Rails.application.secrets.map_tiles_provider_attribution,
|
||||
marker_editable: editable,
|
||||
marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}",
|
||||
latitude_input_selector: "##{map_location_input_id(parent_class, "latitude")}",
|
||||
longitude_input_selector: "##{map_location_input_id(parent_class, "longitude")}",
|
||||
zoom_input_selector: "##{map_location_input_id(parent_class, "zoom")}",
|
||||
marker_investments_coordinates: investments_coordinates
|
||||
}
|
||||
options[:marker_latitude] = map_location.latitude if map_location.latitude.present?
|
||||
options[:marker_longitude] = map_location.longitude if map_location.longitude.present?
|
||||
options
|
||||
end
|
||||
def prepare_map_settings(map_location, editable, parent_class, investments_coordinates=nil)
|
||||
options = {
|
||||
map: "",
|
||||
map_center_latitude: map_location_latitude(map_location),
|
||||
map_center_longitude: map_location_longitude(map_location),
|
||||
map_zoom: map_location_zoom(map_location),
|
||||
map_tiles_provider: Rails.application.secrets.map_tiles_provider,
|
||||
map_tiles_provider_attribution: Rails.application.secrets.map_tiles_provider_attribution,
|
||||
marker_editable: editable,
|
||||
marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}",
|
||||
latitude_input_selector: "##{map_location_input_id(parent_class, "latitude")}",
|
||||
longitude_input_selector: "##{map_location_input_id(parent_class, "longitude")}",
|
||||
zoom_input_selector: "##{map_location_input_id(parent_class, "zoom")}",
|
||||
marker_investments_coordinates: investments_coordinates
|
||||
}
|
||||
options[:marker_latitude] = map_location.latitude if map_location.latitude.present?
|
||||
options[:marker_longitude] = map_location.longitude if map_location.longitude.present?
|
||||
options
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ module ShiftsHelper
|
||||
|
||||
private
|
||||
|
||||
def officer_shifts(task_id, booth)
|
||||
@officer.shifts.where(task: task_id, booth: booth).map(&:date)
|
||||
end
|
||||
def officer_shifts(task_id, booth)
|
||||
@officer.shifts.where(task: task_id, booth: booth).map(&:date)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,9 +48,9 @@ module WelcomeHelper
|
||||
def calculate_offset(debates, proposals, apply_offset)
|
||||
if debates.any? && proposals.any?
|
||||
offset = if apply_offset
|
||||
"medium-offset-2 large-offset-2"
|
||||
"medium-offset-2 large-offset-2"
|
||||
else
|
||||
"end"
|
||||
"end"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,9 @@ class DeviseMailer < Devise::Mailer
|
||||
|
||||
protected
|
||||
|
||||
def devise_mail(record, action, opts = {})
|
||||
I18n.with_locale record.locale do
|
||||
super(record, action, opts)
|
||||
def devise_mail(record, action, opts = {})
|
||||
I18n.with_locale record.locale do
|
||||
super(record, action, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -129,16 +129,16 @@ class Mailer < ApplicationMailer
|
||||
|
||||
private
|
||||
|
||||
def with_user(user, &block)
|
||||
I18n.with_locale(user.locale) do
|
||||
yield
|
||||
def with_user(user, &block)
|
||||
I18n.with_locale(user.locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def prevent_delivery_to_users_without_email
|
||||
if @email_to.blank?
|
||||
mail.perform_deliveries = false
|
||||
def prevent_delivery_to_users_without_email
|
||||
if @email_to.blank?
|
||||
mail.perform_deliveries = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Activity < ApplicationRecord
|
||||
belongs_to :actionable, -> { with_hidden }, polymorphic: true
|
||||
belongs_to :user, -> { with_hidden }
|
||||
|
||||
VALID_ACTIONS = %w(hide block restore valuate email)
|
||||
VALID_ACTIONS = %w[hide block restore valuate email]
|
||||
|
||||
validates :action, inclusion: {in: VALID_ACTIONS}
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@ class AdminNotification < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def validate_segment_recipient
|
||||
errors.add(:segment_recipient, :invalid) unless valid_segment_recipient?
|
||||
end
|
||||
|
||||
def complete_link_url
|
||||
return unless link.present?
|
||||
unless self.link[/\Ahttp:\/\//] || self.link[/\Ahttps:\/\//]
|
||||
self.link = "http://#{self.link}"
|
||||
def validate_segment_recipient
|
||||
errors.add(:segment_recipient, :invalid) unless valid_segment_recipient?
|
||||
end
|
||||
|
||||
def complete_link_url
|
||||
return unless link.present?
|
||||
unless self.link[/\Ahttp:\/\//] || self.link[/\Ahttps:\/\//]
|
||||
self.link = "http://#{self.link}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,17 +32,17 @@ module Ahoy
|
||||
|
||||
private
|
||||
|
||||
def collections
|
||||
@collections ||= []
|
||||
end
|
||||
def collections
|
||||
@collections ||= []
|
||||
end
|
||||
|
||||
def shared_keys
|
||||
@shared_keys ||= []
|
||||
end
|
||||
def shared_keys
|
||||
@shared_keys ||= []
|
||||
end
|
||||
|
||||
def add_key(key)
|
||||
shared_keys.push(key) unless shared_keys.include? key
|
||||
end
|
||||
def add_key(key)
|
||||
shared_keys.push(key) unless shared_keys.include? key
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class Budget < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
CURRENCY_SYMBOLS = %w(€ $ £ ¥).freeze
|
||||
CURRENCY_SYMBOLS = %w[€ $ £ ¥].freeze
|
||||
|
||||
validates_translation :name, presence: true
|
||||
validates :phase, inclusion: { in: Budget::Phase::PHASE_KINDS }
|
||||
@@ -173,13 +173,13 @@ class Budget < ApplicationRecord
|
||||
def investments_orders
|
||||
case phase
|
||||
when "accepting", "reviewing"
|
||||
%w{random}
|
||||
%w[random]
|
||||
when "publishing_prices", "balloting", "reviewing_ballots"
|
||||
%w{random price}
|
||||
%w[random price]
|
||||
when "finished"
|
||||
%w{random}
|
||||
%w[random]
|
||||
else
|
||||
%w{random confidence_score}
|
||||
%w[random confidence_score]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -205,28 +205,28 @@ class Budget < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def sanitize_descriptions
|
||||
s = WYSIWYGSanitizer.new
|
||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
||||
sanitized = s.sanitize(send("description_#{phase}"))
|
||||
send("description_#{phase}=", sanitized)
|
||||
def sanitize_descriptions
|
||||
s = WYSIWYGSanitizer.new
|
||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
||||
sanitized = s.sanitize(send("description_#{phase}"))
|
||||
send("description_#{phase}=", sanitized)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def generate_phases
|
||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
||||
Budget::Phase.create(
|
||||
budget: self,
|
||||
kind: phase,
|
||||
prev_phase: phases&.last,
|
||||
starts_at: phases&.last&.ends_at || Date.current,
|
||||
ends_at: (phases&.last&.ends_at || Date.current) + 1.month
|
||||
)
|
||||
def generate_phases
|
||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
||||
Budget::Phase.create(
|
||||
budget: self,
|
||||
kind: phase,
|
||||
prev_phase: phases&.last,
|
||||
starts_at: phases&.last&.ends_at || Date.current,
|
||||
ends_at: (phases&.last&.ends_at || Date.current) + 1.month
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def generate_slug?
|
||||
slug.nil? || drafting?
|
||||
end
|
||||
def generate_slug?
|
||||
slug.nil? || drafting?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -36,8 +36,8 @@ class Budget
|
||||
|
||||
private
|
||||
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,8 +56,8 @@ class Budget
|
||||
|
||||
private
|
||||
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,54 +14,54 @@ class Budget::Investment::Exporter
|
||||
|
||||
private
|
||||
|
||||
def headers
|
||||
[
|
||||
I18n.t("admin.budget_investments.index.list.id"),
|
||||
I18n.t("admin.budget_investments.index.list.title"),
|
||||
I18n.t("admin.budget_investments.index.list.supports"),
|
||||
I18n.t("admin.budget_investments.index.list.admin"),
|
||||
I18n.t("admin.budget_investments.index.list.valuator"),
|
||||
I18n.t("admin.budget_investments.index.list.valuation_group"),
|
||||
I18n.t("admin.budget_investments.index.list.geozone"),
|
||||
I18n.t("admin.budget_investments.index.list.feasibility"),
|
||||
I18n.t("admin.budget_investments.index.list.valuation_finished"),
|
||||
I18n.t("admin.budget_investments.index.list.selected"),
|
||||
I18n.t("admin.budget_investments.index.list.visible_to_valuators"),
|
||||
I18n.t("admin.budget_investments.index.list.author_username")
|
||||
]
|
||||
end
|
||||
|
||||
def csv_values(investment)
|
||||
[
|
||||
investment.id.to_s,
|
||||
investment.title,
|
||||
investment.total_votes.to_s,
|
||||
admin(investment),
|
||||
investment.assigned_valuators || "-",
|
||||
investment.assigned_valuation_groups || "-",
|
||||
investment.heading.name,
|
||||
price(investment),
|
||||
investment.valuation_finished? ? I18n.t("shared.yes") : I18n.t("shared.no"),
|
||||
investment.selected? ? I18n.t("shared.yes") : I18n.t("shared.no"),
|
||||
investment.visible_to_valuators? ? I18n.t("shared.yes") : I18n.t("shared.no"),
|
||||
investment.author.username
|
||||
]
|
||||
end
|
||||
|
||||
def admin(investment)
|
||||
if investment.administrator.present?
|
||||
investment.administrator.name
|
||||
else
|
||||
I18n.t("admin.budget_investments.index.no_admin_assigned")
|
||||
def headers
|
||||
[
|
||||
I18n.t("admin.budget_investments.index.list.id"),
|
||||
I18n.t("admin.budget_investments.index.list.title"),
|
||||
I18n.t("admin.budget_investments.index.list.supports"),
|
||||
I18n.t("admin.budget_investments.index.list.admin"),
|
||||
I18n.t("admin.budget_investments.index.list.valuator"),
|
||||
I18n.t("admin.budget_investments.index.list.valuation_group"),
|
||||
I18n.t("admin.budget_investments.index.list.geozone"),
|
||||
I18n.t("admin.budget_investments.index.list.feasibility"),
|
||||
I18n.t("admin.budget_investments.index.list.valuation_finished"),
|
||||
I18n.t("admin.budget_investments.index.list.selected"),
|
||||
I18n.t("admin.budget_investments.index.list.visible_to_valuators"),
|
||||
I18n.t("admin.budget_investments.index.list.author_username")
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
def price(investment)
|
||||
price_string = "admin.budget_investments.index.feasibility.#{investment.feasibility}"
|
||||
if investment.feasible?
|
||||
"#{I18n.t(price_string)} (#{investment.formatted_price})"
|
||||
else
|
||||
I18n.t(price_string)
|
||||
def csv_values(investment)
|
||||
[
|
||||
investment.id.to_s,
|
||||
investment.title,
|
||||
investment.total_votes.to_s,
|
||||
admin(investment),
|
||||
investment.assigned_valuators || "-",
|
||||
investment.assigned_valuation_groups || "-",
|
||||
investment.heading.name,
|
||||
price(investment),
|
||||
investment.valuation_finished? ? I18n.t("shared.yes") : I18n.t("shared.no"),
|
||||
investment.selected? ? I18n.t("shared.yes") : I18n.t("shared.no"),
|
||||
investment.visible_to_valuators? ? I18n.t("shared.yes") : I18n.t("shared.no"),
|
||||
investment.author.username
|
||||
]
|
||||
end
|
||||
|
||||
def admin(investment)
|
||||
if investment.administrator.present?
|
||||
investment.administrator.name
|
||||
else
|
||||
I18n.t("admin.budget_investments.index.no_admin_assigned")
|
||||
end
|
||||
end
|
||||
|
||||
def price(investment)
|
||||
price_string = "admin.budget_investments.index.feasibility.#{investment.feasibility}"
|
||||
if investment.feasible?
|
||||
"#{I18n.t(price_string)} (#{investment.formatted_price})"
|
||||
else
|
||||
I18n.t(price_string)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Budget
|
||||
class Phase < ApplicationRecord
|
||||
PHASE_KINDS = %w(drafting informing accepting reviewing selecting valuating publishing_prices balloting
|
||||
reviewing_ballots finished).freeze
|
||||
PUBLISHED_PRICES_PHASES = %w(publishing_prices balloting reviewing_ballots finished).freeze
|
||||
PHASE_KINDS = %w[drafting informing accepting reviewing selecting valuating publishing_prices balloting
|
||||
reviewing_ballots finished].freeze
|
||||
PUBLISHED_PRICES_PHASES = %w[publishing_prices balloting reviewing_ballots finished].freeze
|
||||
SUMMARY_MAX_LENGTH = 1000
|
||||
DESCRIPTION_MAX_LENGTH = 2000
|
||||
|
||||
|
||||
@@ -47,4 +47,4 @@ class Budget
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Budget
|
||||
class ReclassifiedVote < ApplicationRecord
|
||||
REASONS = %w(heading_changed unfeasible)
|
||||
REASONS = %w[heading_changed unfeasible]
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :investment
|
||||
@@ -9,4 +9,4 @@ class Budget
|
||||
validates :investment, presence: true
|
||||
validates :reason, inclusion: {in: REASONS, allow_nil: false}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,4 +3,4 @@ class Budget
|
||||
belongs_to :valuator_group, counter_cache: :budget_investments_count
|
||||
belongs_to :investment, counter_cache: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,25 +11,25 @@ class CommentNotifier
|
||||
|
||||
private
|
||||
|
||||
def send_comment_email
|
||||
unless @comment.commentable.is_a?(Legislation::Annotation)
|
||||
Mailer.comment(@comment).deliver_later if email_on_comment?
|
||||
def send_comment_email
|
||||
unless @comment.commentable.is_a?(Legislation::Annotation)
|
||||
Mailer.comment(@comment).deliver_later if email_on_comment?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def send_reply_email
|
||||
Mailer.reply(@comment).deliver_later if email_on_comment_reply?
|
||||
end
|
||||
def send_reply_email
|
||||
Mailer.reply(@comment).deliver_later if email_on_comment_reply?
|
||||
end
|
||||
|
||||
def email_on_comment?
|
||||
commentable_author = @comment.commentable.author
|
||||
commentable_author != @author && commentable_author.email_on_comment?
|
||||
end
|
||||
def email_on_comment?
|
||||
commentable_author = @comment.commentable.author
|
||||
commentable_author != @author && commentable_author.email_on_comment?
|
||||
end
|
||||
|
||||
def email_on_comment_reply?
|
||||
return false unless @comment.reply?
|
||||
parent_author = @comment.parent.author
|
||||
parent_author != @author && parent_author.email_on_comment_reply?
|
||||
end
|
||||
def email_on_comment_reply?
|
||||
return false unless @comment.reply?
|
||||
parent_author = @comment.parent.author
|
||||
parent_author != @author && parent_author.email_on_comment_reply?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -44,18 +44,18 @@ class Community < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def users_who_commented
|
||||
topics_ids = topics.pluck(:id)
|
||||
query = "comments.commentable_id IN (?)and comments.commentable_type = 'Topic'"
|
||||
User.by_comments(query, topics_ids)
|
||||
end
|
||||
def users_who_commented
|
||||
topics_ids = topics.pluck(:id)
|
||||
query = "comments.commentable_id IN (?)and comments.commentable_type = 'Topic'"
|
||||
User.by_comments(query, topics_ids)
|
||||
end
|
||||
|
||||
def users_who_topics_author
|
||||
author_ids = topics.pluck(:author_id)
|
||||
User.by_authors(author_ids)
|
||||
end
|
||||
def users_who_topics_author
|
||||
author_ids = topics.pluck(:author_id)
|
||||
User.by_authors(author_ids)
|
||||
end
|
||||
|
||||
def author_from_community
|
||||
from_proposal? ? User.where(id: proposal&.author_id) : User.where(id: investment&.author_id)
|
||||
end
|
||||
def author_from_community
|
||||
from_proposal? ? User.where(id: proposal&.author_id) : User.where(id: investment&.author_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,23 +12,23 @@ module SearchCache
|
||||
|
||||
private
|
||||
|
||||
def searchable_values_sql
|
||||
searchable_values
|
||||
.select{ |k, _| k.present? }
|
||||
.collect{ |value, weight| set_tsvector(value, weight) }
|
||||
.join(" || ")
|
||||
end
|
||||
def searchable_values_sql
|
||||
searchable_values
|
||||
.select{ |k, _| k.present? }
|
||||
.collect{ |value, weight| set_tsvector(value, weight) }
|
||||
.join(" || ")
|
||||
end
|
||||
|
||||
def set_tsvector(value, weight)
|
||||
"setweight(to_tsvector('spanish', unaccent(coalesce(#{quote(strip_html(value))}, ''))), #{quote(weight)})"
|
||||
end
|
||||
def set_tsvector(value, weight)
|
||||
"setweight(to_tsvector('spanish', unaccent(coalesce(#{quote(strip_html(value))}, ''))), #{quote(weight)})"
|
||||
end
|
||||
|
||||
def quote(value)
|
||||
ActiveRecord::Base.connection.quote(value)
|
||||
end
|
||||
def quote(value)
|
||||
ActiveRecord::Base.connection.quote(value)
|
||||
end
|
||||
|
||||
def strip_html(value)
|
||||
ActionController::Base.helpers.sanitize(value, tags: [])
|
||||
end
|
||||
def strip_html(value)
|
||||
ActionController::Base.helpers.sanitize(value, tags: [])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,6 +6,42 @@ module Statisticable
|
||||
attr_reader :resource
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def stats_methods
|
||||
base_stats_methods + gender_methods + age_methods + geozone_methods
|
||||
end
|
||||
|
||||
def base_stats_methods
|
||||
%i[total_participants participations] + participation_check_methods
|
||||
end
|
||||
|
||||
def participation_check_methods
|
||||
PARTICIPATIONS.map { |participation| :"#{participation}?" }
|
||||
end
|
||||
|
||||
def gender_methods
|
||||
%i[total_male_participants total_female_participants male_percentage female_percentage]
|
||||
end
|
||||
|
||||
def age_methods
|
||||
[:participants_by_age]
|
||||
end
|
||||
|
||||
def geozone_methods
|
||||
%i[participants_by_geozone total_no_demographic_data]
|
||||
end
|
||||
|
||||
def stats_cache(*method_names)
|
||||
method_names.each do |method_name|
|
||||
alias_method :"raw_#{method_name}", method_name
|
||||
|
||||
define_method method_name do
|
||||
stats_cache(method_name) { send(:"raw_#{method_name}") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(resource)
|
||||
@resource = resource
|
||||
end
|
||||
@@ -150,40 +186,4 @@ module Statisticable
|
||||
I18n.t("stats.age_range", start: start, finish: finish)
|
||||
end
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def stats_methods
|
||||
base_stats_methods + gender_methods + age_methods + geozone_methods
|
||||
end
|
||||
|
||||
def base_stats_methods
|
||||
%i[total_participants participations] + participation_check_methods
|
||||
end
|
||||
|
||||
def participation_check_methods
|
||||
PARTICIPATIONS.map { |participation| :"#{participation}?" }
|
||||
end
|
||||
|
||||
def gender_methods
|
||||
%i[total_male_participants total_female_participants male_percentage female_percentage]
|
||||
end
|
||||
|
||||
def age_methods
|
||||
[:participants_by_age]
|
||||
end
|
||||
|
||||
def geozone_methods
|
||||
%i[participants_by_geozone total_no_demographic_data]
|
||||
end
|
||||
|
||||
def stats_cache(*method_names)
|
||||
method_names.each do |method_name|
|
||||
alias_method :"raw_#{method_name}", method_name
|
||||
|
||||
define_method method_name do
|
||||
stats_cache(method_name) { send(:"raw_#{method_name}") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -161,7 +161,7 @@ class Debate < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.debates_orders(user)
|
||||
orders = %w{hot_score confidence_score created_at relevance}
|
||||
orders = %w[hot_score confidence_score created_at relevance]
|
||||
orders << "recommendations" if Setting["feature.user.recommendations_on_debates"] && user&.recommended_debates
|
||||
return orders
|
||||
end
|
||||
|
||||
@@ -47,20 +47,20 @@ class DirectUpload
|
||||
|
||||
private
|
||||
|
||||
def parent_resource_attachment_validations
|
||||
@relation.valid?
|
||||
def parent_resource_attachment_validations
|
||||
@relation.valid?
|
||||
|
||||
if @relation.errors.key? :attachment
|
||||
errors.add(:attachment, @relation.errors.full_messages_for(:attachment))
|
||||
if @relation.errors.key? :attachment
|
||||
errors.add(:attachment, @relation.errors.full_messages_for(:attachment))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def relation_attributtes
|
||||
{
|
||||
attachment: @attachment,
|
||||
cached_attachment: @cached_attachment,
|
||||
user: @user
|
||||
}
|
||||
end
|
||||
def relation_attributtes
|
||||
{
|
||||
attachment: @attachment,
|
||||
cached_attachment: @cached_attachment,
|
||||
user: @user
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -60,11 +60,11 @@ class Document < ApplicationRecord
|
||||
|
||||
def custom_hash_data(attachment)
|
||||
original_filename = if !attachment.instance.persisted? && attachment.instance.remove
|
||||
attachment.instance.original_filename
|
||||
attachment.instance.original_filename
|
||||
elsif !attachment.instance.persisted?
|
||||
attachment.instance.attachment_file_name
|
||||
attachment.instance.attachment_file_name
|
||||
else
|
||||
attachment.instance.title
|
||||
attachment.instance.title
|
||||
end
|
||||
"#{attachment.instance.user_id}/#{original_filename}"
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Legislation::DraftVersion < ApplicationRecord
|
||||
VALID_STATUSES = %w(draft published)
|
||||
VALID_STATUSES = %w[draft published]
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
@@ -55,16 +55,16 @@ class Newsletter < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def validate_segment_recipient
|
||||
errors.add(:segment_recipient, :invalid) unless valid_segment_recipient?
|
||||
end
|
||||
def validate_segment_recipient
|
||||
errors.add(:segment_recipient, :invalid) unless valid_segment_recipient?
|
||||
end
|
||||
|
||||
def valid_email?(email)
|
||||
email.match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i)
|
||||
end
|
||||
def valid_email?(email)
|
||||
email.match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i)
|
||||
end
|
||||
|
||||
def log_delivery(recipient_email)
|
||||
user = User.where(email: recipient_email).first
|
||||
Activity.log(user, :email, self)
|
||||
end
|
||||
def log_delivery(recipient_email)
|
||||
user = User.where(email: recipient_email).first
|
||||
Activity.log(user, :email, self)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,16 +82,16 @@ class Notification < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def self.batch_size
|
||||
10000
|
||||
end
|
||||
def self.batch_size
|
||||
10000
|
||||
end
|
||||
|
||||
def self.batch_interval
|
||||
20.minutes
|
||||
end
|
||||
def self.batch_interval
|
||||
20.minutes
|
||||
end
|
||||
|
||||
def self.first_batch_run_at
|
||||
Time.current
|
||||
end
|
||||
def self.first_batch_run_at
|
||||
Time.current
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -18,7 +18,6 @@ class Poll::PairAnswer < ApplicationRecord
|
||||
validates :answer_right, inclusion: { in: ->(a) { a.question.question_answers.visibles }},
|
||||
unless: ->(a) { a.question.blank? }
|
||||
|
||||
|
||||
scope :by_author, ->(author_id) { where(author_id: author_id) }
|
||||
scope :by_question, ->(question_id) { where(question_id: question_id) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Poll::PartialResult < ApplicationRecord
|
||||
|
||||
VALID_ORIGINS = %w{web booth}
|
||||
VALID_ORIGINS = %w[web booth]
|
||||
|
||||
belongs_to :question, -> { with_hidden }
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Poll::Recount < ApplicationRecord
|
||||
|
||||
VALID_ORIGINS = %w{web booth letter}.freeze
|
||||
VALID_ORIGINS = %w[web booth letter].freeze
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :booth_assignment
|
||||
|
||||
@@ -56,8 +56,8 @@ class ProposalNotification < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def set_author
|
||||
self.update(author_id: self.proposal.author_id) if self.proposal
|
||||
end
|
||||
def set_author
|
||||
self.update(author_id: self.proposal.author_id) if self.proposal
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class RelatedContent < ApplicationRecord
|
||||
RELATED_CONTENT_SCORE_THRESHOLD = Setting["related_content_score_threshold"].to_f
|
||||
RELATIONABLE_MODELS = %w{proposals debates budgets investments}.freeze
|
||||
RELATIONABLE_MODELS = %w[proposals debates budgets investments].freeze
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
@@ -36,28 +36,28 @@ class RelatedContent < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def create_opposite_related_content
|
||||
related_content = RelatedContent.create!(opposite_related_content: self, parent_relationable: child_relationable,
|
||||
child_relationable: parent_relationable, author: author)
|
||||
self.opposite_related_content = related_content
|
||||
end
|
||||
def create_opposite_related_content
|
||||
related_content = RelatedContent.create!(opposite_related_content: self, parent_relationable: child_relationable,
|
||||
child_relationable: parent_relationable, author: author)
|
||||
self.opposite_related_content = related_content
|
||||
end
|
||||
|
||||
def score(value, user)
|
||||
score_with_opposite(value, user)
|
||||
hide_with_opposite if (related_content_scores.sum(:value) / related_content_scores_count) < RELATED_CONTENT_SCORE_THRESHOLD
|
||||
end
|
||||
def score(value, user)
|
||||
score_with_opposite(value, user)
|
||||
hide_with_opposite if (related_content_scores.sum(:value) / related_content_scores_count) < RELATED_CONTENT_SCORE_THRESHOLD
|
||||
end
|
||||
|
||||
def hide_with_opposite
|
||||
hide
|
||||
opposite_related_content.hide
|
||||
end
|
||||
def hide_with_opposite
|
||||
hide
|
||||
opposite_related_content.hide
|
||||
end
|
||||
|
||||
def create_author_score
|
||||
score_positive(author)
|
||||
end
|
||||
def create_author_score
|
||||
score_positive(author)
|
||||
end
|
||||
|
||||
def score_with_opposite(value, user)
|
||||
RelatedContentScore.create(user: user, related_content: self, value: value)
|
||||
RelatedContentScore.create(user: user, related_content: opposite_related_content, value: value)
|
||||
end
|
||||
def score_with_opposite(value, user)
|
||||
RelatedContentScore.create(user: user, related_content: self, value: value)
|
||||
RelatedContentScore.create(user: user, related_content: opposite_related_content, value: value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ class Signature < ApplicationRecord
|
||||
end
|
||||
|
||||
def document_types
|
||||
%w(1 2 3 4)
|
||||
%w[1 2 3 4]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class SignatureSheet < ApplicationRecord
|
||||
belongs_to :signable, polymorphic: true
|
||||
belongs_to :author, class_name: "User", foreign_key: "author_id"
|
||||
|
||||
VALID_SIGNABLES = %w(Proposal Budget::Investment)
|
||||
VALID_SIGNABLES = %w[Proposal Budget::Investment]
|
||||
|
||||
has_many :signatures
|
||||
|
||||
|
||||
@@ -358,7 +358,6 @@ class User < ApplicationRecord
|
||||
followables.compact.map { |followable| followable.tags.map(&:name) }.flatten.compact.uniq
|
||||
end
|
||||
|
||||
|
||||
def self.current_user
|
||||
Thread.current[:user]
|
||||
end
|
||||
|
||||
@@ -110,7 +110,6 @@ class VotationType < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Widget::Feed < ApplicationRecord
|
||||
self.table_name = "widget_feeds"
|
||||
|
||||
KINDS = %w(proposals debates processes)
|
||||
KINDS = %w[proposals debates processes]
|
||||
|
||||
def active?
|
||||
setting.value.present?
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="row">
|
||||
<div class="small-12 medium-7 column">
|
||||
|
||||
<h2><%= t("account.show.personal")%></h2>
|
||||
<h2><%= t("account.show.personal") %></h2>
|
||||
|
||||
<div class="small-12 medium-10">
|
||||
<% if @account.organization? %>
|
||||
@@ -49,9 +49,8 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
<% if @account.email.present? %>
|
||||
<h2><%= t("account.show.notifications")%></h2>
|
||||
<h2><%= t("account.show.notifications") %></h2>
|
||||
|
||||
<div>
|
||||
<%= f.label :email_on_comment do %>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<strong><%= t("admin.menu.title_booths") %></strong>
|
||||
</a>
|
||||
<ul id="booths_menu" <%= "class=is-active" if menu_booths? || controller_name == "polls" && action_name == "booth_assignments" %>>
|
||||
<li <%= "class=is-active" if %w(officers officer_assignments).include?(controller_name) %>>
|
||||
<li <%= "class=is-active" if %w[officers officer_assignments].include?(controller_name) %>>
|
||||
<%= link_to t("admin.menu.poll_officers"), admin_officers_path %>
|
||||
</li>
|
||||
|
||||
@@ -74,8 +74,8 @@
|
||||
<%= link_to t("admin.menu.poll_booth_assignments"), booth_assignments_admin_polls_path %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=is-active" if %w(shifts booths).include?(controller_name) &&
|
||||
%w(available new).include?(action_name) %>>
|
||||
<li <%= "class=is-active" if %w[shifts booths].include?(controller_name) &&
|
||||
%w[available new].include?(action_name) %>>
|
||||
<%= link_to t("admin.menu.poll_shifts"), available_admin_booths_path %>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -90,7 +90,7 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% messages_sections = %w(newsletters emails_download admin_notifications system_emails) %>
|
||||
<% messages_sections = %w[newsletters emails_download admin_notifications system_emails] %>
|
||||
<% messages_menu_active = messages_sections.include?(controller_name) %>
|
||||
<li class="section-title" <%= "class=is-active" if messages_menu_active %>>
|
||||
<a href="#">
|
||||
@@ -205,7 +205,7 @@
|
||||
</li>
|
||||
|
||||
<li <%= "class=is-active" if controller_name == "moderators" %>>
|
||||
<%= link_to t("admin.menu.moderators"), admin_moderators_path%>
|
||||
<%= link_to t("admin.menu.moderators"), admin_moderators_path %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=is-active" if controller_name == "valuators" %>>
|
||||
@@ -281,7 +281,7 @@
|
||||
<span class="icon-settings"></span>
|
||||
<strong><%= t("admin.menu.title_settings") %></strong>
|
||||
</a>
|
||||
<ul <%="class=is-active" if menu_settings? %>>
|
||||
<ul <%= "class=is-active" if menu_settings? %>>
|
||||
<li <%= "class=is-active" if controller_name == "settings" %>>
|
||||
<%= link_to t("admin.menu.settings"), admin_settings_path %>
|
||||
</li>
|
||||
@@ -300,7 +300,7 @@
|
||||
</li>
|
||||
|
||||
<li <%= "class=is-active" if controller_name == "content_blocks" %>>
|
||||
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path%>
|
||||
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=is-active" if submenu_local_census_records? %>>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
|
||||
</thead>
|
||||
<% @administrators.each do |administrator| %>
|
||||
<tr id="<%= dom_id(administrator)%>">
|
||||
<tr id="<%= dom_id(administrator) %>">
|
||||
<td class="text-center">
|
||||
<%= administrator.id %>
|
||||
</td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
<% if @banner.errors.any? %>
|
||||
|
||||
|
||||
<div id="error_explanation" data-alert class="callout alert" data-closable>
|
||||
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
@@ -12,4 +12,4 @@
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
class: "js-calendar-full",
|
||||
id: "post_started_at" %>
|
||||
</div>
|
||||
<% date_ended_at = @banner.post_ended_at.present? ? I18n.localize(@banner.post_ended_at) : ""%>
|
||||
<% date_ended_at = @banner.post_ended_at.present? ? I18n.localize(@banner.post_ended_at) : "" %>
|
||||
<div class="small-12 medium-3 column end">
|
||||
<%= f.label :post_ended_at, t("admin.banners.banner.post_ended_at") %>
|
||||
<%= f.text_field :post_ended_at,
|
||||
@@ -40,7 +40,7 @@
|
||||
<%= translations_form.text_field :description,
|
||||
placeholder: t("admin.banners.banner.description"),
|
||||
data: {js_banner_description: "js_banner_description"},
|
||||
label: t("admin.banners.banner.description") %>
|
||||
label: t("admin.banners.banner.description") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr id="<%= dom_id(banner) %>">
|
||||
<th scope="col"><%= t("admin.banners.banner.post_started_at")%></th>
|
||||
<th scope="col"><%= t("admin.banners.banner.post_ended_at")%></th>
|
||||
<th scope="col" class="small-4"><%= t("admin.actions.actions")%></th>
|
||||
<th scope="col"><%= t("admin.banners.banner.post_started_at") %></th>
|
||||
<th scope="col"><%= t("admin.banners.banner.post_ended_at") %></th>
|
||||
<th scope="col" class="small-4"><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<a class="small float-right clear" data-open="download-modal"><%= t("admin.budget_investments.index.download_current_selection") %></a>
|
||||
|
||||
|
||||
<% if params[:advanced_filters].include?("winners") %>
|
||||
<% if display_calculate_winners_button?(@budget) %>
|
||||
<%= link_to calculate_winner_button_text(@budget),
|
||||
@@ -9,7 +8,7 @@
|
||||
class: "button hollow float-right clear" %>
|
||||
<% else %>
|
||||
<span class="button hollow disabled float-right clear">
|
||||
<%= t("admin.budgets.winners.calculate")%>
|
||||
<%= t("admin.budgets.winners.calculate") %>
|
||||
</span>
|
||||
<div class="callout warning clear">
|
||||
<%= t("admin.budget_investments.index.cannot_calculate_winners") %>
|
||||
@@ -28,7 +27,7 @@
|
||||
<table class="table-for-mobile column-selecteable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= link_to_investments_sorted_by :id %></th>
|
||||
<th><%= link_to_investments_sorted_by :id %></th>
|
||||
<th data-field="title"><%= link_to_investments_sorted_by :title %></th>
|
||||
<th data-field="supports"><%= link_to_investments_sorted_by :supports %></th>
|
||||
<th data-field="admin"><%= t("admin.budget_investments.index.list.admin") %></th>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user