Skip to content

Commit

Permalink
Display other submissions by the same artist
Browse files Browse the repository at this point in the history
Fixes #87
  • Loading branch information
ywwg committed Feb 10, 2018
1 parent fb0dac0 commit a074c5d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/grant_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def update
end

def show
@other_submissions = GrantSubmission.where(artist_id: @grant_submission.artist_id)
end

def index
Expand Down
4 changes: 4 additions & 0 deletions app/models/grant_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def has_answers?
answers.present?
end

def has_other_submissions?
GrantSubmission.where(artist_id: artist_id).count > 1
end

def max_voters
3
end
Expand Down
18 changes: 18 additions & 0 deletions app/views/grant_submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@
</div>
</div>
</div>
<% if can? :edit_questions, GrantSubmission or can? :vote, GrantSubmission %>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Other Submissions by This Artist</h3>
</div>
<div class="panel-body">
<dl>
<% @other_submissions.each do |s| %>
<% if s.name != @grant_submission.name %>
<dd><%= s.name %> &mdash; <%= Grant.find(s.grant_id).name %></dd>
<% end %>
<% end %>
</dl>
</div>
</div>
</div>
<% end %>
</div>

<div class="row">
Expand Down

0 comments on commit a074c5d

Please sign in to comment.