Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

This commit is contained in:
guange 2016-03-30 15:32:55 +08:00
commit 5b9cbe8784
4 changed files with 38 additions and 18 deletions

View File

@ -19,7 +19,7 @@ module Mobile
else else
ac.act unless ac.nil? || ac.act.nil? ac.act unless ac.nil? || ac.act.nil?
end end
when :reply_num when :reply_count
if ac.act_type == "HomeworkCommon" if ac.act_type == "HomeworkCommon"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
elsif ac.act_type == "News" elsif ac.act_type == "News"
@ -29,7 +29,7 @@ module Mobile
elsif ac.act_type == "Issue" elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count
end end
when :activity_praise_num when :activity_praise_count
if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue" if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act) ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
end end
@ -76,9 +76,9 @@ module Mobile
end end
end end
end end
expose :act_type expose :act_type #缺陷/作业/讨论区/留言等类型
expose :container_type expose :container_type #课程/项目/博客/个人
expose :author, using: Mobile::Entities::User do |a, opt| expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
if a.is_a? ::UserActivity if a.is_a? ::UserActivity
if a.act_type == "ProjectCreateInfo" if a.act_type == "ProjectCreateInfo"
get_user(get_project(a.act_id).user_id) get_user(get_project(a.act_id).user_id)
@ -91,12 +91,12 @@ module Mobile
end end
end end
end end
act_expose :homework_common_detail_manual act_expose :homework_common_detail_manual #作业相关信息
act_expose :reply_num act_expose :reply_count #回复数
act_expose :activity_praise_num act_expose :activity_praise_count #点赞数
act_expose :user_act act_expose :user_act #某个动态
act_expose :course_project_name act_expose :course_project_name #课程/项目名字
act_expose :activity_type_name act_expose :activity_type_name #课程问答区/项目缺陷等
end end
end end
end end

View File

@ -1,9 +1,19 @@
module Mobile module Mobile
module Entities module Entities
class Issue <Grape::Entity class Issue <Grape::Entity
include ApiHelper
include Redmine::I18n
def self.issue_expose(f)
f
end
expose :subject expose :subject
expose :description expose :description
expose :author, using: Mobile::Entities::User expose :author, using: Mobile::Entities::User
expose :done_ratio
issue_expose :issue_priority
issue_expose :issue_assigned_to
issue_expose :issue_status
issue_expose :issue_status
end end
end end
end end

View File

@ -24,11 +24,21 @@ module Mobile
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0) wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
when :evaluation_end when :evaluation_end
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1) wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
when :whomework_praise_count
get_activity_praise_num(wh)
when :whomework_journal_count
wh.journals_for_messages.count
end end
end end
end end
end end
end end
expose :author, using: Mobile::Entities::User do |w, opt|
if w.is_a?(::HomeworkCommon)
w.user
end
end
expose :name expose :name
expose :description expose :description
expose :publish_time expose :publish_time
@ -43,10 +53,10 @@ module Mobile
whomework_expose :absence_penalty whomework_expose :absence_penalty
whomework_expose :evaluation_start whomework_expose :evaluation_start
whomework_expose :evaluation_end whomework_expose :evaluation_end
expose :author, using: Mobile::Entities::User do |w, opt| whomework_expose :whomework_praise_count
if w.is_a?(::HomeworkCommon) whomework_expose :whomework_journal_count
w.user expose :jours, using: Mobile::Entities::Jours do |f, opt|
end f[:jour] if f.is_a?(Hash) && f.key?(:jour)
end end
end end
end end

View File

@ -48,10 +48,10 @@ module RedmineApp
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
#config.i18n.default_locale = :zh config.i18n.default_locale = :zh
config.i18n.enforce_available_locales = true #config.i18n.enforce_available_locales = true
I18n.config.enforce_available_locales = true #I18n.config.enforce_available_locales = true
# Configure the default encoding used in templates for Ruby 1.9. # Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8" config.encoding = "utf-8"