Skip to content

Commit

Permalink
updating discussion_topic model to add author id to announcement feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dansbeerlist committed Oct 9, 2013
1 parent a2a663a commit e1b56ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/discussion_topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,16 @@ def discussion_topic
end

def to_atom(opts={})
# Empowered: Adding author id to discussion topics
author_id = self.user.present? ? self.user.attributes['id'] : t('#discussion_topic.atom_no_author', "No Author")
author_name = self.user.present? ? self.user.name : t('#discussion_topic.atom_no_author', "No Author")
prefix = [self.is_announcement ? t('#titles.announcement', "Announcement") : t('#titles.discussion', "Discussion")]
prefix << self.context.name if opts[:include_context]
Atom::Entry.new do |entry|
entry.title = [before_label(prefix.to_sentence), self.title].join(" ")
entry.authors << Atom::Person.new(:name => author_name)
# Empowered: Adding author id to discussion topics
#entry.authors << Atom::Person.new(:name => author_name)
entry.authors << Atom::Person.new(:name => author_name, :uri => "http://#{HostUrl.default_host}/api/v1/users/#{author_id}/profile")
entry.updated = self.updated_at
entry.published = self.created_at
entry.id = "tag:#{HostUrl.default_host},#{self.created_at.strftime("%Y-%m-%d")}:/discussion_topics/#{self.feed_code}"
Expand Down

0 comments on commit e1b56ac

Please sign in to comment.