diff --git a/app/controllers/valuation/spending_proposals_controller.rb b/app/controllers/valuation/spending_proposals_controller.rb index ac502334d..21389d4a2 100644 --- a/app/controllers/valuation/spending_proposals_controller.rb +++ b/app/controllers/valuation/spending_proposals_controller.rb @@ -4,7 +4,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController has_filters %w{valuation_open valuating valuation_finished}, only: :index - load_resource + load_and_authorize_resource def index @spending_proposals = SpendingProposal.search(params, @current_filter).order(created_at: :desc).page(params[:page]) diff --git a/app/views/valuation/spending_proposals/index.html.erb b/app/views/valuation/spending_proposals/index.html.erb index f7e8d4ba6..5aa486677 100644 --- a/app/views/valuation/spending_proposals/index.html.erb +++ b/app/views/valuation/spending_proposals/index.html.erb @@ -30,7 +30,7 @@ <%= spending_proposal.id %> - <%= link_to spending_proposal.title, spending_proposal_path(spending_proposal) %> + <%= link_to spending_proposal.title, valuation_spending_proposal_path(spending_proposal) %> <% if spending_proposal.administrator.present? %> diff --git a/app/views/valuation/spending_proposals/show.html.erb b/app/views/valuation/spending_proposals/show.html.erb new file mode 100644 index 000000000..cc0c8bca6 --- /dev/null +++ b/app/views/valuation/spending_proposals/show.html.erb @@ -0,0 +1,74 @@ +<%= link_to t("valuation.spending_proposals.show.back"), :back, class: 'back' %> +

<%= t("valuation.spending_proposals.show.heading") %> <%= @spending_proposal.id %>

+

<%= @spending_proposal.title %>

+ +<%= safe_html_with_links @spending_proposal.description %> + +<% if @spending_proposal.external_url.present? %> +

<%= text_with_links @spending_proposal.external_url %>

+<% end %> + +

<%= t("valuation.spending_proposals.show.info") %>

+ +

<%= t("valuation.spending_proposals.show.by") %>: + <%= link_to @spending_proposal.author.name, user_path(@spending_proposal.author) %> +

+ +<% if @spending_proposal.association_name.present? %> +

<%= t("valuation.spending_proposals.show.association_name") %>: + <%= @spending_proposal.association_name %> +

+<% end %> + +

<%= t("valuation.spending_proposals.show.geozone") %>: + <%= geozone_name(@spending_proposal) %> +

+ +

<%= t("valuation.spending_proposals.show.sent") %>: + <%= l @spending_proposal.created_at, format: :datetime %> +

+ +

<%= t("valuation.spending_proposals.show.responsibles") %>

+ +

<%= t("valuation.spending_proposals.show.assigned_admin") %>: + <% if @spending_proposal.administrator.present? %> + <%= @spending_proposal.administrator.name %> (<%= @spending_proposal.administrator.email %>) + <% else %> + <%= t("valuation.spending_proposals.show.undefined") %> + <% end %> +

+ +

<%= t("valuation.spending_proposals.show.assigned_valuators") %>:

+
+ +
+ + +

<%= t("valuation.spending_proposals.show.dossier") %>

+ +

<%= t("valuation.spending_proposals.show.price") %> (<%= t("valuation.spending_proposals.show.currency") %>): + <%= @spending_proposal.price.present? ? @spending_proposal.price : t("valuation.spending_proposals.show.undefined") %> +

+<%= simple_format(safe_html_with_links(@spending_proposal.price_explanation.html_safe), {}, sanitize: false) if @spending_proposal.price_explanation.present? %> + +

<%= t("valuation.spending_proposals.show.feasibility") %>: + <%= t("valuation.spending_proposals.show.#{@spending_proposal.feasibility}") %> +

+<%= simple_format(safe_html_with_links(@spending_proposal.feasible_explanation.html_safe), {}, sanitize: false) if @spending_proposal.feasible_explanation.present? %> + +<% if @spending_proposal.valuation_finished %> +

<%= t("valuation.spending_proposals.show.valuation_finished") %> +<% end %> + +<% if @spending_proposal.internal_comments.present? %> +

<%= t("valuation.spending_proposals.show.internal_comments") %>

+ <%= simple_format(safe_html_with_links(@spending_proposal.internal_comments.html_safe), {}, sanitize: false) %> +<% end %> \ No newline at end of file diff --git a/config/locales/valuation.en.yml b/config/locales/valuation.en.yml index 8d5c0f3ed..a9f7fb393 100644 --- a/config/locales/valuation.en.yml +++ b/config/locales/valuation.en.yml @@ -18,4 +18,24 @@ en: valuators_assigned: one: Assigned valuator other: "%{count} valuators assigned" - no_valuators_assigned: No valuators assigned \ No newline at end of file + no_valuators_assigned: No valuators assigned + show: + back: Back + heading: Investment project + info: Author info + association_name: Asociación + by: Sent by + sent: Sent at + geozone: Scope + dossier: Dossier + price: Price + currency: "€" + feasibility: Feasibility + feasible: Feasible + not_feasible: Not feasible + undefined: Undefined + valuation_finished: Valuation finished + internal_comments: Internal comments + responsibles: Responsibles + assigned_admin: Assigned admin + assigned_valuators: Assigned valuators diff --git a/config/locales/valuation.es.yml b/config/locales/valuation.es.yml index ca65fd82a..a30abc252 100644 --- a/config/locales/valuation.es.yml +++ b/config/locales/valuation.es.yml @@ -18,4 +18,24 @@ es: valuators_assigned: one: Evaluador asignado other: "%{count} evaluadores asignados" - no_valuators_assigned: Sin evaluador \ No newline at end of file + no_valuators_assigned: Sin evaluador + show: + back: Volver + heading: Propuesta de inversión + info: Datos de envío + association_name: Asociación + by: Enviada por + sent: Fecha de creación + geozone: Ámbito + dossier: Informe + price: Coste + currency: "€" + feasibility: Viabilidad + feasible: Viable + not_feasible: No viable + undefined: Sin definir + valuation_finished: Informe finalizado + internal_comments: Commentarios internos + responsibles: Responsables + assigned_admin: Administrador asignado + assigned_valuators: Evaluadores asignados diff --git a/spec/features/valuation/spending_proposals_spec.rb b/spec/features/valuation/spending_proposals_spec.rb index ae0c7df7a..78ce2e08d 100644 --- a/spec/features/valuation/spending_proposals_spec.rb +++ b/spec/features/valuation/spending_proposals_spec.rb @@ -140,4 +140,35 @@ feature 'Valuation spending proposals' do expect(page).to have_content("Old idea") end + scenario 'Show' do + administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org')) + valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org')) + spending_proposal = create(:spending_proposal, + geozone: create(:geozone), + association_name: 'People of the neighbourhood', + price: 1234.56, + feasible: false, + feasible_explanation: 'It is impossible', + administrator: administrator) + spending_proposal.valuators << valuator + + visit valuation_spending_proposals_path + + click_link spending_proposal.title + + expect(page).to have_content(spending_proposal.title) + expect(page).to have_content(spending_proposal.description) + expect(page).to have_content(spending_proposal.author.name) + expect(page).to have_content(spending_proposal.association_name) + expect(page).to have_content(spending_proposal.geozone.name) + expect(page).to have_content('1234.56') + expect(page).to have_content('Not feasible') + expect(page).to have_content('It is impossible') + expect(page).to have_content('Ana (ana@admins.org)') + + within('#assigned_valuators') do + expect(page).to have_content('Rachel (rachel@valuators.org)') + end + end + end