Skip to content

Commit

Permalink
Fix symptoms of #91
Browse files Browse the repository at this point in the history
Doesn’t solve why multiple opinions for same user enter the system, but
makes it so that the same opinion is provided via proposals and the
specific proposal.
  • Loading branch information
tkriplean committed Sep 16, 2016
1 parent 2df1c42 commit cc67fe9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion @client/filter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ OpinionFilter = ReactiveComponent
display: 'inline-block'
marginLeft: 7
padding: '0 0 0 7px'
color: if is_enabled then focus_blue else '#999'
color: if is_enabled then focus_blue else '#777'
cursor: 'pointer'
fontSize: 16
backgroundColor: 'transparent'
Expand Down
4 changes: 2 additions & 2 deletions @server/models/opinion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.get_or_make(proposal)
user = current_user

# First try to find a published opinion for this user
your_opinion = proposal.opinions.where(:user => user)
your_opinion = user.opinions.where(:proposal_id => proposal.id).order('id DESC')

if your_opinion.length > 1
pp "Duplicate opinions for user #{user}: #{your_opinion.map {|o| o.id} }!"
Expand All @@ -43,7 +43,7 @@ def self.get_or_make(proposal)
if your_opinion.nil?
ActsAsTenant.without_tenant do
your_opinion = Opinion.create!(:proposal_id => proposal.id,
:user => user ? user : nil,
:user => user,
:subdomain_id => proposal.subdomain_id,
:stance => 0,
:point_inclusions => '[]',
Expand Down
2 changes: 1 addition & 1 deletion @server/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def self.summaries(subdomain = nil, all_points = false)
# user for all proposals
your_opinions = {}
if subdomain.name != 'homepage'
Opinion.where(:user => current_user).each do |opinion|
Opinion.where(:user => current_user).order('id DESC').each do |opinion|
your_opinions[opinion.proposal_id] = opinion
end

Expand Down

0 comments on commit cc67fe9

Please sign in to comment.