Merge pull request #5154 from consuldemocracy/multiline_rubocop
Add Rubocop rules for multiline statements
This commit is contained in:
76
.rubocop.yml
76
.rubocop.yml
@@ -18,9 +18,41 @@ Bundler/OrderedGems:
|
||||
Enabled: true
|
||||
ConsiderPunctuation: true
|
||||
|
||||
Layout/ArgumentAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/ArrayAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/AssignmentIndentation:
|
||||
Enabled: true
|
||||
|
||||
Layout/BeginEndAlignment:
|
||||
Enabled: true
|
||||
EnforcedStyleAlignWith: begin
|
||||
|
||||
Layout/BlockAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/BlockEndNewline:
|
||||
Enabled: true
|
||||
|
||||
Layout/ClosingHeredocIndentation:
|
||||
Enabled: true
|
||||
|
||||
Layout/ClosingParenthesisIndentation:
|
||||
Enabled: true
|
||||
|
||||
Layout/DefEndAlignment:
|
||||
Enabled: true
|
||||
EnforcedStyleAlignWith: def
|
||||
|
||||
Layout/DotPosition:
|
||||
Enabled: true
|
||||
|
||||
Layout/ElseAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/EmptyLineAfterGuardClause:
|
||||
Enabled: true
|
||||
|
||||
@@ -45,12 +77,26 @@ Layout/EmptyLinesAroundMethodBody:
|
||||
Layout/EmptyLinesAroundModuleBody:
|
||||
Enabled: true
|
||||
|
||||
Layout/EndAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/EndOfLine:
|
||||
EnforcedStyle: lf
|
||||
|
||||
Layout/ExtraSpacing:
|
||||
Enabled: true
|
||||
|
||||
Layout/FirstArrayElementIndentation:
|
||||
Enabled: true
|
||||
EnforcedStyle: consistent
|
||||
|
||||
Layout/FirstHashElementIndentation:
|
||||
Enabled: true
|
||||
EnforcedStyle: consistent
|
||||
|
||||
Layout/HashAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/HeredocIndentation:
|
||||
Enabled: true
|
||||
|
||||
@@ -66,6 +112,9 @@ Layout/IndentationWidth:
|
||||
Layout/LeadingEmptyLines:
|
||||
Enabled: true
|
||||
|
||||
Layout/LineContinuationSpacing:
|
||||
Enabled: true
|
||||
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
Enabled: true
|
||||
|
||||
@@ -73,9 +122,33 @@ Layout/LineLength:
|
||||
Max: 110
|
||||
Severity: refactor
|
||||
|
||||
Layout/MultilineArrayBraceLayout:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineBlockLayout:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineHashBraceLayout:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineHashKeyLineBreaks:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineMethodCallBraceLayout:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineOperationIndentation:
|
||||
Enabled: true
|
||||
|
||||
Layout/ParameterAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/RescueEnsureAlignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/SpaceAfterColon:
|
||||
Enabled: true
|
||||
|
||||
@@ -523,6 +596,9 @@ Style/IdenticalConditionalBranches:
|
||||
Style/IfWithBooleanLiteralBranches:
|
||||
Enabled: true
|
||||
|
||||
Style/LineEndConcatenation:
|
||||
Enabled: true
|
||||
|
||||
Style/MapToHash:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
|
||||
<% if feature?(:map) %>
|
||||
<%= f.select :geozone_id,
|
||||
geozone_options,
|
||||
include_blank: t("geozones.none"),
|
||||
hint: t("admin.budget_headings.form.geozone_info") %>
|
||||
geozone_options,
|
||||
include_blank: t("geozones.none"),
|
||||
hint: t("admin.budget_headings.form.geozone_info") %>
|
||||
<% end %>
|
||||
|
||||
<% if heading.budget.approval_voting? %>
|
||||
<%= f.number_field :max_ballot_lines,
|
||||
hint: t("admin.budget_headings.form.max_ballot_lines_info") %>
|
||||
hint: t("admin.budget_headings.form.max_ballot_lines_info") %>
|
||||
<% end %>
|
||||
|
||||
<%= f.text_field :population,
|
||||
maxlength: 8,
|
||||
data: { toggle_focus: "population-info" },
|
||||
hint: t("admin.budget_headings.form.population_info") %>
|
||||
maxlength: 8,
|
||||
data: { toggle_focus: "population-info" },
|
||||
hint: t("admin.budget_headings.form.population_info") %>
|
||||
|
||||
<%= f.text_field :latitude, maxlength: 22 %>
|
||||
<%= f.text_field :longitude, maxlength: 22 %>
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= translations_form.text_area :description,
|
||||
maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH,
|
||||
class: "html-area",
|
||||
hint: t("admin.budget_phases.edit.description_help_text") %>
|
||||
maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH,
|
||||
class: "html-area",
|
||||
hint: t("admin.budget_phases.edit.description_help_text") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
<%= enabled_cell(phase) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(phase,
|
||||
<%= render Admin::TableActionsComponent.new(
|
||||
phase,
|
||||
actions: [:edit],
|
||||
edit_path: edit_path(phase)
|
||||
) %>
|
||||
|
||||
@@ -83,10 +83,10 @@ class Admin::Budgets::ActionsComponent < ApplicationComponent
|
||||
balloting_phase = budget.phases.find_by(kind: "balloting")
|
||||
|
||||
admin_polls_path(poll: {
|
||||
name: budget.name,
|
||||
name: budget.name,
|
||||
budget_id: budget.id,
|
||||
starts_at: balloting_phase.starts_at,
|
||||
ends_at: balloting_phase.ends_at
|
||||
ends_at: balloting_phase.ends_at
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-9 large-6 column end">
|
||||
<%= translations_form.text_field :name,
|
||||
maxlength: Budget.title_max_length,
|
||||
hint: t("admin.budgets.edit.name_description") %>
|
||||
maxlength: Budget.title_max_length,
|
||||
hint: t("admin.budgets.edit.name_description") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row expanded">
|
||||
@@ -67,9 +67,9 @@
|
||||
<% %w[administrators valuators].each do |staff| %>
|
||||
<div class="small-12 medium-6 large-3 column end">
|
||||
<%= link_to t("admin.budgets.edit.#{staff}", count: budget.send(staff).count),
|
||||
"#",
|
||||
class: "button expanded hollow js-budget-show-#{staff}-list js-budget-show-users-list",
|
||||
data: { toggle: "#{staff}_list", texts: t("admin.budgets.edit.#{staff}") } %>
|
||||
"#",
|
||||
class: "button expanded hollow js-budget-show-#{staff}-list js-budget-show-users-list",
|
||||
data: { toggle: "#{staff}_list", texts: t("admin.budgets.edit.#{staff}") } %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -41,6 +41,6 @@
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.submit(value: t("admin.geozones.edit.form.submit_button"),
|
||||
class: "button success") %>
|
||||
class: "button success") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
<div class="callout primary">
|
||||
<p>
|
||||
<%= sanitize(t("admin.machine_learning.feature_disabled",
|
||||
link: link_to(t("admin.machine_learning.feature_disabled_link"),
|
||||
admin_settings_path(anchor: "tab-feature-flags")))) %>
|
||||
link: link_to(t("admin.machine_learning.feature_disabled_link"),
|
||||
admin_settings_path(anchor: "tab-feature-flags")))) %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -41,7 +41,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
def polls?
|
||||
controller.class.module_parent == Admin::Poll::Questions::Answers ||
|
||||
%w[polls active_polls recounts results questions answers].include?(controller_name) &&
|
||||
action_name != "booth_assignments"
|
||||
action_name != "booth_assignments"
|
||||
end
|
||||
|
||||
def booths?
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
</td>
|
||||
<td>
|
||||
<% if officer.persisted? %>
|
||||
<%= render Admin::TableActionsComponent.new(officer,
|
||||
<%= render Admin::TableActionsComponent.new(
|
||||
officer,
|
||||
actions: [:destroy],
|
||||
destroy_text: t("admin.poll_officers.officer.delete"),
|
||||
destroy_options: { class: "destroy-officer-link" }
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
<% else %>
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= f.select :poll_id,
|
||||
options_for_select(select_options),
|
||||
prompt: t("admin.questions.index.select_poll"),
|
||||
hint: t("admin.questions.form.poll_help") %>
|
||||
options_for_select(select_options),
|
||||
prompt: t("admin.questions.index.select_poll"),
|
||||
hint: t("admin.questions.form.poll_help") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<% if already_has_role? %>
|
||||
<%= render Admin::TableActionsComponent.new(record,
|
||||
<%= render Admin::TableActionsComponent.new(
|
||||
record,
|
||||
actions: actions,
|
||||
destroy_options: { class: "destroy-role-link" }
|
||||
) %>
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
rows: 5,
|
||||
class: "js-globalize-attribute",
|
||||
style: site_customization_display_translation_style(locale),
|
||||
data: { locale: locale } %>
|
||||
data: { locale: locale } %>
|
||||
<% end %>
|
||||
|
||||
@@ -46,10 +46,10 @@ class Attachable::FieldsComponent < ApplicationComponent
|
||||
def file_field
|
||||
klass = attachable.persisted? || attachable.cached_attachment.present? ? " hide" : ""
|
||||
f.file_field :attachment,
|
||||
label_options: { class: "button hollow #{klass}" },
|
||||
accept: accepted_content_types_extensions,
|
||||
class: "js-#{singular_name}-attachment",
|
||||
data: { url: direct_upload_path }
|
||||
label_options: { class: "button hollow #{klass}" },
|
||||
accept: accepted_content_types_extensions,
|
||||
class: "js-#{singular_name}-attachment",
|
||||
data: { url: direct_upload_path }
|
||||
end
|
||||
|
||||
def direct_upload_path
|
||||
|
||||
@@ -2,21 +2,22 @@
|
||||
<div class="filter">
|
||||
<%= label_tag :milestone_tag, t("budgets.executions.filters.milestone_tag.label") %>
|
||||
<%= select_tag :milestone_tag,
|
||||
options_for_select(
|
||||
options_for_milestone_tags,
|
||||
params[:milestone_tag]
|
||||
),
|
||||
prompt: t("budgets.executions.filters.milestone_tag.all",
|
||||
count: budget.investments.winners.with_milestones.count) %>
|
||||
options_for_select(
|
||||
options_for_milestone_tags,
|
||||
params[:milestone_tag]
|
||||
),
|
||||
prompt: t("budgets.executions.filters.milestone_tag.all",
|
||||
count: budget.investments.winners.with_milestones.count) %>
|
||||
</div>
|
||||
<div class="filter">
|
||||
<%= label_tag :status, t("budgets.executions.filters.status.label") %>
|
||||
<%= select_tag :status,
|
||||
options_from_collection_for_select(statuses,
|
||||
:id, lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
|
||||
params[:status]),
|
||||
prompt: t("budgets.executions.filters.status.all",
|
||||
count: budget.investments.winners.with_milestones.count) %>
|
||||
options_from_collection_for_select(statuses,
|
||||
:id,
|
||||
lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
|
||||
params[:status]),
|
||||
prompt: t("budgets.executions.filters.status.all",
|
||||
count: budget.investments.winners.with_milestones.count) %>
|
||||
</div>
|
||||
<div class="submit">
|
||||
<%= submit_tag t("shared.filter") %>
|
||||
|
||||
@@ -9,7 +9,9 @@ class Budgets::Executions::ImageComponent < ApplicationComponent
|
||||
private
|
||||
|
||||
def milestone
|
||||
investment.milestones.order_by_publication_date
|
||||
.select { |milestone| milestone.image.present? }.last
|
||||
investment.milestones
|
||||
.order_by_publication_date
|
||||
.select { |milestone| milestone.image.present? }
|
||||
.last
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
<div>
|
||||
<%= translations_form.text_field :title,
|
||||
maxlength: Budget::Investment.title_max_length,
|
||||
data: suggest_data(investment) %>
|
||||
maxlength: Budget::Investment.title_max_length,
|
||||
data: suggest_data(investment) %>
|
||||
</div>
|
||||
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
|
||||
|
||||
<div>
|
||||
<%= translations_form.text_area :description,
|
||||
maxlength: Budget::Investment.description_max_length,
|
||||
class: "html-area" %>
|
||||
maxlength: Budget::Investment.description_max_length,
|
||||
class: "html-area" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
@@ -51,10 +51,10 @@
|
||||
<% if feature?(:map) %>
|
||||
<div>
|
||||
<%= render "map_locations/form_fields",
|
||||
form: f,
|
||||
form: f,
|
||||
map_location: investment.map_location || MapLocation.new,
|
||||
label: t("budgets.investments.form.map_location"),
|
||||
help: t("budgets.investments.form.map_location_instructions"),
|
||||
label: t("budgets.investments.form.map_location"),
|
||||
help: t("budgets.investments.form.map_location_instructions"),
|
||||
i18n_namespace: "budgets.investments" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -80,11 +80,11 @@
|
||||
|
||||
<br>
|
||||
<%= f.text_field :tag_list, value: investment.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("budgets.investments.form.tags_placeholder"),
|
||||
aria: { describedby: "tags-list-help-text" },
|
||||
class: "js-tag-list tag-autocomplete",
|
||||
data: { js_url: suggest_tags_path } %>
|
||||
label: false,
|
||||
placeholder: t("budgets.investments.form.tags_placeholder"),
|
||||
aria: { describedby: "tags-list-help-text" },
|
||||
class: "js-tag-list tag-autocomplete",
|
||||
data: { js_url: suggest_tags_path } %>
|
||||
</div>
|
||||
|
||||
<%= render SDG::RelatedListSelectorComponent.new(f) %>
|
||||
@@ -94,11 +94,10 @@
|
||||
<% unless current_user.manager? || investment.persisted? %>
|
||||
<div>
|
||||
<%= f.check_box :terms_of_service,
|
||||
title: t("form.accept_terms_title"),
|
||||
label: t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
|
||||
) %>
|
||||
title: t("form.accept_terms_title"),
|
||||
label: t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
<% elsif assigned_heading.present? %>
|
||||
<p>
|
||||
<%= sanitize(t("budgets.investments.index.sidebar.different_heading_assigned",
|
||||
heading_link: heading_link(assigned_heading, budget)
|
||||
)) %>
|
||||
heading_link: heading_link(assigned_heading, budget))) %>
|
||||
<br>
|
||||
<small>
|
||||
<%= sanitize(t("budgets.investments.index.sidebar.change_ballot",
|
||||
check_ballot: link_to(t("budgets.investments.index.sidebar.check_ballot_link"),
|
||||
budget_ballot_path(budget)))) %>
|
||||
check_ballot: link_to(t("budgets.investments.index.sidebar.check_ballot_link"),
|
||||
budget_ballot_path(budget)))) %>
|
||||
</small>
|
||||
</p>
|
||||
<% else %>
|
||||
@@ -26,7 +25,8 @@
|
||||
<p>
|
||||
<%= sanitize(ballot.change_vote_info(
|
||||
link: link_to(t("budgets.investments.index.sidebar.change_vote_link"),
|
||||
budget_ballot_path(budget)))) %>
|
||||
budget_ballot_path(budget))
|
||||
)) %>
|
||||
</p>
|
||||
|
||||
<ul class="ballot-list">
|
||||
@@ -39,6 +39,6 @@
|
||||
</ul>
|
||||
|
||||
<%= link_to t("budgets.investments.header.check_ballot"),
|
||||
budget_ballot_path(budget),
|
||||
class: "button hollow expanded" %>
|
||||
budget_ballot_path(budget),
|
||||
class: "button hollow expanded" %>
|
||||
</div>
|
||||
|
||||
@@ -13,22 +13,22 @@
|
||||
</div>
|
||||
<% if feature?(:remove_investments_supports) %>
|
||||
<%= button_to remove_support_path,
|
||||
class: "button button-remove-support expanded",
|
||||
method: "delete",
|
||||
remote: true,
|
||||
"aria-label": remove_support_aria_label do %>
|
||||
class: "button button-remove-support expanded",
|
||||
method: "delete",
|
||||
remote: true,
|
||||
"aria-label": remove_support_aria_label do %>
|
||||
<%= t("budgets.investments.votes.remove_support") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= button_to t("budgets.investments.votes.support"), support_path,
|
||||
class: "button button-support expanded",
|
||||
title: t("budgets.investments.investment.support_title"),
|
||||
method: "post",
|
||||
remote: !display_support_alert?,
|
||||
data: ({ confirm: confirm_vote_message } if display_support_alert?),
|
||||
"aria-label": support_aria_label %>
|
||||
class: "button button-support expanded",
|
||||
title: t("budgets.investments.investment.support_title"),
|
||||
method: "post",
|
||||
remote: !display_support_alert?,
|
||||
data: ({ confirm: confirm_vote_message } if display_support_alert?),
|
||||
"aria-label": support_aria_label %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -38,11 +38,11 @@
|
||||
<% if user_voted_for? && setting["twitter_handle"] %>
|
||||
<div class="share-supported">
|
||||
<%= render "shared/social_share",
|
||||
title: investment.title,
|
||||
image_url: image_absolute_url(investment.image, :thumb),
|
||||
url: budget_investment_url(investment.budget, investment),
|
||||
description: investment.title,
|
||||
mobile: investment.title %>
|
||||
title: investment.title,
|
||||
image_url: image_absolute_url(investment.image, :thumb),
|
||||
url: budget_investment_url(investment.budget, investment),
|
||||
description: investment.title,
|
||||
mobile: investment.title %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
<% else %>
|
||||
<div class="callout warning">
|
||||
<%= sanitize(t("budgets.investments.index.sidebar.verified_only",
|
||||
verify: link_to_verify_account)) %>
|
||||
verify: link_to_verify_account)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="callout primary">
|
||||
<%= sanitize(t("budgets.investments.index.sidebar.not_logged_in",
|
||||
sign_in: link_to_signin, sign_up: link_to_signup)) %>
|
||||
sign_in: link_to_signin, sign_up: link_to_signup)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</header>
|
||||
|
||||
<p><%= t("budgets.supports_info.time",
|
||||
phase_end_date: l(budget.current_phase.ends_at.to_date, format: :long)) %></p>
|
||||
phase_end_date: l(budget.current_phase.ends_at.to_date, format: :long)) %></p>
|
||||
|
||||
<p><%= t("budgets.supports_info.share") %></p>
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
<span class="in-favor">
|
||||
<%= button_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post",
|
||||
remote: can?(:vote, comment),
|
||||
title: t("votes.agree") do %>
|
||||
method: "post",
|
||||
remote: can?(:vote, comment),
|
||||
title: t("votes.agree") do %>
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
<span class="against">
|
||||
<%= button_to vote_comment_path(comment, value: "no"),
|
||||
method: "post",
|
||||
remote: can?(:vote, comment),
|
||||
title: t("votes.disagree") do %>
|
||||
method: "post",
|
||||
remote: can?(:vote, comment),
|
||||
title: t("votes.disagree") do %>
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
<div>
|
||||
<%= translations_form.text_field :title,
|
||||
maxlength: Debate.title_max_length,
|
||||
data: suggest_data(debate) %>
|
||||
maxlength: Debate.title_max_length,
|
||||
data: suggest_data(debate) %>
|
||||
</div>
|
||||
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
|
||||
|
||||
<div>
|
||||
<%= translations_form.text_area :description,
|
||||
maxlength: Debate.description_max_length,
|
||||
class: "html-area" %>
|
||||
maxlength: Debate.description_max_length,
|
||||
class: "html-area" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
<div>
|
||||
<%= f.text_field :tag_list, value: debate.tag_list.to_s,
|
||||
hint: t("debates.form.tags_instructions"),
|
||||
placeholder: t("debates.form.tags_placeholder"),
|
||||
data: { js_url: suggest_tags_path },
|
||||
class: "tag-autocomplete" %>
|
||||
hint: t("debates.form.tags_instructions"),
|
||||
placeholder: t("debates.form.tags_placeholder"),
|
||||
data: { js_url: suggest_tags_path },
|
||||
class: "tag-autocomplete" %>
|
||||
</div>
|
||||
|
||||
<%= render SDG::RelatedListSelectorComponent.new(f) %>
|
||||
@@ -42,11 +42,10 @@
|
||||
<% if debate.new_record? %>
|
||||
<div>
|
||||
<%= f.check_box :terms_of_service,
|
||||
title: t("form.accept_terms_title"),
|
||||
label: t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
|
||||
) %>
|
||||
title: t("form.accept_terms_title"),
|
||||
label: t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ class Documents::NestedComponent < ApplicationComponent
|
||||
|
||||
def note
|
||||
t "documents.form.note", max_documents_allowed: max_documents_allowed,
|
||||
accepted_content_types: Document.humanized_accepted_content_types,
|
||||
max_file_size: documentable.class.max_file_size
|
||||
accepted_content_types: Document.humanized_accepted_content_types,
|
||||
max_file_size: documentable.class.max_file_size
|
||||
end
|
||||
|
||||
def max_documents_allowed?
|
||||
|
||||
@@ -14,6 +14,6 @@ class Images::NestedComponent < ApplicationComponent
|
||||
|
||||
def note
|
||||
t "images.form.note", accepted_content_types: Image.humanized_accepted_content_types,
|
||||
max_file_size: Image.max_file_size
|
||||
max_file_size: Image.max_file_size
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
<p class="info">
|
||||
<%= sanitize(t("layouts.footer.description",
|
||||
open_source: link_to(t("layouts.footer.open_source"), t("layouts.footer.open_source_url"), target: "blank", rel: "nofollow"),
|
||||
consul: link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), target: "blank", rel: "nofollow"))) %>
|
||||
open_source: link_to(t("layouts.footer.open_source"), t("layouts.footer.open_source_url"), target: "blank", rel: "nofollow"),
|
||||
consul: link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), target: "blank", rel: "nofollow"))) %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<% if user %>
|
||||
<li>
|
||||
<%= layout_menu_link_to t("layouts.header.my_activity_link"),
|
||||
user_path(user),
|
||||
controller_name == "users",
|
||||
rel: "nofollow",
|
||||
title: t("shared.go_to_page") +
|
||||
t("layouts.header.my_activity_link") %>
|
||||
user_path(user),
|
||||
controller_name == "users",
|
||||
rel: "nofollow",
|
||||
title: t("shared.go_to_page") +
|
||||
t("layouts.header.my_activity_link") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= layout_menu_link_to t("layouts.header.my_account_link"),
|
||||
account_path,
|
||||
controller_name == "account",
|
||||
rel: "nofollow",
|
||||
title: t("shared.go_to_page") +
|
||||
t("layouts.header.my_account_link") %>
|
||||
account_path,
|
||||
controller_name == "account",
|
||||
rel: "nofollow",
|
||||
title: t("shared.go_to_page") +
|
||||
t("layouts.header.my_account_link") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t("devise_views.menu.login_items.logout"),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<% if user %>
|
||||
<li id="notifications">
|
||||
<%= link_to notifications_path, rel: "nofollow", title: text,
|
||||
class: "notifications #{notifications_class}" do %>
|
||||
<%= link_to notifications_path, rel: "nofollow",
|
||||
title: text,
|
||||
class: "notifications #{notifications_class}" do %>
|
||||
<span class="show-for-sr">
|
||||
<%= t("layouts.header.notification_item.notifications") %>
|
||||
</span>
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
<% if feature?(:polls) %>
|
||||
<li>
|
||||
<%= layout_menu_link_to t("layouts.header.poll_questions"),
|
||||
polls_path,
|
||||
controller_name == "polls" || (controller_name == "questions" && controller.class.module_parent == Polls),
|
||||
accesskey: "3" %>
|
||||
polls_path,
|
||||
controller_name == "polls" || (controller_name == "questions" && controller.class.module_parent == Polls),
|
||||
accesskey: "3" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if feature?(:legislation) %>
|
||||
@@ -37,9 +37,9 @@
|
||||
<% if feature?(:budgets) %>
|
||||
<li>
|
||||
<%= layout_menu_link_to t("layouts.header.budgets"),
|
||||
budgets_path,
|
||||
controller_name == "budgets" || controller_name == "investments",
|
||||
accesskey: "5" %>
|
||||
budgets_path,
|
||||
controller_name == "budgets" || controller_name == "investments",
|
||||
accesskey: "5" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if feature?(:sdg) %>
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
<% if current_user&.voted_as_when_voted_for(proposal) && setting["twitter_handle"] %>
|
||||
<div class="share-supported">
|
||||
<%= render "shared/social_share",
|
||||
title: proposal.title,
|
||||
url: proposal_url(proposal),
|
||||
description: proposal.summary,
|
||||
mobile: proposal.title %>
|
||||
title: proposal.title,
|
||||
url: proposal_url(proposal),
|
||||
description: proposal.summary,
|
||||
mobile: proposal.title %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<td><%= budget.current_phase.name %></td>
|
||||
<td align="right">
|
||||
<%= link_to t("management.budgets.print_investments"),
|
||||
print_management_budget_investments_path(budget) %>
|
||||
print_management_budget_investments_path(budget) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
<div>
|
||||
<%= translations_form.text_field :title,
|
||||
maxlength: Proposal.title_max_length,
|
||||
data: suggest_data(proposal) %>
|
||||
maxlength: Proposal.title_max_length,
|
||||
data: suggest_data(proposal) %>
|
||||
</div>
|
||||
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
|
||||
|
||||
@@ -52,17 +52,17 @@
|
||||
<% if Geozone.any? %>
|
||||
<div>
|
||||
<%= f.select :geozone_id, geozone_select_options,
|
||||
include_blank: t("geozones.none") %>
|
||||
include_blank: t("geozones.none") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:map) %>
|
||||
<div>
|
||||
<%= render "map_locations/form_fields",
|
||||
form: f,
|
||||
form: f,
|
||||
map_location: proposal.map_location || MapLocation.new,
|
||||
label: t("proposals.form.map_location"),
|
||||
help: t("proposals.form.map_location_instructions"),
|
||||
label: t("proposals.form.map_location"),
|
||||
help: t("proposals.form.map_location_instructions"),
|
||||
i18n_namespace: "proposals" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -80,17 +80,17 @@
|
||||
|
||||
<br>
|
||||
<%= f.text_field :tag_list, value: proposal.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("proposals.form.tags_placeholder"),
|
||||
class: "js-tag-list tag-autocomplete",
|
||||
aria: { describedby: "tag-list-help-text" },
|
||||
data: { js_url: suggest_tags_path } %>
|
||||
label: false,
|
||||
placeholder: t("proposals.form.tags_placeholder"),
|
||||
class: "js-tag-list tag-autocomplete",
|
||||
aria: { describedby: "tag-list-help-text" },
|
||||
data: { js_url: suggest_tags_path } %>
|
||||
</div>
|
||||
|
||||
<% if current_user.unverified? %>
|
||||
<div>
|
||||
<%= f.text_field :responsible_name,
|
||||
hint: t("proposals.form.proposal_responsible_name_note") %>
|
||||
hint: t("proposals.form.proposal_responsible_name_note") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -101,11 +101,10 @@
|
||||
<% if proposal.new_record? %>
|
||||
<div>
|
||||
<%= f.check_box :terms_of_service,
|
||||
title: t("form.accept_terms_title"),
|
||||
label: t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
|
||||
) %>
|
||||
title: t("form.accept_terms_title"),
|
||||
label: t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
</div>
|
||||
<% else %>
|
||||
<%= button_to vote_url,
|
||||
class: "button button-support small expanded",
|
||||
title: t("proposals.proposal.support_title"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
"aria-label": support_aria_label do %>
|
||||
class: "button button-support small expanded",
|
||||
title: t("proposals.proposal.support_title"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
"aria-label": support_aria_label do %>
|
||||
<%= t("proposals.proposal.support") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
</fieldset>
|
||||
|
||||
<%= f.text_field :related_sdg_list,
|
||||
class: "input",
|
||||
hint: sanitize(t("sdg.related_list_selector.hint",
|
||||
class: "input",
|
||||
hint: sanitize(t("sdg.related_list_selector.hint",
|
||||
link: link_to(t("sdg.related_list_selector.help.text"),
|
||||
sdg_help_path,
|
||||
title: t("shared.target_blank"),
|
||||
target: "_blank")),
|
||||
attributes: %w[href title target]),
|
||||
data: { "suggestions-list": sdg_related_suggestions,
|
||||
"remove-tag-text": t("sdg.related_list_selector.remove_tag") } %>
|
||||
sdg_help_path,
|
||||
title: t("shared.target_blank"),
|
||||
target: "_blank")),
|
||||
attributes: %w[href title target]),
|
||||
data: { "suggestions-list": sdg_related_suggestions,
|
||||
"remove-tag-text": t("sdg.related_list_selector.remove_tag") } %>
|
||||
</div>
|
||||
|
||||
<div class="help-section callout primary hide">
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<div class="filter">
|
||||
<label for="js-advanced-search-date-min"><%= t("shared.advanced_search.date") %></label>
|
||||
<%= select_tag("advanced_search[date_min]", date_range_options,
|
||||
include_blank: t("shared.advanced_search.date_range_blank"),
|
||||
id: "js-advanced-search-date-min") %>
|
||||
include_blank: t("shared.advanced_search.date_range_blank"),
|
||||
id: "js-advanced-search-date-min") %>
|
||||
</div>
|
||||
|
||||
<div id="js-custom-date" class="custom-date-filters" style="display: none">
|
||||
@@ -25,16 +25,16 @@
|
||||
<%= t("shared.advanced_search.from") %> (<%= t("shared.advanced_search.date_placeholder") %>)
|
||||
</label>
|
||||
<%= text_field_tag "advanced_search[date_min]",
|
||||
advanced_search[:date_min],
|
||||
class: "js-calendar" %>
|
||||
advanced_search[:date_min],
|
||||
class: "js-calendar" %>
|
||||
</div>
|
||||
<div class="filter">
|
||||
<label for="advanced_search_date_max">
|
||||
<%= t("shared.advanced_search.to") %> (<%= t("shared.advanced_search.date_placeholder") %>)
|
||||
</label>
|
||||
<%= text_field_tag "advanced_search[date_max]",
|
||||
advanced_search[:date_max],
|
||||
class: "js-calendar" %>
|
||||
advanced_search[:date_max],
|
||||
class: "js-calendar" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -43,12 +43,12 @@
|
||||
<div class="filter">
|
||||
<label for="advanced_search_goal"><%= t("shared.advanced_search.goal") %></label>
|
||||
<%= select_tag("advanced_search[goal]", goal_options,
|
||||
include_blank: t("shared.advanced_search.goal_blank")) %>
|
||||
include_blank: t("shared.advanced_search.goal_blank")) %>
|
||||
</div>
|
||||
<div class="filter">
|
||||
<label for="advanced_search_target"><%= t("shared.advanced_search.target") %></label>
|
||||
<%= select_tag("advanced_search[target]", target_options,
|
||||
include_blank: t("shared.advanced_search.target_blank")) %>
|
||||
include_blank: t("shared.advanced_search.target_blank")) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -8,13 +8,16 @@ class Shared::AdvancedSearchComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def date_range_options
|
||||
options_for_select([
|
||||
[t("shared.advanced_search.date_1"), 1],
|
||||
[t("shared.advanced_search.date_2"), 2],
|
||||
[t("shared.advanced_search.date_3"), 3],
|
||||
[t("shared.advanced_search.date_4"), 4],
|
||||
[t("shared.advanced_search.date_5"), "custom"]],
|
||||
selected_date_range)
|
||||
options_for_select(
|
||||
[
|
||||
[t("shared.advanced_search.date_1"), 1],
|
||||
[t("shared.advanced_search.date_2"), 2],
|
||||
[t("shared.advanced_search.date_3"), 3],
|
||||
[t("shared.advanced_search.date_4"), 4],
|
||||
[t("shared.advanced_search.date_5"), "custom"]
|
||||
],
|
||||
selected_date_range
|
||||
)
|
||||
end
|
||||
|
||||
def selected_date_range
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<div class="in-favor-against">
|
||||
<div class="in-favor">
|
||||
<%= button_to polymorphic_path(votable, action: :vote, value: "yes"),
|
||||
class: "like #{voted_classes[:in_favor]}",
|
||||
title: t("votes.agree"),
|
||||
"aria-label": agree_aria_label,
|
||||
method: "post",
|
||||
remote: true do %>
|
||||
class: "like #{voted_classes[:in_favor]}",
|
||||
title: t("votes.agree"),
|
||||
"aria-label": agree_aria_label,
|
||||
method: "post",
|
||||
remote: true do %>
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
<% end %>
|
||||
<span class="percentage"><%= votes_percentage("likes", votable) %></span>
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
<div class="against">
|
||||
<%= button_to polymorphic_path(votable, action: :vote, value: "no"),
|
||||
class: "unlike #{voted_classes[:against]}",
|
||||
title: t("votes.disagree"),
|
||||
"aria-label": disagree_aria_label,
|
||||
method: "post",
|
||||
remote: true do %>
|
||||
class: "unlike #{voted_classes[:against]}",
|
||||
title: t("votes.disagree"),
|
||||
"aria-label": disagree_aria_label,
|
||||
method: "post",
|
||||
remote: true do %>
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
<% end %>
|
||||
<span class="percentage"><%= votes_percentage("dislikes", votable) %></span>
|
||||
|
||||
@@ -40,9 +40,9 @@ class Shared::MapLocationComponent < ApplicationComponent
|
||||
|
||||
def remove_marker
|
||||
button_tag remove_marker_label,
|
||||
id: remove_marker_id,
|
||||
class: "map-location-remove-marker",
|
||||
type: "button"
|
||||
id: remove_marker_id,
|
||||
class: "map-location-remove-marker",
|
||||
type: "button"
|
||||
end
|
||||
|
||||
def data
|
||||
|
||||
@@ -47,18 +47,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
web_section_ids: []]
|
||||
end
|
||||
|
||||
def banner_styles
|
||||
@banner_styles = Setting.all.banner_style.map do |banner_style|
|
||||
[banner_style.value, banner_style.key.split(".")[1]]
|
||||
end
|
||||
end
|
||||
|
||||
def banner_imgs
|
||||
@banner_imgs = Setting.all.banner_img.map do |banner_img|
|
||||
[banner_img.value, banner_img.key.split(".")[1]]
|
||||
end
|
||||
end
|
||||
|
||||
def banner_sections
|
||||
@banner_sections = WebSection.all
|
||||
end
|
||||
|
||||
@@ -29,7 +29,8 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners }
|
||||
redirect_to admin_budget_budget_investments_path(
|
||||
budget_id: @budget.id,
|
||||
advanced_filters: ["winners"]),
|
||||
advanced_filters: ["winners"]
|
||||
),
|
||||
notice: I18n.t("admin.budgets.winners.calculated")
|
||||
end
|
||||
|
||||
@@ -60,13 +61,14 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
|
||||
def allowed_params
|
||||
descriptions = Budget::Phase::PHASE_KINDS.map { |p| "description_#{p}" }.map(&:to_sym)
|
||||
valid_attributes = [:phase,
|
||||
:currency_symbol,
|
||||
:voting_style,
|
||||
:hide_money,
|
||||
administrator_ids: [],
|
||||
valuator_ids: [],
|
||||
image_attributes: image_attributes
|
||||
valid_attributes = [
|
||||
:phase,
|
||||
:currency_symbol,
|
||||
:voting_style,
|
||||
:hide_money,
|
||||
administrator_ids: [],
|
||||
valuator_ids: [],
|
||||
image_attributes: image_attributes
|
||||
] + descriptions
|
||||
|
||||
[*valid_attributes, *report_attributes, translation_params(Budget)]
|
||||
|
||||
@@ -37,8 +37,10 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BudgetsWizard::BaseContro
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
valid_attributes = [:currency_symbol, :voting_style, :hide_money, administrator_ids: [],
|
||||
valuator_ids: [], image_attributes: image_attributes]
|
||||
valid_attributes = [:currency_symbol, :voting_style, :hide_money,
|
||||
administrator_ids: [],
|
||||
valuator_ids: [],
|
||||
image_attributes: image_attributes]
|
||||
|
||||
[*valid_attributes, translation_params(Budget)]
|
||||
end
|
||||
|
||||
@@ -8,8 +8,9 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
|
||||
def index
|
||||
@processes = ::Legislation::Process.send(@current_filter).order(start_date: :desc)
|
||||
.page(params[:page])
|
||||
@processes = ::Legislation::Process.send(@current_filter)
|
||||
.order(start_date: :desc)
|
||||
.page(params[:page])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -10,7 +10,7 @@ class Admin::LocalCensusRecordsController < Admin::BaseController
|
||||
@local_census_record = LocalCensusRecord.new(local_census_record_params)
|
||||
if @local_census_record.save
|
||||
redirect_to admin_local_census_records_path,
|
||||
notice: t("admin.local_census_records.create.notice")
|
||||
notice: t("admin.local_census_records.create.notice")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
@@ -19,7 +19,7 @@ class Admin::LocalCensusRecordsController < Admin::BaseController
|
||||
def update
|
||||
if @local_census_record.update(local_census_record_params)
|
||||
redirect_to admin_local_census_records_path,
|
||||
notice: t("admin.local_census_records.update.notice")
|
||||
notice: t("admin.local_census_records.update.notice")
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
@@ -28,7 +28,7 @@ class Admin::LocalCensusRecordsController < Admin::BaseController
|
||||
def destroy
|
||||
@local_census_record.destroy!
|
||||
redirect_to admin_local_census_records_path,
|
||||
notice: t("admin.local_census_records.destroy.notice")
|
||||
notice: t("admin.local_census_records.destroy.notice")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -4,22 +4,22 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
|
||||
before_action :load_booth_assignment, only: [:create]
|
||||
|
||||
def index
|
||||
@officers = ::Poll::Officer.
|
||||
includes(:user).
|
||||
order("users.username").
|
||||
where(
|
||||
id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id)
|
||||
).page(params[:page]).per(50)
|
||||
@officers = ::Poll::Officer
|
||||
.includes(:user)
|
||||
.order("users.username")
|
||||
.where(id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id))
|
||||
.page(params[:page])
|
||||
.per(50)
|
||||
end
|
||||
|
||||
def by_officer
|
||||
@poll = ::Poll.includes(:booths).find(params[:poll_id])
|
||||
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id])
|
||||
@officer_assignments = ::Poll::OfficerAssignment.
|
||||
joins(:booth_assignment).
|
||||
includes(:recounts, booth_assignment: :booth).
|
||||
by_officer_and_poll(@officer.id, @poll.id).
|
||||
order(:date)
|
||||
@officer_assignments = ::Poll::OfficerAssignment
|
||||
.joins(:booth_assignment)
|
||||
.includes(:recounts, booth_assignment: :booth)
|
||||
.by_officer_and_poll(@officer.id, @poll.id)
|
||||
.order(:date)
|
||||
end
|
||||
|
||||
def search_officers
|
||||
|
||||
@@ -12,7 +12,7 @@ class Admin::Poll::Questions::Answers::DocumentsController < Admin::Poll::BaseCo
|
||||
|
||||
if @answer.save
|
||||
redirect_to admin_answer_documents_path(@answer),
|
||||
notice: t("admin.documents.create.success_notice")
|
||||
notice: t("admin.documents.create.success_notice")
|
||||
else
|
||||
render :index
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
|
||||
|
||||
if @answer.save
|
||||
redirect_to admin_answer_images_path(@answer),
|
||||
notice: t("flash.actions.create.poll_question_answer_image")
|
||||
notice: t("flash.actions.create.poll_question_answer_image")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
|
||||
def create
|
||||
if @video.save
|
||||
redirect_to admin_answer_videos_path(@answer),
|
||||
notice: t("flash.actions.create.poll_question_answer_video")
|
||||
notice: t("flash.actions.create.poll_question_answer_video")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
|
||||
def create
|
||||
if @answer.save
|
||||
redirect_to admin_question_path(@question),
|
||||
notice: t("flash.actions.create.poll_question_answer")
|
||||
notice: t("flash.actions.create.poll_question_answer")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
@@ -24,7 +24,7 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
|
||||
def update
|
||||
if @answer.update(answer_params)
|
||||
redirect_to admin_question_path(@question),
|
||||
notice: t("flash.actions.save_changes.notice")
|
||||
notice: t("flash.actions.save_changes.notice")
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
|
||||
@@ -4,10 +4,10 @@ class Admin::Poll::RecountsController < Admin::Poll::BaseController
|
||||
def index
|
||||
@stats = Poll::Stats.new(@poll)
|
||||
|
||||
@booth_assignments = @poll.booth_assignments.
|
||||
includes(:booth, :recounts, :voters).
|
||||
order("poll_booths.name").
|
||||
page(params[:page]).per(50)
|
||||
@booth_assignments = @poll.booth_assignments
|
||||
.includes(:booth, :recounts, :voters)
|
||||
.order("poll_booths.name")
|
||||
.page(params[:page]).per(50)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomization::BaseController
|
||||
load_and_authorize_resource :content_block, class: "SiteCustomization::ContentBlock",
|
||||
except: [
|
||||
:delete_heading_content_block,
|
||||
:edit_heading_content_block,
|
||||
:update_heading_content_block
|
||||
]
|
||||
except: [
|
||||
:delete_heading_content_block,
|
||||
:edit_heading_content_block,
|
||||
:update_heading_content_block
|
||||
]
|
||||
|
||||
def index
|
||||
@content_blocks = SiteCustomization::ContentBlock.order(:name, :locale)
|
||||
|
||||
@@ -4,17 +4,17 @@ class Admin::SystemEmailsController < Admin::BaseController
|
||||
def index
|
||||
@system_emails = {
|
||||
proposal_notification_digest: %w[view preview_pending],
|
||||
budget_investment_created: %w[view edit_info],
|
||||
budget_investment_selected: %w[view edit_info],
|
||||
budget_investment_created: %w[view edit_info],
|
||||
budget_investment_selected: %w[view edit_info],
|
||||
budget_investment_unfeasible: %w[view edit_info],
|
||||
budget_investment_unselected: %w[view edit_info],
|
||||
comment: %w[view edit_info],
|
||||
reply: %w[view edit_info],
|
||||
direct_message_for_receiver: %w[view edit_info],
|
||||
direct_message_for_sender: %w[view edit_info],
|
||||
email_verification: %w[view edit_info],
|
||||
user_invite: %w[view edit_info],
|
||||
evaluation_comment: %w[view edit_info]
|
||||
comment: %w[view edit_info],
|
||||
reply: %w[view edit_info],
|
||||
direct_message_for_receiver: %w[view edit_info],
|
||||
direct_message_for_sender: %w[view edit_info],
|
||||
email_verification: %w[view edit_info],
|
||||
user_invite: %w[view edit_info],
|
||||
evaluation_comment: %w[view edit_info]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@ class Admin::VerificationsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@users = User.incomplete_verification.search(params[:search])
|
||||
.page(params[:page])
|
||||
.for_render
|
||||
@users = User.incomplete_verification
|
||||
.search(params[:search])
|
||||
.page(params[:page])
|
||||
.for_render
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ module Budgets
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to budget_investments_path(heading_id: @investment.heading.id),
|
||||
notice: t("flash.actions.create.support")
|
||||
notice: t("flash.actions.create.support")
|
||||
end
|
||||
|
||||
format.js { render :show }
|
||||
|
||||
@@ -37,11 +37,11 @@ class Dashboard::AchievementsController < Dashboard::BaseController
|
||||
def executed_proposed_actions
|
||||
@executed_proposed_actions ||=
|
||||
Dashboard::ExecutedAction
|
||||
.joins(:action)
|
||||
.includes(:action)
|
||||
.where(proposal: proposal)
|
||||
.where(executed_at: start_date.beginning_of_day..end_date.end_of_day)
|
||||
.where(dashboard_actions: { action_type: 0 })
|
||||
.order(executed_at: :asc)
|
||||
.joins(:action)
|
||||
.includes(:action)
|
||||
.where(proposal: proposal)
|
||||
.where(executed_at: start_date.beginning_of_day..end_date.end_of_day)
|
||||
.where(dashboard_actions: { action_type: 0 })
|
||||
.order(executed_at: :asc)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,8 +30,9 @@ class Dashboard::ActionsController < Dashboard::BaseController
|
||||
def execute
|
||||
authorize! :dashboard, proposal
|
||||
|
||||
Dashboard::ExecutedAction.create(proposal: proposal, action: dashboard_action,
|
||||
executed_at: Time.current)
|
||||
Dashboard::ExecutedAction.create(proposal: proposal,
|
||||
action: dashboard_action,
|
||||
executed_at: Time.current)
|
||||
redirect_to request.referer
|
||||
end
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class Dashboard::PosterController < Dashboard::BaseController
|
||||
dpi: 300,
|
||||
zoom: 0.32,
|
||||
show_as_html: Rails.env.test? || params.key?("debug"),
|
||||
margin: { top: 0 }
|
||||
margin: { top: 0 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,8 @@ class GraphqlController < ApplicationController
|
||||
begin
|
||||
raise GraphqlController::QueryStringError if query_string.nil?
|
||||
|
||||
result = ConsulSchema.execute(query_string,
|
||||
result = ConsulSchema.execute(
|
||||
query_string,
|
||||
variables: prepare_variables,
|
||||
context: {},
|
||||
operation_name: params[:operationName]
|
||||
|
||||
@@ -10,8 +10,11 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
|
||||
def index
|
||||
@current_filter ||= "open"
|
||||
@processes = ::Legislation::Process.send(@current_filter).published
|
||||
.not_in_draft.order(start_date: :desc).page(params[:page])
|
||||
@processes = ::Legislation::Process.send(@current_filter)
|
||||
.published
|
||||
.not_in_draft
|
||||
.order(start_date: :desc)
|
||||
.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -9,7 +9,7 @@ class Management::Budgets::Investments::VotesController < Management::BaseContro
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to management_budget_investments_path(heading_id: @investment.heading.id),
|
||||
notice: t("flash.actions.create.support")
|
||||
notice: t("flash.actions.create.support")
|
||||
end
|
||||
|
||||
format.js { render :show }
|
||||
|
||||
@@ -42,13 +42,13 @@ class Officing::BallotSheetsController < Officing::BaseController
|
||||
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)
|
||||
@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
|
||||
|
||||
@@ -21,12 +21,12 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
def index
|
||||
@booth_assignment = ::Poll::BoothAssignment.includes(:booth).find(index_params[:booth_assignment_id])
|
||||
if current_user.poll_officer.officer_assignments.final.
|
||||
where(booth_assignment_id: @booth_assignment.id).exists?
|
||||
if current_user.poll_officer.officer_assignments.final
|
||||
.where(booth_assignment_id: @booth_assignment.id).exists?
|
||||
|
||||
@partial_results = ::Poll::PartialResult.includes(:question).
|
||||
where(booth_assignment_id: index_params[:booth_assignment_id]).
|
||||
where(date: index_params[:date])
|
||||
@partial_results = ::Poll::PartialResult.includes(:question)
|
||||
.where(booth_assignment_id: index_params[:booth_assignment_id])
|
||||
.where(date: index_params[:date])
|
||||
@recounts = ::Poll::Recount.where(booth_assignment_id: @booth_assignment.id, date: index_params[:date])
|
||||
end
|
||||
end
|
||||
@@ -89,18 +89,18 @@ class Officing::ResultsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def load_officer_assignment
|
||||
@officer_assignment = current_user.poll_officer.
|
||||
officer_assignments.final.find_by(id: results_params[:officer_assignment_id])
|
||||
@officer_assignment = current_user.poll_officer
|
||||
.officer_assignments.final.find_by(id: results_params[:officer_assignment_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)
|
||||
@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_partial_results
|
||||
|
||||
@@ -13,7 +13,7 @@ class Officing::VotersController < Officing::BaseController
|
||||
def create
|
||||
@poll = Poll.find(voter_params[:poll_id])
|
||||
@user = User.find(voter_params[:user_id])
|
||||
@voter = Poll::Voter.new(document_type: @user.document_type,
|
||||
@voter = Poll::Voter.new(document_type: @user.document_type,
|
||||
document_number: @user.document_number,
|
||||
user: @user,
|
||||
poll: @poll,
|
||||
|
||||
@@ -155,8 +155,10 @@ class ProposalsController < ApplicationController
|
||||
return unless !@advanced_search_terms && @search_terms.blank? && params[:retired].blank? && @current_order != "recommendations"
|
||||
|
||||
if Setting["feature.featured_proposals"]
|
||||
@featured_proposals = Proposal.not_archived.unsuccessful
|
||||
.sort_by_confidence_score.limit(Setting["featured_proposals_number"])
|
||||
@featured_proposals = Proposal.not_archived
|
||||
.unsuccessful
|
||||
.sort_by_confidence_score
|
||||
.limit(Setting["featured_proposals_number"])
|
||||
if @featured_proposals.present?
|
||||
@resources = @resources.where.not(id: @featured_proposals)
|
||||
end
|
||||
|
||||
@@ -77,19 +77,19 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id)).sort_by(&:name)
|
||||
|
||||
all_headings_filter = [
|
||||
{
|
||||
name: t("valuation.budget_investments.index.headings_filter_all"),
|
||||
id: nil,
|
||||
count: investments.size
|
||||
}
|
||||
]
|
||||
{
|
||||
name: t("valuation.budget_investments.index.headings_filter_all"),
|
||||
id: nil,
|
||||
count: investments.size
|
||||
}
|
||||
]
|
||||
|
||||
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||
filters << {
|
||||
name: heading.name,
|
||||
id: heading.id,
|
||||
count: investments.count { |i| i.heading_id == heading.id }
|
||||
}
|
||||
name: heading.name,
|
||||
id: heading.id,
|
||||
count: investments.count { |i| i.heading_id == heading.id }
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module AdminBudgetInvestmentsHelper
|
||||
def advanced_menu_visibility
|
||||
if params[:advanced_filters].empty? &&
|
||||
params["min_total_supports"].blank? &&
|
||||
params["max_total_supports"].blank?
|
||||
params["min_total_supports"].blank? &&
|
||||
params["max_total_supports"].blank?
|
||||
"hide"
|
||||
else
|
||||
""
|
||||
@@ -22,8 +22,8 @@ module AdminBudgetInvestmentsHelper
|
||||
end
|
||||
|
||||
def valuator_select_options(budget)
|
||||
budget.valuators.order("description ASC").order("users.email ASC").includes(:user).
|
||||
map { |v| [v.description_or_email, "valuator_#{v.id}"] }
|
||||
budget.valuators.order("description ASC").order("users.email ASC").includes(:user)
|
||||
.map { |v| [v.description_or_email, "valuator_#{v.id}"] }
|
||||
end
|
||||
|
||||
def valuator_group_select_options
|
||||
|
||||
@@ -48,7 +48,7 @@ module ApplicationHelper
|
||||
|
||||
def self.asset_data_base64(path)
|
||||
asset = (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application))
|
||||
.find_asset(path)
|
||||
.find_asset(path)
|
||||
throw "Could not find asset '#{path}'" if asset.nil?
|
||||
base64 = Base64.encode64(asset.to_s).gsub(/\s+/, "")
|
||||
"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
|
||||
|
||||
@@ -33,13 +33,13 @@ module BudgetsHelper
|
||||
|
||||
def budget_subnav_items_for(budget)
|
||||
{
|
||||
results: t("budgets.results.link"),
|
||||
stats: t("stats.budgets.link"),
|
||||
results: t("budgets.results.link"),
|
||||
stats: t("stats.budgets.link"),
|
||||
executions: t("budgets.executions.link")
|
||||
}.select { |section, _| can?(:"read_#{section}", budget) }.map do |section, text|
|
||||
{
|
||||
text: text,
|
||||
url: send("budget_#{section}_path", budget),
|
||||
url: send("budget_#{section}_path", budget),
|
||||
active: controller_name == section.to_s
|
||||
}
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module GlobalizeHelper
|
||||
|
||||
def first_i18n_content_translation_locale
|
||||
if I18nContentTranslation.existing_languages.count == 0 ||
|
||||
I18nContentTranslation.existing_languages.include?(I18n.locale)
|
||||
I18nContentTranslation.existing_languages.include?(I18n.locale)
|
||||
I18n.locale
|
||||
else
|
||||
I18nContentTranslation.existing_languages.first
|
||||
|
||||
@@ -9,12 +9,12 @@ module LegislationHelper
|
||||
|
||||
def legislation_process_tabs(process)
|
||||
{
|
||||
"info" => edit_admin_legislation_process_path(process),
|
||||
"homepage" => edit_admin_legislation_process_homepage_path(process),
|
||||
"questions" => admin_legislation_process_questions_path(process),
|
||||
"proposals" => admin_legislation_process_proposals_path(process),
|
||||
"info" => edit_admin_legislation_process_path(process),
|
||||
"homepage" => edit_admin_legislation_process_homepage_path(process),
|
||||
"questions" => admin_legislation_process_questions_path(process),
|
||||
"proposals" => admin_legislation_process_proposals_path(process),
|
||||
"draft_versions" => admin_legislation_process_draft_versions_path(process),
|
||||
"milestones" => admin_legislation_process_milestones_path(process)
|
||||
"milestones" => admin_legislation_process_milestones_path(process)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module LinksHelper
|
||||
def render_destroy_element_link(builder, element)
|
||||
link_to_remove_association element.new_record? ? t("links.form.cancel_button") :
|
||||
t("links.form.delete_button"),
|
||||
builder, class: "delete remove-element"
|
||||
builder, class: "delete remove-element"
|
||||
end
|
||||
|
||||
def link_to_signin(options = {})
|
||||
|
||||
@@ -25,17 +25,17 @@ module ManagementHelper
|
||||
|
||||
def menu_create_investments?
|
||||
(controller_name == "budget_investments" && action_name == "new") ||
|
||||
(controller_name == "budgets" && action_name == "create_investments")
|
||||
(controller_name == "budgets" && action_name == "create_investments")
|
||||
end
|
||||
|
||||
def menu_support_investments?
|
||||
(controller_name == "budget_investments" && action_name == "index") ||
|
||||
(controller_name == "budgets" && action_name == "support_investments")
|
||||
(controller_name == "budgets" && action_name == "support_investments")
|
||||
end
|
||||
|
||||
def menu_print_investments?
|
||||
(controller_name == "budget_investments" && action_name == "print") ||
|
||||
(controller_name == "budgets" && action_name == "print_investments")
|
||||
(controller_name == "budgets" && action_name == "print_investments")
|
||||
end
|
||||
|
||||
def menu_user_invites?
|
||||
|
||||
@@ -3,14 +3,14 @@ module MilestonesHelper
|
||||
text = number_to_percentage(progress_bar.percentage, precision: 0)
|
||||
|
||||
tag.div class: "progress",
|
||||
role: "progressbar",
|
||||
role: "progressbar",
|
||||
"aria-valuenow": progress_bar.percentage,
|
||||
"aria-valuetext": "#{progress_bar.percentage}%",
|
||||
"aria-valuemax": ProgressBar::RANGE.max,
|
||||
"aria-valuemin": "0",
|
||||
tabindex: "0" do
|
||||
tag.span(class: "progress-meter", style: "width: #{progress_bar.percentage}%;") +
|
||||
tag.p(text, class: "progress-meter-text")
|
||||
tag.p(text, class: "progress-meter-text")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ module PollRecountsHelper
|
||||
def total_recounts_by_booth(booth_assignment)
|
||||
if booth_assignment.recounts.any?
|
||||
booth_assignment.recounts.sum(:total_amount) +
|
||||
booth_assignment.recounts.sum(:white_amount) +
|
||||
booth_assignment.recounts.sum(:null_amount)
|
||||
booth_assignment.recounts.sum(:white_amount) +
|
||||
booth_assignment.recounts.sum(:null_amount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ module ProposalsDashboardHelper
|
||||
|
||||
def is_proposed_action_request?
|
||||
controller_name == "dashboard" && action_name == "new_request" &&
|
||||
dashboard_action&.proposed_action?
|
||||
dashboard_action&.proposed_action?
|
||||
end
|
||||
|
||||
def is_request_active(id)
|
||||
@@ -60,10 +60,10 @@ module ProposalsDashboardHelper
|
||||
label = []
|
||||
|
||||
label << t("dashboard.resource.required_days",
|
||||
days: resource.day_offset) if resource.day_offset > 0
|
||||
days: resource.day_offset) if resource.day_offset > 0
|
||||
label << t("dashboard.resource.required_supports",
|
||||
supports: number_with_delimiter(resource.required_supports,
|
||||
delimiter: ".")) if resource.required_supports > 0
|
||||
supports: number_with_delimiter(resource.required_supports,
|
||||
delimiter: ".")) if resource.required_supports > 0
|
||||
|
||||
safe_join label, h(" #{t("dashboard.resource.and")})") + tag(:br)
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ module TranslatableFormHelper
|
||||
{
|
||||
class: "translatable-fields js-globalize-attribute #{highlight_translation_html_class}",
|
||||
style: @template.display_translation_style(resource.globalized_model, locale),
|
||||
data: { locale: locale }
|
||||
data: { locale: locale }
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ module UsersHelper
|
||||
deleted_commentable_text(comment)
|
||||
elsif commentable.hidden?
|
||||
tag.del(commentable.title) + " " +
|
||||
tag.span("(#{deleted_commentable_text(comment)})", class: "small")
|
||||
tag.span("(#{deleted_commentable_text(comment)})", class: "small")
|
||||
else
|
||||
link_to(commentable.title, comment)
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ module WelcomeHelper
|
||||
|
||||
def calculate_image_path(recommended, image_default)
|
||||
if recommended.respond_to?(:image) && recommended.image.present? &&
|
||||
recommended.image.attachment.attached?
|
||||
recommended.image.attachment.attached?
|
||||
recommended.image.variant(:medium)
|
||||
elsif image_default.present?
|
||||
image_default
|
||||
|
||||
@@ -73,7 +73,7 @@ module Abilities
|
||||
can [:hide, :admin_update, :toggle_selection], Budget::Investment
|
||||
can [:valuate, :comment_valuation], Budget::Investment
|
||||
cannot [:admin_update, :toggle_selection, :valuate, :comment_valuation],
|
||||
Budget::Investment, budget: { phase: "finished" }
|
||||
Budget::Investment, budget: { phase: "finished" }
|
||||
|
||||
can :create, Budget::ValuatorAssignment
|
||||
|
||||
|
||||
@@ -96,9 +96,9 @@ module Abilities
|
||||
can :suggest, Budget::Investment, budget: { phase: "accepting" }
|
||||
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id
|
||||
can [:create, :destroy], ActsAsVotable::Vote,
|
||||
voter_id: user.id,
|
||||
votable_type: "Budget::Investment",
|
||||
votable: { budget: { phase: "selecting" }}
|
||||
voter_id: user.id,
|
||||
votable_type: "Budget::Investment",
|
||||
votable: { budget: { phase: "selecting" }}
|
||||
|
||||
can [:show, :create], Budget::Ballot, budget: { phase: "balloting" }
|
||||
can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" }
|
||||
|
||||
@@ -11,8 +11,8 @@ class Budget
|
||||
|
||||
def name_uniqueness_by_budget
|
||||
if budget.groups.joins(:translations)
|
||||
.where(name: name)
|
||||
.where.not("budget_group_translations.budget_group_id": budget_group_id).any?
|
||||
.where(name: name)
|
||||
.where.not("budget_group_translations.budget_group_id": budget_group_id).any?
|
||||
errors.add(:name, I18n.t("errors.messages.taken"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,9 +33,9 @@ class Budget
|
||||
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
|
||||
validates :population, numericality: { greater_than: 0 }, allow_nil: true
|
||||
validates :latitude, length: { maximum: 22 }, allow_blank: true, \
|
||||
format: /\A(-|\+)?([1-8]?\d(?:\.\d{1,})?|90(?:\.0{1,6})?)\z/
|
||||
format: /\A(-|\+)?([1-8]?\d(?:\.\d{1,})?|90(?:\.0{1,6})?)\z/
|
||||
validates :longitude, length: { maximum: 22 }, allow_blank: true, \
|
||||
format: /\A(-|\+)?((?:1[0-7]|[1-9])?\d(?:\.\d{1,})?|180(?:\.0{1,})?)\z/
|
||||
format: /\A(-|\+)?((?:1[0-7]|[1-9])?\d(?:\.\d{1,})?|180(?:\.0{1,})?)\z/
|
||||
validates :max_ballot_lines, numericality: { greater_than_or_equal_to: 1 }
|
||||
|
||||
delegate :budget, :budget_id, to: :group, allow_nil: true
|
||||
|
||||
@@ -51,9 +51,9 @@ class Budget
|
||||
has_many :comments, -> { where(valuation: false) }, as: :commentable, inverse_of: :commentable
|
||||
has_one :summary_comment, as: :commentable, class_name: "MlSummaryComment", dependent: :destroy
|
||||
has_many :valuations, -> { where(valuation: true) },
|
||||
as: :commentable,
|
||||
inverse_of: :commentable,
|
||||
class_name: "Comment"
|
||||
as: :commentable,
|
||||
inverse_of: :commentable,
|
||||
class_name: "Comment"
|
||||
|
||||
validates_translation :title, presence: true, length: { in: 4..Budget::Investment.title_max_length }
|
||||
validates_translation :description, presence: true, length: { maximum: Budget::Investment.description_max_length }
|
||||
@@ -109,8 +109,8 @@ class Budget
|
||||
end
|
||||
|
||||
def self.by_valuator_group(valuator_group_id)
|
||||
joins(:valuator_group_assignments).
|
||||
where(budget_valuator_group_assignments: { valuator_group_id: valuator_group_id })
|
||||
joins(:valuator_group_assignments)
|
||||
.where(budget_valuator_group_assignments: { valuator_group_id: valuator_group_id })
|
||||
end
|
||||
|
||||
before_validation :set_responsible_name
|
||||
@@ -198,13 +198,14 @@ class Budget
|
||||
def self.search_by_title_or_id(title_or_id)
|
||||
with_joins = with_translations(Globalize.fallbacks(I18n.locale))
|
||||
|
||||
with_joins.where(id: title_or_id).
|
||||
or(with_joins.where("budget_investment_translations.title ILIKE ?", "%#{title_or_id}%"))
|
||||
with_joins.where(id: title_or_id)
|
||||
.or(with_joins.where("budget_investment_translations.title ILIKE ?", "%#{title_or_id}%"))
|
||||
end
|
||||
|
||||
def searchable_values
|
||||
{ author.username => "B",
|
||||
heading.name => "B",
|
||||
{
|
||||
author.username => "B",
|
||||
heading.name => "B",
|
||||
tag_list.join(" ") => "B"
|
||||
}.merge(searchable_globalized_values)
|
||||
end
|
||||
@@ -394,7 +395,7 @@ class Budget
|
||||
end
|
||||
|
||||
def searchable_translations_definitions
|
||||
{ title => "A",
|
||||
{ title => "A",
|
||||
description => "D" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Budget
|
||||
class Phase < ApplicationRecord
|
||||
PHASE_KINDS = %w[informing accepting reviewing selecting valuating publishing_prices balloting
|
||||
reviewing_ballots finished].freeze
|
||||
reviewing_ballots finished].freeze
|
||||
PUBLISHED_PRICES_PHASES = %w[publishing_prices balloting reviewing_ballots finished].freeze
|
||||
DESCRIPTION_MAX_LENGTH = 2000
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ class Budget::Stats
|
||||
def balloters_by_heading(heading_id)
|
||||
stats_cache("balloters_by_heading_#{heading_id}") do
|
||||
budget.ballots.joins(:lines)
|
||||
.where(budget_ballot_lines: { heading_id: heading_id })
|
||||
.distinct.pluck(:user_id)
|
||||
.where(budget_ballot_lines: { heading_id: heading_id })
|
||||
.distinct.pluck(:user_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ class Budget::VotingStyles::Base
|
||||
|
||||
def voted_info(heading)
|
||||
I18n.t("budgets.investments.index.sidebar.voted_info.#{name}",
|
||||
count: investments(heading).count,
|
||||
amount_spent: budget.formatted_amount(investments_price(heading)))
|
||||
count: investments(heading).count,
|
||||
amount_spent: budget.formatted_amount(investments_price(heading)))
|
||||
end
|
||||
|
||||
def amount_available_info(heading)
|
||||
|
||||
@@ -6,8 +6,8 @@ class Comment < ApplicationRecord
|
||||
include Searchable
|
||||
|
||||
COMMENTABLE_TYPES = %w[Debate Proposal Budget::Investment Poll Topic
|
||||
Legislation::Question Legislation::Annotation
|
||||
Legislation::Proposal].freeze
|
||||
Legislation::Question Legislation::Annotation
|
||||
Legislation::Proposal].freeze
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
@@ -57,10 +57,10 @@ class Comment < ApplicationRecord
|
||||
|
||||
def self.build(commentable, user, body, p_id = nil, valuation = false)
|
||||
new(commentable: commentable,
|
||||
user_id: user.id,
|
||||
body: body,
|
||||
parent_id: p_id,
|
||||
valuation: valuation)
|
||||
user_id: user.id,
|
||||
body: body,
|
||||
parent_id: p_id,
|
||||
valuation: valuation)
|
||||
end
|
||||
|
||||
def self.find_commentable(c_type, c_id)
|
||||
@@ -134,7 +134,7 @@ class Comment < ApplicationRecord
|
||||
|
||||
def searchable_values
|
||||
{
|
||||
body => "A",
|
||||
body => "A",
|
||||
commentable&.title => "B"
|
||||
}
|
||||
end
|
||||
@@ -148,7 +148,8 @@ class Comment < ApplicationRecord
|
||||
def validate_body_length
|
||||
validator = ActiveModel::Validations::LengthValidator.new(
|
||||
attributes: :body,
|
||||
maximum: Comment.body_max_length)
|
||||
maximum: Comment.body_max_length
|
||||
)
|
||||
validator.validate(self)
|
||||
end
|
||||
|
||||
|
||||
@@ -6,25 +6,25 @@ module Attachable
|
||||
attr_accessor :cached_attachment
|
||||
|
||||
validates :attachment,
|
||||
presence: true,
|
||||
file_content_type: {
|
||||
allow: ->(record) { record.accepted_content_types },
|
||||
if: -> { association_class && attachment.attached? },
|
||||
message: ->(record, *) do
|
||||
I18n.t("#{record.model_name.plural}.errors.messages.wrong_content_type",
|
||||
content_type: record.attachment_content_type,
|
||||
accepted_content_types: record.class.humanized_accepted_content_types)
|
||||
end
|
||||
},
|
||||
file_size: {
|
||||
less_than_or_equal_to: ->(record) { record.max_file_size.megabytes },
|
||||
if: -> { association_class && attachment.attached? },
|
||||
message: ->(record, *) do
|
||||
I18n.t("#{record.model_name.plural}.errors.messages.in_between",
|
||||
min: "0 Bytes",
|
||||
max: "#{record.max_file_size} MB")
|
||||
end
|
||||
}
|
||||
presence: true,
|
||||
file_content_type: {
|
||||
allow: ->(record) { record.accepted_content_types },
|
||||
if: -> { association_class && attachment.attached? },
|
||||
message: ->(record, *) do
|
||||
I18n.t("#{record.model_name.plural}.errors.messages.wrong_content_type",
|
||||
content_type: record.attachment_content_type,
|
||||
accepted_content_types: record.class.humanized_accepted_content_types)
|
||||
end
|
||||
},
|
||||
file_size: {
|
||||
less_than_or_equal_to: ->(record) { record.max_file_size.megabytes },
|
||||
if: -> { association_class && attachment.attached? },
|
||||
message: ->(record, *) do
|
||||
I18n.t("#{record.model_name.plural}.errors.messages.in_between",
|
||||
min: "0 Bytes",
|
||||
max: "#{record.max_file_size} MB")
|
||||
end
|
||||
}
|
||||
|
||||
before_validation :set_attachment_from_cached_attachment, if: -> { cached_attachment.present? }
|
||||
end
|
||||
|
||||
@@ -110,10 +110,10 @@ module Globalizable
|
||||
end.join(", ")
|
||||
|
||||
translations_ids = translation_class
|
||||
.select("DISTINCT ON (#{translations_foreign_key}) id")
|
||||
.where(locale: fallbacks)
|
||||
.joins("LEFT JOIN (VALUES #{fallbacks_with_order}) AS locales(name, ordering) ON locale = locales.name")
|
||||
.order(translations_foreign_key, "locales.ordering")
|
||||
.select("DISTINCT ON (#{translations_foreign_key}) id")
|
||||
.where(locale: fallbacks)
|
||||
.joins("LEFT JOIN (VALUES #{fallbacks_with_order}) AS locales(name, ordering) ON locale = locales.name")
|
||||
.order(translations_foreign_key, "locales.ordering")
|
||||
|
||||
with_translations(fallbacks).where("#{translations_table_name}.id": translations_ids)
|
||||
end
|
||||
|
||||
@@ -3,9 +3,9 @@ module Relationable
|
||||
|
||||
included do
|
||||
has_many :related_contents,
|
||||
as: :parent_relationable,
|
||||
inverse_of: :parent_relationable,
|
||||
dependent: :destroy
|
||||
as: :parent_relationable,
|
||||
inverse_of: :parent_relationable,
|
||||
dependent: :destroy
|
||||
end
|
||||
|
||||
def find_related_content(relationable)
|
||||
|
||||
@@ -163,8 +163,7 @@ module Statisticable
|
||||
[75, 79],
|
||||
[80, 84],
|
||||
[85, 89],
|
||||
[90, 300]
|
||||
]
|
||||
[90, 300]]
|
||||
end
|
||||
|
||||
def participants_between_ages(from, to)
|
||||
|
||||
@@ -108,9 +108,10 @@ class Dashboard::Action < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.calculate_actions(proposal_votes, day_offset, proposal)
|
||||
Dashboard::Action.active.where("required_supports <= ?", proposal_votes)
|
||||
.where("day_offset <= ?", day_offset)
|
||||
.by_published_proposal(proposal.published?)
|
||||
Dashboard::Action.active
|
||||
.where("required_supports <= ?", proposal_votes)
|
||||
.where("day_offset <= ?", day_offset)
|
||||
.by_published_proposal(proposal.published?)
|
||||
end
|
||||
|
||||
def self.calculate_votes(proposal, date)
|
||||
|
||||
@@ -57,15 +57,15 @@ class Debate < ApplicationRecord
|
||||
end
|
||||
|
||||
def searchable_translations_definitions
|
||||
{ title => "A",
|
||||
{ title => "A",
|
||||
description => "D" }
|
||||
end
|
||||
|
||||
def searchable_values
|
||||
{
|
||||
author.username => "B",
|
||||
author.username => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
geozone&.name => "B"
|
||||
geozone&.name => "B"
|
||||
}.merge!(searchable_globalized_values)
|
||||
end
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ class Legislation::DraftVersion < ApplicationRecord
|
||||
|
||||
belongs_to :process, foreign_key: "legislation_process_id", inverse_of: :draft_versions
|
||||
has_many :annotations,
|
||||
foreign_key: "legislation_draft_version_id",
|
||||
inverse_of: :draft_version,
|
||||
dependent: :destroy
|
||||
foreign_key: "legislation_draft_version_id",
|
||||
inverse_of: :draft_version,
|
||||
dependent: :destroy
|
||||
|
||||
validates_translation :title, presence: true
|
||||
validates_translation :body, presence: true
|
||||
|
||||
@@ -27,21 +27,21 @@ class Legislation::Process < ApplicationRecord
|
||||
CSS_HEX_COLOR = /\A#?(?:[A-F0-9]{3}){1,2}\z/i
|
||||
|
||||
has_many :draft_versions, -> { order(:id) },
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process,
|
||||
dependent: :destroy
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process,
|
||||
dependent: :destroy
|
||||
has_one :final_draft_version, -> { where final_version: true, status: "published" },
|
||||
class_name: "Legislation::DraftVersion",
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process
|
||||
class_name: "Legislation::DraftVersion",
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process
|
||||
has_many :questions, -> { order(:id) },
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process,
|
||||
dependent: :destroy
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process,
|
||||
dependent: :destroy
|
||||
has_many :proposals, -> { order(:id) },
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process,
|
||||
dependent: :destroy
|
||||
foreign_key: "legislation_process_id",
|
||||
inverse_of: :process,
|
||||
dependent: :destroy
|
||||
|
||||
validates_translation :title, presence: true
|
||||
validates :start_date, presence: true
|
||||
@@ -127,8 +127,8 @@ class Legislation::Process < ApplicationRecord
|
||||
|
||||
def searchable_translations_definitions
|
||||
{
|
||||
title => "A",
|
||||
summary => "C",
|
||||
title => "A",
|
||||
summary => "C",
|
||||
description => "D"
|
||||
}
|
||||
end
|
||||
|
||||
@@ -57,12 +57,12 @@ class Legislation::Proposal < ApplicationRecord
|
||||
end
|
||||
|
||||
def searchable_values
|
||||
{ title => "A",
|
||||
author.username => "B",
|
||||
{ title => "A",
|
||||
author.username => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
geozone&.name => "B",
|
||||
summary => "C",
|
||||
description => "D" }
|
||||
geozone&.name => "B",
|
||||
summary => "C",
|
||||
description => "D" }
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
|
||||
@@ -73,7 +73,7 @@ class LocalCensusRecords::Import
|
||||
def file_headers_definition
|
||||
headers = fetch_file_headers
|
||||
return if headers.all? { |header| ATTRIBUTES.include? header } &&
|
||||
ATTRIBUTES.all? { |attr| headers.include? attr }
|
||||
ATTRIBUTES.all? { |attr| headers.include? attr }
|
||||
|
||||
errors.add :file, :headers, required_headers: ATTRIBUTES.join(", ")
|
||||
end
|
||||
|
||||
@@ -32,17 +32,17 @@ class Officing::Residence
|
||||
user.update!(verified_at: Time.current)
|
||||
else
|
||||
user_params = {
|
||||
document_number: document_number,
|
||||
document_type: document_type,
|
||||
geozone: geozone,
|
||||
date_of_birth: response_date_of_birth.in_time_zone.to_datetime,
|
||||
gender: gender,
|
||||
document_number: document_number,
|
||||
document_type: document_type,
|
||||
geozone: geozone,
|
||||
date_of_birth: response_date_of_birth.in_time_zone.to_datetime,
|
||||
gender: gender,
|
||||
residence_verified_at: Time.current,
|
||||
verified_at: Time.current,
|
||||
erased_at: Time.current,
|
||||
password: random_password,
|
||||
terms_of_service: "1",
|
||||
email: nil
|
||||
verified_at: Time.current,
|
||||
erased_at: Time.current,
|
||||
password: random_password,
|
||||
terms_of_service: "1",
|
||||
email: nil
|
||||
}
|
||||
self.user = User.create!(user_params)
|
||||
end
|
||||
|
||||
@@ -52,14 +52,16 @@ class Organization < ApplicationRecord
|
||||
def validate_name_length
|
||||
validator = ActiveModel::Validations::LengthValidator.new(
|
||||
attributes: :name,
|
||||
maximum: Organization.name_max_length)
|
||||
maximum: Organization.name_max_length
|
||||
)
|
||||
validator.validate(self)
|
||||
end
|
||||
|
||||
def validate_responsible_name_length
|
||||
validator = ActiveModel::Validations::LengthValidator.new(
|
||||
attributes: :responsible_name,
|
||||
maximum: Organization.responsible_name_max_length)
|
||||
maximum: Organization.responsible_name_max_length
|
||||
)
|
||||
validator.validate(self)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,9 +62,11 @@ class Poll < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.overlaping_with(poll)
|
||||
where("? < ends_at and ? >= starts_at", poll.starts_at.beginning_of_day,
|
||||
poll.ends_at.end_of_day).where.not(id: poll.id)
|
||||
.where(related: poll.related)
|
||||
where("? < ends_at and ? >= starts_at",
|
||||
poll.starts_at.beginning_of_day,
|
||||
poll.ends_at.end_of_day)
|
||||
.where.not(id: poll.id)
|
||||
.where(related: poll.related)
|
||||
end
|
||||
|
||||
def title
|
||||
@@ -102,7 +104,7 @@ class Poll < ApplicationRecord
|
||||
return none if user.nil? || user.unverified?
|
||||
|
||||
current.left_joins(:geozones)
|
||||
.where("geozone_restricted = ? OR geozones.id = ?", false, user.geozone_id)
|
||||
.where("geozone_restricted = ? OR geozones.id = ?", false, user.geozone_id)
|
||||
end
|
||||
|
||||
def self.votable_by(user)
|
||||
@@ -205,8 +207,8 @@ class Poll < ApplicationRecord
|
||||
|
||||
def searchable_translations_definitions
|
||||
{
|
||||
name => "A",
|
||||
summary => "C",
|
||||
name => "A",
|
||||
summary => "C",
|
||||
description => "D"
|
||||
}
|
||||
end
|
||||
|
||||
@@ -36,8 +36,8 @@ class Poll::BallotSheet < ApplicationRecord
|
||||
|
||||
def create_ballot(poll_ballot)
|
||||
Budget::Ballot.where(physical: true,
|
||||
user: nil,
|
||||
poll_ballot: poll_ballot,
|
||||
budget: poll.budget).first_or_create!
|
||||
user: nil,
|
||||
poll_ballot: poll_ballot,
|
||||
budget: poll.budget).first_or_create!
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user