Skip to content

Commit

Permalink
Merge pull request #128 from fdel15/new-events-person-profile
Browse files Browse the repository at this point in the history
Show news items and events that a person has created on their profile
  • Loading branch information
kentonh authored Oct 15, 2017
2 parents ecd4d6a + a33db3c commit dedd094
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def full_name
"#{first_name} #{last_name}".strip
end

def news_items
news + News.where('user_id = ?', user_id)
end

def event_items
events + Event.where('user_id = ?', user_id)
end

class << self

def pdate_profiles_scores
Expand Down
12 changes: 6 additions & 6 deletions app/views/shared/_profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
<% end %>
</div>
<% end %>
<% unless person.news.empty? then %>
<% unless person.news_items.empty? then %>
<div class="meta">
<h4 class="meta-title">Related News</h4>
<% person.news.take(10).each do |news| %>
<% person.news_items.take(10).each do |news| %>
<%= render partial: 'shared/news', locals: {newsItem: news} %>
<% end %>
<% if person.news.size > 10 then %>
<% if person.news_items.size > 10 then %>
<%= link_to "View More", news_index_path(person: person.slug) %>
<% end %>
</div>
<% end %>

<% unless person.events.empty? then %>
<% unless person.event_items.empty? then %>
<div class="meta">
<h4 class="meta-title">Related Events</h4>
<% person.events.take(10).each do |event| %>
<% person.event_items.take(10).each do |event| %>
<%= render partial: 'shared/event', locals: {event: event} %>
<% end %>
<% if person.events.size > 10 then %>
<% if person.event_items.size > 10 then %>
<%= link_to "View More", events_path(person: person.slug) %>
<% end %>
</div>
Expand Down

0 comments on commit dedd094

Please sign in to comment.