diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-03-07 22:53:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-07 22:53:47 +0100 |
commit | 054bbb3da21b2c76374eb921cba862adb8d5a0b3 (patch) | |
tree | 61e4ea5e735631b6e947ca00884588ca184e8ab6 /app/serializers/rest | |
parent | 75cb93676b1dd41d3e47f62466c0c6430691a990 (diff) |
Immediately display poll results to poll author (#10187)
* Immediately display poll results to poll author * Refactor Poll#loaded_options and add Poll#voted? to improve DRYness
Diffstat (limited to 'app/serializers/rest')
-rw-r--r-- | app/serializers/rest/poll_serializer.rb | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/app/serializers/rest/poll_serializer.rb b/app/serializers/rest/poll_serializer.rb index b02e8ca93..4dae1c09f 100644 --- a/app/serializers/rest/poll_serializer.rb +++ b/app/serializers/rest/poll_serializer.rb @@ -4,7 +4,7 @@ class REST::PollSerializer < ActiveModel::Serializer attributes :id, :expires_at, :expired, :multiple, :votes_count - has_many :dynamic_options, key: :options + has_many :loaded_options, key: :options attribute :voted, if: :current_user? @@ -12,20 +12,12 @@ class REST::PollSerializer < ActiveModel::Serializer object.id.to_s end - def dynamic_options - if !object.expired? && object.hide_totals? - object.unloaded_options - else - object.loaded_options - end - end - def expired object.expired? end def voted - object.votes.where(account: current_user.account).exists? + object.voted?(current_user.account) end def current_user? |