Added poll method voted_in_web?

This commit is contained in:
María Checa
2017-10-17 13:16:46 +02:00
parent e1e9b431d7
commit 58f57bc15b
2 changed files with 5 additions and 1 deletions

View File

@@ -65,6 +65,10 @@ class Poll < ActiveRecord::Base
Poll::Voter.where(poll: self, user: user, origin: "booth").exists?
end
def voted_in_web?(user)
Poll::Voter.where(poll: self, user: user, origin: "web").exists?
end
def date_range
unless starts_at.present? && ends_at.present? && starts_at <= ends_at
errors.add(:starts_at, I18n.t('errors.messages.invalid_date_range'))

View File

@@ -39,7 +39,7 @@
</div>
<% else %>
<% unless current_user && @poll.votable_by?(current_user) %>
<% if current_user && @poll.voted_in_web?(current_user) %>
<div class="callout warning">
<%= t("polls.show.already_voted_in_web") %>
</div>