socialforge/app/api/mobile/entities/journal.rb

44 lines
1.0 KiB
Ruby
Raw Normal View History

2016-03-31 20:46:36 +08:00
module Mobile
module Entities
class Journal <Grape::Entity
2016-04-01 23:22:39 +08:00
include Redmine::I18n
2016-04-01 18:46:00 +08:00
=begin
2016-03-31 20:46:36 +08:00
include Redmine::I18n
include ApplicationHelper
include ApiHelper
2016-04-01 18:46:00 +08:00
include IssuesHelper
2016-03-31 20:46:36 +08:00
include ActionView::Helpers::TagHelper
2016-04-01 18:46:00 +08:00
include ActionView::Helpers::UrlHelper
=end
2016-03-31 20:46:36 +08:00
def self.journal_expose(f)
expose f do |journal, opt|
if journal.is_a?(Hash) && journal.key?(f)
journal[f]
elsif journal.is_a?(::Journal)
if journal.respond_to?(f)
if f == :created_on
2016-04-01 23:22:39 +08:00
time_from_now(journal.send(f))
2016-03-31 20:46:36 +08:00
else
journal.send(f)
end
else
case f
when :detail_journal
if journal.details.any?
2016-04-01 18:46:00 +08:00
details_to_strings(journal.details)
2016-03-31 20:46:36 +08:00
end
end
end
end
end
end
expose :notes
journal_expose :created_on
2016-04-01 21:32:33 +08:00
expose :user,using: Mobile::Entities::User do |f, opt|
f.user
end
2016-04-01 18:46:00 +08:00
#journal_expose :detail_journal
2016-03-31 20:46:36 +08:00
end
end
end