Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show news items and events that a person has created on their profile #128

Merged
merged 1 commit into from
Oct 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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