微信最新动态修改
This commit is contained in:
parent
6f9fcbe1a7
commit
77e11fe0fe
|
@ -1,32 +1,32 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Activities< Grape::API
|
||||
resources :activities do
|
||||
|
||||
desc "get user activities"
|
||||
get ':id' do
|
||||
#uw = UserWechat.find params[:openid]
|
||||
user = User.find params[:id]
|
||||
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||
principal_types = "JournalsForMessage"
|
||||
|
||||
blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")"
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10)
|
||||
present :data, activities, with: Mobile::Entities::Activity
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Activities< Grape::API
|
||||
resources :activities do
|
||||
|
||||
desc "get user activities"
|
||||
get ':id' do
|
||||
#uw = UserWechat.find params[:openid]
|
||||
user = User.find params[:id]
|
||||
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||
principal_types = "JournalsForMessage"
|
||||
|
||||
blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")"
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10)
|
||||
present :data, activities, with: Mobile::Entities::Activity
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +1,17 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class BlogComments< Grape::API
|
||||
resources :blog_comments do
|
||||
|
||||
desc "get special topic"
|
||||
get ':id' do
|
||||
blog = BlogComment.find params[:id]
|
||||
present :blog, message, with: Mobile::Entities::BlogComment
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class BlogComments< Grape::API
|
||||
resources :blog_comments do
|
||||
|
||||
desc "get special topic"
|
||||
get ':id' do
|
||||
blog = BlogComment.find params[:id]
|
||||
present :blog, message, with: Mobile::Entities::BlogComment
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Issues< Grape::API
|
||||
resources :issues do
|
||||
|
||||
desc "get special issuse"
|
||||
get ':id' do
|
||||
issue = Issue.find params[:id]
|
||||
present :data, issue, with: Mobile::Entities::Issue
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Issues< Grape::API
|
||||
resources :issues do
|
||||
|
||||
desc "get special issuse"
|
||||
get ':id' do
|
||||
issue = Issue.find params[:id]
|
||||
present :data, issue, with: Mobile::Entities::Issue
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class JournalForMessages< Grape::API
|
||||
resources :journal_for_messages do
|
||||
|
||||
desc "get special journal"
|
||||
get ':id' do
|
||||
jour = JournalsForMessage.find params[:id]
|
||||
present :data, jour, with: Mobile::Entities::Jours
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class JournalForMessages< Grape::API
|
||||
resources :journal_for_messages do
|
||||
|
||||
desc "get special journal"
|
||||
get ':id' do
|
||||
jour = JournalsForMessage.find params[:id]
|
||||
present :data, jour, with: Mobile::Entities::Jours
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Messages< Grape::API
|
||||
resources :messages do
|
||||
|
||||
desc "get special topic"
|
||||
get ':id' do
|
||||
message = Message.find params[:id]
|
||||
present :data, message, with: Mobile::Entities::Message
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Messages< Grape::API
|
||||
resources :messages do
|
||||
|
||||
desc "get special topic"
|
||||
get ':id' do
|
||||
message = Message.find params[:id]
|
||||
present :data, message, with: Mobile::Entities::Message
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Newss< Grape::API
|
||||
resources :newss do
|
||||
|
||||
desc "get special news"
|
||||
get ':id' do
|
||||
news = News.find params[:id]
|
||||
present :data, news, with: Mobile::Entities::News
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Newss< Grape::API
|
||||
resources :newss do
|
||||
|
||||
desc "get special news"
|
||||
get ':id' do
|
||||
news = News.find params[:id]
|
||||
present :data, news, with: Mobile::Entities::News
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Whomeworks< Grape::API
|
||||
resources :whomeworks do
|
||||
|
||||
desc "get one homework"
|
||||
get ':id' do
|
||||
homework = HomeworkCommon.find params[:id]
|
||||
present :data, homework, with: Mobile::Entities::Whomework
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Whomeworks< Grape::API
|
||||
resources :whomeworks do
|
||||
|
||||
desc "get one homework"
|
||||
get ':id' do
|
||||
homework = HomeworkCommon.find params[:id]
|
||||
present :data, homework, with: Mobile::Entities::Whomework
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,132 +1,132 @@
|
|||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Activity <Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.act_expose(f)
|
||||
expose f do |ac,opt|
|
||||
if ac.is_a?(Hash) && ac.key?(f)
|
||||
ac[f]
|
||||
elsif ac.is_a?(::UserActivity)
|
||||
if ac.respond_to?(f)
|
||||
ac.send(f)
|
||||
else
|
||||
case f
|
||||
when :user_act
|
||||
if ac.act_type == "ProjectCreateInfo"
|
||||
ac unless ac.nil?
|
||||
else
|
||||
ac.act unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :reply_count
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
|
||||
elsif ac.act_type == "News"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
|
||||
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
|
||||
elsif ac.act_type == "Issue"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count
|
||||
end
|
||||
when :subject
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.act.name unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
|
||||
ac.act.title unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "Issue"
|
||||
ac.act.subject unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "JournalsForMessage"
|
||||
ac.act.private == 0 ? "留言" : "私信"
|
||||
end
|
||||
when :description
|
||||
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
|
||||
ac.act.description unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
|
||||
ac.act.content unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :latest_update
|
||||
time_from_now ac.updated_at unless ac.nil?
|
||||
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"
|
||||
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
|
||||
end
|
||||
#when :homework_common_detail_manual
|
||||
# if ac.act_type == "HomeworkCommon"
|
||||
# ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
|
||||
# end
|
||||
when :course_project_name
|
||||
if ac.container_type == "Course"
|
||||
name = (get_course(ac.container_id)).name
|
||||
name
|
||||
elsif ac.container_type == "Project"
|
||||
name = (get_project(ac.container_id)).name
|
||||
name
|
||||
elsif ac.container_type == "Blog"
|
||||
"发表博客"
|
||||
end
|
||||
when :activity_type_name
|
||||
if ac.container_type == "Course"
|
||||
case ac.act_type
|
||||
when "HomeworkCommon"
|
||||
"课程作业"
|
||||
when "News"
|
||||
"课程通知"
|
||||
when "Message"
|
||||
"课程问答区"
|
||||
when "Poll"
|
||||
"课程问卷"
|
||||
when "Course"
|
||||
"课程"
|
||||
end
|
||||
elsif ac.container_type == "Project"
|
||||
case ac.act_type
|
||||
when "Issue"
|
||||
"项目缺陷"
|
||||
when "Message"
|
||||
"项目问答区"
|
||||
when "ProjectCreateInfo"
|
||||
"项目"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :act_type #缺陷/作业/讨论区/留言等类型
|
||||
expose :container_type #课程/项目/博客/个人
|
||||
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
|
||||
if a.is_a? ::UserActivity
|
||||
if a.act_type == "ProjectCreateInfo"
|
||||
get_user(get_project(a.act_id).user_id)
|
||||
elsif a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
|
||||
a.act.author
|
||||
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
|
||||
a.act.user
|
||||
elsif a.act_type == 'Course'
|
||||
a.act.teacher
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息
|
||||
if a.act_type == "HomeworkCommon"
|
||||
a.act
|
||||
end
|
||||
end
|
||||
expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息
|
||||
if a.act_type == "Issue"
|
||||
a.act
|
||||
end
|
||||
end
|
||||
act_expose :reply_count #回复数
|
||||
act_expose :activity_praise_count #点赞数
|
||||
#act_expose :user_act #某个动态
|
||||
act_expose :subject #标题
|
||||
act_expose :description #描述
|
||||
act_expose :latest_update #最新更新时间
|
||||
act_expose :course_project_name #课程/项目名字
|
||||
act_expose :activity_type_name #课程问答区/项目缺陷等
|
||||
end
|
||||
end
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Activity <Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.act_expose(f)
|
||||
expose f do |ac,opt|
|
||||
if ac.is_a?(Hash) && ac.key?(f)
|
||||
ac[f]
|
||||
elsif ac.is_a?(::UserActivity)
|
||||
if ac.respond_to?(f)
|
||||
ac.send(f)
|
||||
else
|
||||
case f
|
||||
when :user_act
|
||||
if ac.act_type == "ProjectCreateInfo"
|
||||
ac unless ac.nil?
|
||||
else
|
||||
ac.act unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :reply_count
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
|
||||
elsif ac.act_type == "News"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
|
||||
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
|
||||
elsif ac.act_type == "Issue"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count
|
||||
end
|
||||
when :subject
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.act.name unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
|
||||
ac.act.title unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "Issue"
|
||||
ac.act.subject unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "JournalsForMessage"
|
||||
ac.act.private == 0 ? "留言" : "私信"
|
||||
end
|
||||
when :description
|
||||
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
|
||||
ac.act.description unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
|
||||
ac.act.content unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :latest_update
|
||||
time_from_now ac.updated_at unless ac.nil?
|
||||
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"
|
||||
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
|
||||
end
|
||||
#when :homework_common_detail_manual
|
||||
# if ac.act_type == "HomeworkCommon"
|
||||
# ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
|
||||
# end
|
||||
when :course_project_name
|
||||
if ac.container_type == "Course"
|
||||
name = (get_course(ac.container_id)).name
|
||||
name
|
||||
elsif ac.container_type == "Project"
|
||||
name = (get_project(ac.container_id)).name
|
||||
name
|
||||
elsif ac.container_type == "Blog"
|
||||
"发表博客"
|
||||
end
|
||||
when :activity_type_name
|
||||
if ac.container_type == "Course"
|
||||
case ac.act_type
|
||||
when "HomeworkCommon"
|
||||
"课程作业"
|
||||
when "News"
|
||||
"课程通知"
|
||||
when "Message"
|
||||
"课程问答区"
|
||||
when "Poll"
|
||||
"课程问卷"
|
||||
when "Course"
|
||||
"课程"
|
||||
end
|
||||
elsif ac.container_type == "Project"
|
||||
case ac.act_type
|
||||
when "Issue"
|
||||
"项目缺陷"
|
||||
when "Message"
|
||||
"项目问答区"
|
||||
when "ProjectCreateInfo"
|
||||
"项目"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :act_type #缺陷/作业/讨论区/留言等类型
|
||||
expose :container_type #课程/项目/博客/个人
|
||||
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
|
||||
if a.is_a? ::UserActivity
|
||||
if a.act_type == "ProjectCreateInfo"
|
||||
get_user(get_project(a.act_id).user_id)
|
||||
elsif a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
|
||||
a.act.author
|
||||
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
|
||||
a.act.user
|
||||
elsif a.act_type == 'Course'
|
||||
a.act.teacher
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息
|
||||
if a.act_type == "HomeworkCommon"
|
||||
a.act
|
||||
end
|
||||
end
|
||||
expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息
|
||||
if a.act_type == "Issue"
|
||||
a.act
|
||||
end
|
||||
end
|
||||
act_expose :reply_count #回复数
|
||||
act_expose :activity_praise_count #点赞数
|
||||
#act_expose :user_act #某个动态
|
||||
act_expose :subject #标题
|
||||
act_expose :description #描述
|
||||
act_expose :latest_update #最新更新时间
|
||||
act_expose :course_project_name #课程/项目名字
|
||||
act_expose :activity_type_name #课程问答区/项目缺陷等
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,46 +1,46 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class BlogComment < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.blog_comment_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::BlogComment)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time( u.send(f))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
else
|
||||
# case f
|
||||
# when :xx
|
||||
# #
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::BlogComment)
|
||||
c.author
|
||||
end
|
||||
end
|
||||
blog_comment_expose :blog_id
|
||||
blog_comment_expose :title
|
||||
blog_comment_expose :content
|
||||
blog_comment_expose :comments_count
|
||||
blog_comment_expose :created_at
|
||||
blog_comment_expose :id
|
||||
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
|
||||
if c.is_a? (::BlogComment)
|
||||
c.children
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
module Mobile
|
||||
module Entities
|
||||
class BlogComment < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.blog_comment_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::BlogComment)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time( u.send(f))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
else
|
||||
# case f
|
||||
# when :xx
|
||||
# #
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::BlogComment)
|
||||
c.author
|
||||
end
|
||||
end
|
||||
blog_comment_expose :blog_id
|
||||
blog_comment_expose :title
|
||||
blog_comment_expose :content
|
||||
blog_comment_expose :comments_count
|
||||
blog_comment_expose :created_at
|
||||
blog_comment_expose :id
|
||||
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
|
||||
if c.is_a? (::BlogComment)
|
||||
c.children
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +1,35 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class Issue <Grape::Entity
|
||||
include ApiHelper
|
||||
include Redmine::I18n
|
||||
def self.issue_expose(f)
|
||||
expose f do |issue, opt|
|
||||
if issue.is_a?(Hash) && issue.key?(f)
|
||||
issue[f]
|
||||
elsif issue.is_a?(::Issue)
|
||||
if issue.respond_to?(f)
|
||||
issue.send(f)
|
||||
else
|
||||
case f
|
||||
when :issue_priority
|
||||
get_issue_priority_api issue.priority_id
|
||||
when :issue_assigned_to
|
||||
(get_user(issue.assigned_to_id)).login
|
||||
when :issue_status
|
||||
IssueStatus.find(issue.status_id).name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :subject
|
||||
expose :description
|
||||
expose :author, using: Mobile::Entities::User
|
||||
expose :done_ratio
|
||||
issue_expose :issue_priority
|
||||
issue_expose :issue_assigned_to
|
||||
issue_expose :issue_status
|
||||
end
|
||||
end
|
||||
module Mobile
|
||||
module Entities
|
||||
class Issue <Grape::Entity
|
||||
include ApiHelper
|
||||
include Redmine::I18n
|
||||
def self.issue_expose(f)
|
||||
expose f do |issue, opt|
|
||||
if issue.is_a?(Hash) && issue.key?(f)
|
||||
issue[f]
|
||||
elsif issue.is_a?(::Issue)
|
||||
if issue.respond_to?(f)
|
||||
issue.send(f)
|
||||
else
|
||||
case f
|
||||
when :issue_priority
|
||||
get_issue_priority_api issue.priority_id
|
||||
when :issue_assigned_to
|
||||
(get_user(issue.assigned_to_id)).login
|
||||
when :issue_status
|
||||
IssueStatus.find(issue.status_id).name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :subject
|
||||
expose :description
|
||||
expose :author, using: Mobile::Entities::User
|
||||
expose :done_ratio
|
||||
issue_expose :issue_priority
|
||||
issue_expose :issue_assigned_to
|
||||
issue_expose :issue_status
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,66 +1,66 @@
|
|||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Whomework <Grape::Entity
|
||||
include ApiHelper
|
||||
include ApplicationHelper
|
||||
include Redmine::I18n
|
||||
def self.whomework_expose(f)
|
||||
expose f do |wh, opt|
|
||||
if wh.is_a?(Hash) && wh.key?(f)
|
||||
if f == :created_at
|
||||
format_time(wh[f])
|
||||
else
|
||||
wh[f]
|
||||
end
|
||||
elsif wh.is_a?(::HomeworkCommon)
|
||||
if wh.respond_to?(f)
|
||||
wh.send(f)
|
||||
else
|
||||
case f
|
||||
when :absence_penalty
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
|
||||
when :evaluation_start
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
|
||||
when :evaluation_end
|
||||
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
|
||||
|
||||
expose :author, using: Mobile::Entities::User do |w, opt|
|
||||
if w.is_a?(::HomeworkCommon)
|
||||
w.user
|
||||
end
|
||||
end
|
||||
expose :name
|
||||
expose :description
|
||||
expose :publish_time
|
||||
expose :end_time
|
||||
expose :homework_type
|
||||
expose :late_penalty
|
||||
expose :course_id
|
||||
expose :anonymous_comment
|
||||
expose :quotes
|
||||
expose :is_open
|
||||
whomework_expose :created_at
|
||||
whomework_expose :absence_penalty
|
||||
whomework_expose :evaluation_start
|
||||
whomework_expose :evaluation_end
|
||||
whomework_expose :whomework_praise_count
|
||||
whomework_expose :whomework_journal_count
|
||||
expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt|
|
||||
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
|
||||
if f.is_a?(::HomeworkCommon)
|
||||
f.journals_for_messages
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Whomework <Grape::Entity
|
||||
include ApiHelper
|
||||
include ApplicationHelper
|
||||
include Redmine::I18n
|
||||
def self.whomework_expose(f)
|
||||
expose f do |wh, opt|
|
||||
if wh.is_a?(Hash) && wh.key?(f)
|
||||
if f == :created_at
|
||||
format_time(wh[f])
|
||||
else
|
||||
wh[f]
|
||||
end
|
||||
elsif wh.is_a?(::HomeworkCommon)
|
||||
if wh.respond_to?(f)
|
||||
wh.send(f)
|
||||
else
|
||||
case f
|
||||
when :absence_penalty
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
|
||||
when :evaluation_start
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
|
||||
when :evaluation_end
|
||||
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
|
||||
|
||||
expose :author, using: Mobile::Entities::User do |w, opt|
|
||||
if w.is_a?(::HomeworkCommon)
|
||||
w.user
|
||||
end
|
||||
end
|
||||
expose :name
|
||||
expose :description
|
||||
expose :publish_time
|
||||
expose :end_time
|
||||
expose :homework_type
|
||||
expose :late_penalty
|
||||
expose :course_id
|
||||
expose :anonymous_comment
|
||||
expose :quotes
|
||||
expose :is_open
|
||||
whomework_expose :created_at
|
||||
whomework_expose :absence_penalty
|
||||
whomework_expose :evaluation_start
|
||||
whomework_expose :evaluation_end
|
||||
whomework_expose :whomework_praise_count
|
||||
whomework_expose :whomework_journal_count
|
||||
expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt|
|
||||
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
|
||||
if f.is_a?(::HomeworkCommon)
|
||||
f.journals_for_messages
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,96 +1,96 @@
|
|||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
require 'sprockets/railtie'
|
||||
require 'elasticsearch/model'
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||
# If you want your assets lazily compiled in production, use this line
|
||||
# Bundler.require(:default, :assets, Rails.env)
|
||||
end
|
||||
|
||||
module RedmineApp
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
#verifier if email is real
|
||||
|
||||
|
||||
config.generators do |g|
|
||||
g.test_framework :rspec,
|
||||
fixtures: true,
|
||||
view_specs: false,
|
||||
helper_specs: false,
|
||||
routing_specs: false,
|
||||
controller_specs: true,
|
||||
request_specs: false
|
||||
g.fixture_replacement :factory_girl, dir: "spec/factories"
|
||||
end
|
||||
# Custom directories with classes and modules you want to be autoloadable.
|
||||
config.autoload_paths += %W(#{config.root}/lib)
|
||||
config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers)
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# Activate observers that should always be running.
|
||||
config.active_record.observers = :journals_for_message_observer, :issue_observer, :journal_observer, :wiki_content_observer
|
||||
|
||||
config.active_record.store_full_sti_class = true
|
||||
config.active_record.default_timezone = :local
|
||||
config.time_zone = 'Beijing'
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
|
||||
# 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.default_locale = :zh
|
||||
|
||||
#config.i18n.enforce_available_locales = true
|
||||
#I18n.config.enforce_available_locales = true
|
||||
# Configure the default encoding used in templates for Ruby 1.9.
|
||||
config.encoding = "utf-8"
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [:password]
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = false
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.0'
|
||||
|
||||
config.action_mailer.perform_deliveries = false
|
||||
|
||||
# Do not include all helpers
|
||||
config.action_controller.include_all_helpers = false
|
||||
|
||||
config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed'
|
||||
|
||||
config.before_initialize do
|
||||
end
|
||||
|
||||
config.after_initialize do
|
||||
if RbConfig::CONFIG['target_os'] == 'mingw32'
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true
|
||||
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n",""))
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true
|
||||
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n",""))
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true
|
||||
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n",""))
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true
|
||||
else
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true
|
||||
end
|
||||
end
|
||||
|
||||
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||||
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
require 'sprockets/railtie'
|
||||
require 'elasticsearch/model'
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||
# If you want your assets lazily compiled in production, use this line
|
||||
# Bundler.require(:default, :assets, Rails.env)
|
||||
end
|
||||
|
||||
module RedmineApp
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
#verifier if email is real
|
||||
|
||||
|
||||
config.generators do |g|
|
||||
g.test_framework :rspec,
|
||||
fixtures: true,
|
||||
view_specs: false,
|
||||
helper_specs: false,
|
||||
routing_specs: false,
|
||||
controller_specs: true,
|
||||
request_specs: false
|
||||
g.fixture_replacement :factory_girl, dir: "spec/factories"
|
||||
end
|
||||
# Custom directories with classes and modules you want to be autoloadable.
|
||||
config.autoload_paths += %W(#{config.root}/lib)
|
||||
config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers)
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# Activate observers that should always be running.
|
||||
config.active_record.observers = :journals_for_message_observer, :issue_observer, :journal_observer, :wiki_content_observer
|
||||
|
||||
config.active_record.store_full_sti_class = true
|
||||
config.active_record.default_timezone = :local
|
||||
config.time_zone = 'Beijing'
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
|
||||
# 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.default_locale = :zh
|
||||
|
||||
#config.i18n.enforce_available_locales = true
|
||||
#I18n.config.enforce_available_locales = true
|
||||
# Configure the default encoding used in templates for Ruby 1.9.
|
||||
config.encoding = "utf-8"
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [:password]
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = false
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.0'
|
||||
|
||||
config.action_mailer.perform_deliveries = false
|
||||
|
||||
# Do not include all helpers
|
||||
config.action_controller.include_all_helpers = false
|
||||
|
||||
config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed'
|
||||
|
||||
config.before_initialize do
|
||||
end
|
||||
|
||||
config.after_initialize do
|
||||
if RbConfig::CONFIG['target_os'] == 'mingw32'
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true
|
||||
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n",""))
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true
|
||||
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n",""))
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true
|
||||
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n",""))
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true
|
||||
else
|
||||
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true
|
||||
end
|
||||
end
|
||||
|
||||
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||||
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
4184
db/schema.rb
4184
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>react js</title>
|
||||
<title>最新动态</title>
|
||||
<meta charset='utf-8' />
|
||||
<meta name="keywords" content="" />
|
||||
<meta name="description" content="" />
|
||||
|
@ -20,65 +20,65 @@
|
|||
|
||||
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
||||
<script id="t:result-list" type="text/html">
|
||||
<! for(var i =0; i <activities.length; ++i){ !>
|
||||
<! var container_type = "course"; var act_type = "homework"; !>
|
||||
<! if (container_type == "course") { !>
|
||||
<! if (act_type == "homework") { !>
|
||||
<! for(var i =0; i < activities.length; ++i){ !>
|
||||
<! var container_type = activities[i].container_type; var act_type = activities[i].act_type; !>
|
||||
<! if (container_type == "Course") { !>
|
||||
<! if (act_type == "HomeworkCommon") { !>
|
||||
<!--homework -->
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10">我的私有课程 | 课程作业</a></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10"><!=activities[i].course_project_name!> | <!=activities[i].activity_type_name!></a></div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10">
|
||||
<div class="post-all-content"><!:=activities[i].description!><br />
|
||||
<span class="mr15">迟交扣分:10分</span> 匿评开启时间:2016-03-14 00:00<br />
|
||||
<span class="mr15">缺评扣分:5分/作品</span> 匿评关闭时间:2016-03-21 23:59</div>
|
||||
<span class="mr15">迟交扣分:<!:=activities[i].homework_common_detail.late_penalty!>分</span> 匿评开启时间:<!:=activities[i].homework_common_detail.evaluation_start!><br />
|
||||
<span class="mr15">缺评扣分:<!:=activities[i].homework_common_detail.absence_penalty!>分/作品</span> 匿评关闭时间:<!:=activities[i].homework_common_detail.evaluation_end!></div>
|
||||
</div>
|
||||
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||
<div class="cl"></div>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].latest_update!></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复<!=activities[i].reply_num!></div>
|
||||
<div class="post-interactive-column c-grey2">赞<!=activities[i].praise_num!></div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<! } else if (act_type == "news") { !>
|
||||
<! } else if (act_type == "News") { !>
|
||||
<!-- course news -->
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10">我的私有课程 | 课程讨论区</a></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<!=activities[i].course_project_name!> | <!=activities[i].activity_type_name!></div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10">
|
||||
<div class="post-all-content"><!:=activities[i].description!></div>
|
||||
</div>
|
||||
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||
<div class="cl"></div>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].latest_update!></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复</div>
|
||||
<div class="post-interactive-column c-grey2">赞</div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<! } else if (act_type == "messge") { !>
|
||||
<! } else if (act_type == "Message") { !>
|
||||
<!--course message -->
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span><br />
|
||||
<span class="c-grey"><!=activities[i].created_on!></span> </div>
|
||||
<span class="c-grey"><!=activities[i].latest_update!></span> </div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10">
|
||||
<p class="post-all-content"><!:=activities[i].description!></p>
|
||||
|
@ -87,68 +87,68 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复</div>
|
||||
<div class="post-interactive-column c-grey2">赞</div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<! } else if (act_type == "course") { !>
|
||||
<! } else if (act_type == "Course") { !>
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f15 fb">我的私有课程 | 课程</span></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].created_on!></a></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].latest_update!></a></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<! } !>
|
||||
<! } else if (container_type == "project") { !>
|
||||
<! if (act_type == "activities") { !>
|
||||
<! } else if (container_type == "Project") { !>
|
||||
<! if (act_type == "Issue") { !>
|
||||
<!-- activities -->
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to</div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<!=activities[i].course_project_name!> | <!=activities[i].activity_type_name!></div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10">
|
||||
<div class="post-all-content"><!:=activities[i].description!><br />
|
||||
<span class="mr15">指派给:黄井泉</span> <span class="mr15">状态:新增</span> <span class="mr15">完成度:30%</span></div>
|
||||
<span class="mr15">状态:<!:=activities[i].issue_detail.issue_status!></span> <span class="mr15">优先级:<!:=activities[i].issue_detail.issue_priority!></span> <br /> <span class="mr15">指派给:<!:=activities[i].issue_detail.issue_assigned_to!></span> <span class="mr15">完成度:<!:=activities[i].issue_detail.done_ratio!></span></div>
|
||||
</div>
|
||||
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||
<div class="cl"></div>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].latest_update!></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复</div>
|
||||
<div class="post-interactive-column c-grey2">赞</div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<! } else if (act_type == "message") { !>
|
||||
<! } else if (act_type == "Message") { !>
|
||||
<!-- project news -->
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10">我的私有课程 | 课程讨论区</a></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<!=activities[i].course_project_name!> | <!=activities[i].activity_type_name!></div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10">
|
||||
<div class="post-all-content"><!:=activities[i].description!></div>
|
||||
</div>
|
||||
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||
<div class="cl"></div>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].latest_update!></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复</div>
|
||||
<div class="post-interactive-column c-grey2">赞</div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -159,7 +159,7 @@
|
|||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f15 fb">我的私有课程 | 课程</span></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].created_on!></a></div>
|
||||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].latest_update!></a></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -172,7 +172,7 @@
|
|||
<div class="post-main">
|
||||
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
|
||||
<div class="post-title fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span><br />
|
||||
<span class="c-grey"><!=activities[i].created_on!></span> </div>
|
||||
<span class="c-grey"><!=activities[i].latest_update!></span> </div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10">
|
||||
<p class="post-all-content"><!:=activities[i].description!></p>
|
||||
|
@ -181,12 +181,12 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复</div>
|
||||
<div class="post-interactive-column c-grey2">赞</div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<! } else if (container_type == "blog") { !>
|
||||
<! } else if (container_type == "Blog") { !>
|
||||
<!--blog -->
|
||||
<div class="post-container">
|
||||
<div class="post-wrapper">
|
||||
|
@ -200,12 +200,12 @@
|
|||
</div>
|
||||
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||
<div class="cl"></div>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||
<span class="c-grey f13 mt10 fl"><!=activities[i].latest_update!></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive">
|
||||
<div class="post-interactive-column c-grey2">回复</div>
|
||||
<div class="post-interactive-column c-grey2">赞</div>
|
||||
<div class="post-interactive-column c-grey2">回复 (<!=activities[i].reply_count!>)</div>
|
||||
<div class="post-interactive-column c-grey2">赞 (<!=activities[i].activity_praise_count!>)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
/**
|
||||
* Created by root on 3/25/16.
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
|
||||
var bt=baidu.template;
|
||||
bt.LEFT_DELIMITER='<!';
|
||||
bt.RIGHT_DELIMITER='!>';
|
||||
|
||||
|
||||
var apiUrl = '/api/v1/';
|
||||
var setTemplate = function(data){
|
||||
console.log(data);
|
||||
var html=bt('t:result-list',{activities: data});
|
||||
$('#container').prepend(html);
|
||||
descToggle();
|
||||
|
||||
};
|
||||
|
||||
var loadDataFromServer = function(id){
|
||||
//getOpenId(function(openid){
|
||||
$.ajax({
|
||||
url: apiUrl + 'activities/' + id,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
setTemplate(data.data);
|
||||
},
|
||||
error: function(xhr,status,err){
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
//})
|
||||
|
||||
|
||||
};
|
||||
|
||||
loadDataFromServer(8686);
|
||||
|
||||
var descToggle = function(){
|
||||
var postWidth = $(".post-wrapper").width();
|
||||
var titleWidth = postWidth - 80;
|
||||
$(".post-title").css("maxWidth",titleWidth);
|
||||
$(".post-all-content").each(function(){
|
||||
var postHeight = $(this).height();
|
||||
if (postHeight > 90){
|
||||
$(this).parent().next().css("display","block");
|
||||
$(this).parent().next().toggle(function(){
|
||||
$(this).text("点击隐藏");
|
||||
$(this).prev().css("height",postHeight);
|
||||
},function(){
|
||||
$(this).text("点击展开");
|
||||
$(this).prev().css("height",90);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var timeSpilt = function(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
/**
|
||||
* Created by root on 3/25/16.
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
|
||||
var bt=baidu.template;
|
||||
bt.LEFT_DELIMITER='<!';
|
||||
bt.RIGHT_DELIMITER='!>';
|
||||
|
||||
|
||||
var apiUrl = '/api/v1/';
|
||||
var setTemplate = function(data){
|
||||
console.log(data);
|
||||
var html=bt('t:result-list',{activities: data});
|
||||
$('#container').prepend(html);
|
||||
descToggle();
|
||||
|
||||
};
|
||||
|
||||
var loadDataFromServer = function(id){
|
||||
//getOpenId(function(openid){
|
||||
$.ajax({
|
||||
url: apiUrl + 'activities/' + id,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
setTemplate(data.data);
|
||||
},
|
||||
error: function(xhr,status,err){
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
//})
|
||||
|
||||
|
||||
};
|
||||
|
||||
loadDataFromServer(8686);
|
||||
|
||||
var descToggle = function(){
|
||||
var postWidth = $(".post-wrapper").width();
|
||||
var titleWidth = postWidth - 80;
|
||||
$(".post-title").css("maxWidth",titleWidth);
|
||||
$(".post-all-content").each(function(){
|
||||
var postHeight = $(this).height();
|
||||
if (postHeight > 90){
|
||||
$(this).parent().next().css("display","block");
|
||||
$(this).parent().next().toggle(function(){
|
||||
$(this).text("点击隐藏");
|
||||
$(this).prev().css("height",postHeight);
|
||||
},function(){
|
||||
$(this).text("点击展开");
|
||||
$(this).prev().css("height",90);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var timeSpilt = function(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -1,97 +1,97 @@
|
|||
/**
|
||||
* Created by guange on 16/3/21.
|
||||
*//*
|
||||
|
||||
|
||||
var Index = React.createClass({
|
||||
render: function(){
|
||||
return (<div>index page</div>);
|
||||
}
|
||||
});
|
||||
|
||||
var apiUrl = '/api/v1/';
|
||||
|
||||
var PostContainer = React.createClass({
|
||||
loadDataFromServer: function(){
|
||||
$.ajax({
|
||||
url: apiUrl + 'issues/' + this.props.params.id,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
this.setState({data: data.data});
|
||||
}.bind(this),
|
||||
error: function(xhr,status,err){
|
||||
console.log(err);
|
||||
}.bind(this)
|
||||
})
|
||||
},
|
||||
componentDidMount: function(){
|
||||
this.loadDataFromServer();
|
||||
},
|
||||
getInitialState: function(){
|
||||
return {data: null};
|
||||
},
|
||||
render: function(){
|
||||
return (
|
||||
<PostView data={this.state.data}/>
|
||||
)
|
||||
}
|
||||
});
|
||||
|
||||
var PostView = React.createClass({
|
||||
testClick: function(){
|
||||
console.log("123123");
|
||||
},
|
||||
|
||||
render: function(){
|
||||
if(!this.props.data){
|
||||
return <div></div>
|
||||
}
|
||||
|
||||
|
||||
var issueEach = this.props.data.map(function(issue){
|
||||
|
||||
var descMarkup = converter.makeHtml(issue.description.toString());
|
||||
|
||||
return (
|
||||
<div className="post-container">
|
||||
<div className="post-wrapper">
|
||||
<div className="post-main">
|
||||
<div className="post-avatar fl"><img src={issue.author.img_url} width="45" height="45" className="border-radius" /></div>
|
||||
<div className="post-title hidden mb5"><span className="c-grey3 f15 fb">{issue.subject}</span></div>
|
||||
<div className="post-title hidden"><a herf="javascript:void(0);" className="mr10">{issue.author.nickname}</a>项目问题</div>
|
||||
<div className="cl"></div>
|
||||
<div className="post-content c-grey2 mt10">
|
||||
<div className="post-all-content" dangerouslySetInnerHTML={{__html: descMarkup}}></div>
|
||||
</div>
|
||||
<a herf="javascript:void(0);" className="link-blue f13 fl mt5 post-more " style={{textDecoration: 'underline'}}>点击展开</a>
|
||||
<div className="cl"></div>
|
||||
<span onClick={this.testClick} className="c-grey f13 mt10 fl">{issue.created_on}</span>
|
||||
<div className="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
|
||||
return(
|
||||
<div>{issueEach}</div>
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var Route = ReactRouter.Route;
|
||||
var Router = ReactRouter.Router;
|
||||
|
||||
var routes = (
|
||||
<Router>
|
||||
<Route path="/" component={Index}/>
|
||||
<Route path="issue/:id" component={PostContainer} />
|
||||
</Router>
|
||||
);
|
||||
|
||||
React.render(routes, document.getElementById("container"));
|
||||
|
||||
|
||||
*/
|
||||
/**
|
||||
* Created by guange on 16/3/21.
|
||||
*//*
|
||||
|
||||
|
||||
var Index = React.createClass({
|
||||
render: function(){
|
||||
return (<div>index page</div>);
|
||||
}
|
||||
});
|
||||
|
||||
var apiUrl = '/api/v1/';
|
||||
|
||||
var PostContainer = React.createClass({
|
||||
loadDataFromServer: function(){
|
||||
$.ajax({
|
||||
url: apiUrl + 'issues/' + this.props.params.id,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
this.setState({data: data.data});
|
||||
}.bind(this),
|
||||
error: function(xhr,status,err){
|
||||
console.log(err);
|
||||
}.bind(this)
|
||||
})
|
||||
},
|
||||
componentDidMount: function(){
|
||||
this.loadDataFromServer();
|
||||
},
|
||||
getInitialState: function(){
|
||||
return {data: null};
|
||||
},
|
||||
render: function(){
|
||||
return (
|
||||
<PostView data={this.state.data}/>
|
||||
)
|
||||
}
|
||||
});
|
||||
|
||||
var PostView = React.createClass({
|
||||
testClick: function(){
|
||||
console.log("123123");
|
||||
},
|
||||
|
||||
render: function(){
|
||||
if(!this.props.data){
|
||||
return <div></div>
|
||||
}
|
||||
|
||||
|
||||
var issueEach = this.props.data.map(function(issue){
|
||||
|
||||
var descMarkup = converter.makeHtml(issue.description.toString());
|
||||
|
||||
return (
|
||||
<div className="post-container">
|
||||
<div className="post-wrapper">
|
||||
<div className="post-main">
|
||||
<div className="post-avatar fl"><img src={issue.author.img_url} width="45" height="45" className="border-radius" /></div>
|
||||
<div className="post-title hidden mb5"><span className="c-grey3 f15 fb">{issue.subject}</span></div>
|
||||
<div className="post-title hidden"><a herf="javascript:void(0);" className="mr10">{issue.author.nickname}</a>项目问题</div>
|
||||
<div className="cl"></div>
|
||||
<div className="post-content c-grey2 mt10">
|
||||
<div className="post-all-content" dangerouslySetInnerHTML={{__html: descMarkup}}></div>
|
||||
</div>
|
||||
<a herf="javascript:void(0);" className="link-blue f13 fl mt5 post-more " style={{textDecoration: 'underline'}}>点击展开</a>
|
||||
<div className="cl"></div>
|
||||
<span onClick={this.testClick} className="c-grey f13 mt10 fl">{issue.created_on}</span>
|
||||
<div className="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
|
||||
return(
|
||||
<div>{issueEach}</div>
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var Route = ReactRouter.Route;
|
||||
var Router = ReactRouter.Router;
|
||||
|
||||
var routes = (
|
||||
<Router>
|
||||
<Route path="/" component={Index}/>
|
||||
<Route path="issue/:id" component={PostContainer} />
|
||||
</Router>
|
||||
);
|
||||
|
||||
React.render(routes, document.getElementById("container"));
|
||||
|
||||
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue