diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index fc20c36a9..8cff4b72b 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -65,6 +65,7 @@ module BudgetsHelper end def current_budget_map_locations + return unless current_budget.present? MapLocation.where(investment_id: current_budget.investments).map { |l| l.json_data } end end diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index ff0a7a505..360e79d72 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -3,168 +3,172 @@ <%= render "shared/canonical", href: budgets_url %> <% end %> -
-
-
+<% if current_budget.present? %> +
+
+
-

<%= current_budget.name %>

-
- <%= safe_html_with_links(current_budget.description) %> +

<%= current_budget.name %>

+
+ <%= safe_html_with_links(current_budget.description) %> +
+

+ <%= link_to t("budgets.index.section_header.help"), "#section_help" %> +

-

- <%= link_to t("budgets.index.section_header.help"), "#section_help" %> -

-
-
-

- <%= t("budgets.show.phase") %> -

-

<%= t("budgets.phase.#{current_budget.phase}") %>

+
+

+ <%= t("budgets.show.phase") %> +

+

<%= t("budgets.phase.#{current_budget.phase}") %>

- <%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %> + <%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %> - <% if current_budget.accepting? %> - <% if current_user %> - <% if current_user.level_two_or_three_verified? %> - <%= link_to t("budgets.investments.index.sidebar.create"), - new_budget_investment_guide, - class: "button margin-top expanded" %> + <% if current_budget.accepting? %> + <% if current_user %> + <% if current_user.level_two_or_three_verified? %> + <%= link_to t("budgets.investments.index.sidebar.create"), + new_budget_investment_guide, + class: "button margin-top expanded" %> + <% else %> +
+ <%= t("budgets.investments.index.sidebar.verified_only", + verify: link_to(t("budgets.investments.index.sidebar.verify_account"), + verification_path)).html_safe %> +
+ <% end %> <% else %> -
- <%= t("budgets.investments.index.sidebar.verified_only", - verify: link_to(t("budgets.investments.index.sidebar.verify_account"), - verification_path)).html_safe %> +
+ <%= t("budgets.investments.index.sidebar.not_logged_in", + sign_in: link_to(t("budgets.investments.index.sidebar.sign_in"), + new_user_session_path), + sign_up: link_to(t("budgets.investments.index.sidebar.sign_up"), + new_user_registration_path)).html_safe %>
<% end %> - <% else %> -
- <%= t("budgets.investments.index.sidebar.not_logged_in", - sign_in: link_to(t("budgets.investments.index.sidebar.sign_in"), - new_user_session_path), - sign_up: link_to(t("budgets.investments.index.sidebar.sign_up"), - new_user_registration_path)).html_safe %> -
<% end %> - <% end %> - <% if current_budget.finished? || (current_budget.balloting? && can?(:read_results, current_budget)) %> - <%= link_to t("budgets.show.see_results"), - budget_results_path(current_budget, heading_id: current_budget.headings.first), - class: "button margin-top expanded" %> - <% end %> -
-
-
- -
-
-
- -
- <% current_budget.groups.each do |group| %> -

<%= group.name %>

-
    - <% group.headings.order_by_group_name.each do |heading| %> -
  • - <% unless current_budget.informing? %> - <%= link_to budget_investments_path(current_budget.id, heading_id: heading.id) do %> - <%= heading_name_and_price_html(heading, current_budget) %> - <% end %> - <% else %> -
    - <%= heading_name_and_price_html(heading, current_budget) %> -
    - <% end %> -
  • - <% end %> -
+ <% if current_budget.finished? || (current_budget.balloting? && can?(:read_results, current_budget)) %> + <%= link_to t("budgets.show.see_results"), + budget_results_path(current_budget, heading_id: current_budget.headings.first), + class: "button margin-top expanded" %> <% end %>
+
+
- <% unless current_budget.informing? %> -
-

<%= t("budgets.index.map") %>

- <%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %> +
+
+
+ +
+ <% current_budget.groups.each do |group| %> +

<%= group.name %>

+
    + <% group.headings.order_by_group_name.each do |heading| %> +
  • + <% unless current_budget.informing? %> + <%= link_to budget_investments_path(current_budget.id, heading_id: heading.id) do %> + <%= heading_name_and_price_html(heading, current_budget) %> + <% end %> + <% else %> +
    + <%= heading_name_and_price_html(heading, current_budget) %> +
    + <% end %> +
  • + <% end %> +
+ <% end %>
-

- <% show_links = show_links_to_budget_investments(current_budget) %> - <% if show_links %> - <%= link_to budget_investments_path(current_budget.id) do %> - <%= t("budgets.index.investment_proyects") %> - <% end %>
- <% end %> - <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unfeasible') do %> - <%= t("budgets.index.unfeasible_investment_proyects") %> - <% end %>
- <% if show_links %> - <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %> - <%= t("budgets.index.not_selected_investment_proyects") %> - <% end %> - <% end %> -

- <% end %> + <% unless current_budget.informing? %> +
+

<%= t("budgets.index.map") %>

+ <%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %> +
-
-

<%= t("budgets.index.all_phases") %>

- <%= render "phases", budget: current_budget %> +

+ <% show_links = show_links_to_budget_investments(current_budget) %> + <% if show_links %> + <%= link_to budget_investments_path(current_budget.id) do %> + <%= t("budgets.index.investment_proyects") %> + <% end %>
+ <% end %> + <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unfeasible') do %> + <%= t("budgets.index.unfeasible_investment_proyects") %> + <% end %>
+ <% if show_links %> + <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %> + <%= t("budgets.index.not_selected_investment_proyects") %> + <% end %> + <% end %> +

+ <% end %> + +
+

<%= t("budgets.index.all_phases") %>

+ <%= render "phases", budget: current_budget %> +
-
- <% if @finished_budgets.present? %> -
-
- + <% if @finished_budgets.present? %> +
+
+ -
- <% @finished_budgets.each do |budget| %> -
-
-
-
-
-

<%= budget.name %>

+
+ <% @finished_budgets.each do |budget| %> +
+
+
+
+
+

<%= budget.name %>

+
-
-
-
- <%= link_to t("budgets.index.see_results"), - budget_results_path(budget.id), - class: "button expanded" %> +
+
+ <%= link_to t("budgets.index.see_results"), + budget_results_path(budget.id), + class: "button expanded" %> +
-
- <% end %> + <% end %> +
+
+
+ <% end %> + +
+
+
+

+ <%= t("budgets.index.section_footer.title") %> +

+

<%= t("budgets.index.section_footer.description") %>

+

<%= t("budgets.index.section_footer.help_text_1") %>

+

<%= t("budgets.index.section_footer.help_text_2") %>

+

<%= t("budgets.index.section_footer.help_text_3", + org: link_to(setting['org_name'], new_user_registration_path)).html_safe %>

+

<%= t("budgets.index.section_footer.help_text_4") %>

- <% end %> - -
-
-
-

- <%= t("budgets.index.section_footer.title") %> -

-

<%= t("budgets.index.section_footer.description") %>

-

<%= t("budgets.index.section_footer.help_text_1") %>

-

<%= t("budgets.index.section_footer.help_text_2") %>

-

<%= t("budgets.index.section_footer.help_text_3", - org: link_to(setting['org_name'], new_user_registration_path)).html_safe %>

-

<%= t("budgets.index.section_footer.help_text_4") %>

-
-
-
+<% else %> + <%= t("budgets.index.empty_budgets") %> +<% end %> \ No newline at end of file diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml index 48d3b3462..eeed3b2fb 100644 --- a/config/locales/en/budgets.yml +++ b/config/locales/en/budgets.yml @@ -41,6 +41,7 @@ en: finished: Finished budget index: title: Participatory budgets + empty_budgets: There are no budgets section_header: icon_alt: Participatory budgets icon title: Participatory budgets diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml index 67ad55d5f..70ed9c454 100644 --- a/config/locales/es/budgets.yml +++ b/config/locales/es/budgets.yml @@ -41,6 +41,7 @@ es: finished: Resultados index: title: Presupuestos participativos + empty_budgets: No hay presupuestos participativos section_header: icon_alt: Icono de Presupuestos participativos title: Presupuestos participativos diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index d391dc9be..cd1ee6cd5 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -117,6 +117,13 @@ feature 'Budgets' do end end + scenario "No budgets" do + Budget.destroy_all + + visit budgets_path + + expect(page).to have_content "There are no budgets" + end end scenario 'Index shows only published phases' do