diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 06d2f78f7..2faf9b3f8 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -49,6 +49,16 @@ module PollsHelper question.answers.where(author: current_user).any? { |vote| current_user.current_sign_in_at > vote.updated_at } end + def link_to_poll(text, poll) + if poll.results_enabled? + link_to text, results_poll_path(id: poll.slug || poll.id) + elsif poll.stats_enabled? + link_to text, stats_poll_path(id: poll.slug || poll.id) + else + link_to text, poll_path(id: poll.slug || poll.id) + end + end + def show_stats_or_results? @poll.expired? && (@poll.results_enabled? || @poll.stats_enabled?) end diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 8bd388b10..1de745cdf 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -31,27 +31,11 @@
<% if poll.questions.count == 1 %> <% poll.questions.each do |question| %> -

- <% if poll.results_enabled? %> - <%= link_to question.title, results_poll_path(poll) %> - <% elsif poll.stats_enabled? %> - <%= link_to question.title, stats_poll_path(poll) %> - <% else %> - <%= link_to question.title, poll %> - <% end %> -

+

<%= link_to_poll question.title, poll %>

<%= poll_dates(poll) %> <% end %> <% else %> -

- <% if poll.results_enabled? %> - <%= link_to poll.name, results_poll_path(poll) %> - <% elsif poll.stats_enabled? %> - <%= link_to poll.name, stats_poll_path(poll) %> - <% else %> - <%= link_to poll.name, poll_path(id: poll.slug || poll.id) %> - <% end %> -

+

<%= link_to_poll poll.name, poll %>

<%= poll_dates(poll) %>