Merge branch 'develop' into dev_shcool
This commit is contained in:
commit
6a4f239961
|
@ -13,50 +13,55 @@ module Mobile
|
||||||
requires :container_type, type: String
|
requires :container_type, type: String
|
||||||
end
|
end
|
||||||
post do
|
post do
|
||||||
authenticate!
|
begin
|
||||||
|
authenticate!
|
||||||
|
|
||||||
user = current_user
|
user = current_user
|
||||||
|
|
||||||
container_type = params[:container_type] ? params[:container_type] : "All"
|
container_type = params[:container_type] ? params[:container_type] : "All"
|
||||||
|
|
||||||
if container_type == "All" || container_type == "Project"
|
if container_type == "All" || container_type == "Project"
|
||||||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||||
user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")"
|
user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||||
project_types = "('Message','Issue','Project')"
|
project_types = "('Message','Issue','Project')"
|
||||||
|
end
|
||||||
|
|
||||||
|
if container_type == "All" || container_type == "Course"
|
||||||
|
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||||
|
user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||||
|
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||||
|
end
|
||||||
|
|
||||||
|
page = params[:page] ? params[:page] : 0
|
||||||
|
principal_types = "JournalsForMessage"
|
||||||
|
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
|
||||||
|
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
|
||||||
|
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? " " :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
|
||||||
|
blog_ids = "(" + watched_user_blog_ids + ")"
|
||||||
|
|
||||||
|
if container_type == "Course"
|
||||||
|
activities = UserActivity.where("(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc')
|
||||||
|
elsif container_type == "Project"
|
||||||
|
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})").order('updated_at desc')
|
||||||
|
else
|
||||||
|
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')
|
||||||
|
end
|
||||||
|
all_count = activities.count
|
||||||
|
activities = activities.limit(10).offset(page * 10)
|
||||||
|
count = activities.count
|
||||||
|
present :data, activities, with: Mobile::Entities::Activity,user: user
|
||||||
|
present :all_count, all_count
|
||||||
|
present :count, count
|
||||||
|
present :page, page
|
||||||
|
present :status, 0
|
||||||
|
present :container_type, container_type
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
if container_type == "All" || container_type == "Course"
|
|
||||||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
|
||||||
user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
|
|
||||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
|
||||||
end
|
|
||||||
|
|
||||||
page = params[:page] ? params[:page] : 0
|
|
||||||
principal_types = "JournalsForMessage"
|
|
||||||
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
|
|
||||||
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
|
|
||||||
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? " " :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
|
|
||||||
blog_ids = "(" + watched_user_blog_ids + ")"
|
|
||||||
|
|
||||||
if container_type == "Course"
|
|
||||||
activities = UserActivity.where("(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc')
|
|
||||||
elsif container_type == "Project"
|
|
||||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})").order('updated_at desc')
|
|
||||||
else
|
|
||||||
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')
|
|
||||||
end
|
|
||||||
all_count = activities.count
|
|
||||||
activities = activities.limit(10).offset(page * 10)
|
|
||||||
count = activities.count
|
|
||||||
present :data, activities, with: Mobile::Entities::Activity,user: user
|
|
||||||
present :all_count, all_count
|
|
||||||
present :count, count
|
|
||||||
present :page, page
|
|
||||||
present :status, 0
|
|
||||||
present :container_type, container_type
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,17 +7,22 @@ module Mobile
|
||||||
|
|
||||||
desc "get special topic"
|
desc "get special topic"
|
||||||
post ':id' do
|
post ':id' do
|
||||||
user = current_user
|
begin
|
||||||
|
user = current_user
|
||||||
|
|
||||||
#0一级回复的更多 1 二级回复的更多
|
#0一级回复的更多 1 二级回复的更多
|
||||||
type = params[:type] || 0
|
type = params[:type] || 0
|
||||||
page = params[:page] || 0
|
page = params[:page] || 0
|
||||||
|
|
||||||
blog = BlogComment.find params[:id]
|
blog = BlogComment.find params[:id]
|
||||||
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
|
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
|
||||||
present :type, type
|
present :type, type
|
||||||
present :page, page
|
present :page, page
|
||||||
present :status, 0
|
present :status, 0
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,8 +167,20 @@ module Mobile
|
||||||
requires :course_id, type: Integer, desc: "课程id"
|
requires :course_id, type: Integer, desc: "课程id"
|
||||||
end
|
end
|
||||||
get 'teachers' do
|
get 'teachers' do
|
||||||
|
|
||||||
|
course = Course.find(params[:course_id])
|
||||||
|
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
teachers = cs.course_teacher_or_student_list({role: '1'}, params[:course_id],current_user)
|
teachers = cs.course_teacher_or_student_list({role: '1'}, params[:course_id],current_user)
|
||||||
|
|
||||||
|
teachers.each do |m|
|
||||||
|
if m[:id] == course.tea_id
|
||||||
|
teachers.delete(m)
|
||||||
|
teachers.insert(0,m)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
present :data, teachers, with: Mobile::Entities::User
|
present :data, teachers, with: Mobile::Entities::User
|
||||||
present :status, 0
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,17 +8,25 @@ module Mobile
|
||||||
|
|
||||||
desc "get special issuse"
|
desc "get special issuse"
|
||||||
post ':id' do
|
post ':id' do
|
||||||
authenticate!
|
begin
|
||||||
user = current_user
|
# authenticate!
|
||||||
|
user = current_user
|
||||||
|
|
||||||
#0一级回复的更多 1 二级回复的更多
|
#is_public true 公开 false 私有 1公开 0私有
|
||||||
type = params[:type] || 0
|
|
||||||
page = params[:page] || 0
|
#0一级回复的更多 1 二级回复的更多
|
||||||
issue = Issue.find params[:id]
|
type = params[:type] || 0
|
||||||
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
|
page = params[:page] || 0
|
||||||
present :type, type
|
issue = Issue.find params[:id]
|
||||||
present :page, page
|
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
|
||||||
present :status, 0
|
present :type, type
|
||||||
|
present :page, page
|
||||||
|
present :is_public, issue.project.is_public
|
||||||
|
present :status, 0
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,18 +7,33 @@ module Mobile
|
||||||
|
|
||||||
desc "get special journal"
|
desc "get special journal"
|
||||||
post ':id' do
|
post ':id' do
|
||||||
authenticate!
|
begin
|
||||||
user = current_user
|
# authenticate!
|
||||||
|
user = current_user
|
||||||
|
|
||||||
#0一级回复的更多 1 二级回复的更多
|
#0一级回复的更多 1 二级回复的更多
|
||||||
type = params[:type] || 0
|
type = params[:type] || 0
|
||||||
page = params[:page] || 0
|
page = params[:page] || 0
|
||||||
|
|
||||||
jour = JournalsForMessage.find params[:id]
|
jour = JournalsForMessage.find params[:id]
|
||||||
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
|
|
||||||
present :type, type
|
is_public = 1
|
||||||
present :page, page
|
|
||||||
present :status, 0
|
if jour.jour_type == "Project"
|
||||||
|
is_public = jour.project.is_public
|
||||||
|
elsif jour.jour_type == "Course"
|
||||||
|
is_public = jour.course.is_public
|
||||||
|
end
|
||||||
|
|
||||||
|
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
|
||||||
|
present :type, type
|
||||||
|
present :page, page
|
||||||
|
present :is_public, is_public
|
||||||
|
present :status, 0
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,17 +7,36 @@ module Mobile
|
||||||
|
|
||||||
desc "get special topic"
|
desc "get special topic"
|
||||||
post ':id' do
|
post ':id' do
|
||||||
authenticate!
|
begin
|
||||||
user = current_user
|
# authenticate!
|
||||||
|
user = current_user
|
||||||
|
|
||||||
#0一级回复的更多 1 二级回复的更多
|
#0一级回复的更多 1 二级回复的更多
|
||||||
type = params[:type] || 0
|
type = params[:type] || 0
|
||||||
page = params[:page] || 0
|
page = params[:page] || 0
|
||||||
message = Message.find params[:id]
|
message = Message.find params[:id]
|
||||||
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
|
|
||||||
present :type, type
|
is_public = 1
|
||||||
present :page, page
|
type_name = ""
|
||||||
present :status, 0
|
|
||||||
|
if message.project
|
||||||
|
is_public = message.project.is_public
|
||||||
|
type_name = "project"
|
||||||
|
elsif message.course
|
||||||
|
is_public = message.course.is_public
|
||||||
|
type_name = "course"
|
||||||
|
end
|
||||||
|
|
||||||
|
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
|
||||||
|
present :type, type
|
||||||
|
present :page, page
|
||||||
|
present :is_public, is_public
|
||||||
|
present :type_name, type_name
|
||||||
|
present :status, 0
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,69 +11,208 @@ module Mobile
|
||||||
params do
|
params do
|
||||||
requires :type, type: String
|
requires :type, type: String
|
||||||
requires :content, type: String
|
requires :content, type: String
|
||||||
requires :token, type: String
|
|
||||||
end
|
end
|
||||||
post ':id' do
|
post ':id' do
|
||||||
|
unless current_user
|
||||||
|
#如果当前用户不存在 则需要根据微信昵称注册一个帐号
|
||||||
|
openid = session[:wechat_openid]
|
||||||
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
|
us = UsersService.new
|
||||||
|
|
||||||
|
access_token = session[:access_token]
|
||||||
|
refresh_token = session[:refresh_token]
|
||||||
|
|
||||||
|
if access_token.present? && refresh_token.present?
|
||||||
|
begin
|
||||||
|
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||||
|
rescue
|
||||||
|
info = Wechat.api.web_access_token(session[:wechat_code])
|
||||||
|
openid =info["openid"]
|
||||||
|
access_token =info["access_token"]
|
||||||
|
if access_token
|
||||||
|
session[:access_token] = access_token
|
||||||
|
end
|
||||||
|
refresh_token = info["refresh_token"]
|
||||||
|
if refresh_token
|
||||||
|
session[:refresh_token] = refresh_token
|
||||||
|
end
|
||||||
|
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||||
|
end
|
||||||
|
|
||||||
|
access_token = refreshinfo["access_token"]
|
||||||
|
refresh_token = refreshinfo["refresh_token"]
|
||||||
|
session[:access_token] = access_token
|
||||||
|
session[:refresh_token] = refresh_token
|
||||||
|
|
||||||
|
#获取用户信息
|
||||||
|
userinfo = Wechat.api.web_userinfo(access_token,openid)
|
||||||
|
Rails.logger.info "userinfo!!!!!!!!!"
|
||||||
|
Rails.logger.info userinfo
|
||||||
|
name = userinfo["nickname"]
|
||||||
|
else
|
||||||
|
name = openid[0..3]+"***"+openid.last
|
||||||
|
end
|
||||||
|
|
||||||
|
user = us.register ({:login=>openid, :mail=>"#{openid}@163.com",
|
||||||
|
:password=>"12345678", :password_confirmation=>"12345678",
|
||||||
|
:should_confirmation_password => true})
|
||||||
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
|
user.update_attributes(:lastname=>name)
|
||||||
|
#自动激活
|
||||||
|
if Setting.self_registration != '3'
|
||||||
|
user.activate
|
||||||
|
user.last_login_on = Time.now
|
||||||
|
if user.save
|
||||||
|
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
UserWechat.create!(
|
||||||
|
openid: openid,
|
||||||
|
user: user,
|
||||||
|
bindtype: 1
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
authenticate!
|
authenticate!
|
||||||
|
|
||||||
|
subscribe = 0 #默认未关注
|
||||||
|
|
||||||
|
#-------------------获取用户是否关注此公众号-----------------------------
|
||||||
|
openid = session[:wechat_openid]
|
||||||
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
|
user_info = Wechat.api.user(openid)
|
||||||
|
Rails.logger.info "user_info!!!!!!!!!"
|
||||||
|
Rails.logger.info user_info
|
||||||
|
subscribe = user_info["subscribe"]
|
||||||
|
|
||||||
|
status = 0
|
||||||
|
tip = 0 #0班级1项目
|
||||||
type = params[:type]
|
type = params[:type]
|
||||||
result = 1
|
result = 1
|
||||||
if params[:content]!="" && current_user
|
if params[:content]!="" && current_user
|
||||||
case type
|
case type
|
||||||
when "HomeworkCommon"
|
when "HomeworkCommon"
|
||||||
homework_common = HomeworkCommon.find(params[:id])
|
homework_common = HomeworkCommon.find(params[:id])
|
||||||
|
|
||||||
|
#如果是私有的 并且不是成员则不能回复
|
||||||
|
# is_public = homework_common.course.is_public
|
||||||
|
# if is_public == 0 && !current_user.member_of_course?(homework_common.course)
|
||||||
|
# status = -1
|
||||||
|
# tip = 0
|
||||||
|
# else
|
||||||
|
# feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
|
||||||
|
# if (feedback.errors.empty?)
|
||||||
|
# homework_common.update_column(:updated_at, Time.now)
|
||||||
|
# result = 2
|
||||||
|
# end
|
||||||
|
# end
|
||||||
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
|
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
|
||||||
if (feedback.errors.empty?)
|
if (feedback.errors.empty?)
|
||||||
homework_common.update_column(:updated_at, Time.now)
|
homework_common.update_column(:updated_at, Time.now)
|
||||||
result = 2
|
result = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
when "News"
|
when "News"
|
||||||
news = News.find(params[:id])
|
news = News.find(params[:id])
|
||||||
comment = Comment.new
|
|
||||||
comment.comments = params[:content]
|
# if news.project
|
||||||
comment.author = current_user
|
# if news.project.is_public == false && !current_user.member_of?(news.project)
|
||||||
if news.comments << comment
|
# status = -1
|
||||||
result = 2
|
# tip = 1
|
||||||
|
# end
|
||||||
|
# elsif news.course
|
||||||
|
# if news.course.is_public == 0 && !current_user.member_of_course?(news.course)
|
||||||
|
# status = -1
|
||||||
|
# tip = 0
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
if status == 0
|
||||||
|
comment = Comment.new
|
||||||
|
comment.comments = params[:content]
|
||||||
|
comment.author = current_user
|
||||||
|
if news.comments << comment
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when "Message"
|
when "Message"
|
||||||
message = Message.find(params[:id])
|
message = Message.find(params[:id])
|
||||||
board = Board.find(message.board_id)
|
board = Board.find(message.board_id)
|
||||||
topic = message.root
|
|
||||||
reply = Message.new
|
# if message.project
|
||||||
reply.author = current_user
|
# if message.project.is_public == false && !current_user.member_of?(message.project)
|
||||||
reply.board = board
|
# status = -1
|
||||||
reply.content = params[:content]
|
# tip = 1
|
||||||
reply.parent_id = params[:id]
|
# end
|
||||||
reply.subject = "RE: #{topic.subject}"
|
# elsif message.course
|
||||||
if topic.children << reply
|
# if message.course.is_public == 0 && !current_user.member_of_course?(message.course)
|
||||||
result = 2
|
# status = -1
|
||||||
|
# tip = 0
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
if status == 0
|
||||||
|
topic = message.root
|
||||||
|
reply = Message.new
|
||||||
|
reply.author = current_user
|
||||||
|
reply.board = board
|
||||||
|
reply.content = params[:content]
|
||||||
|
reply.parent_id = params[:id]
|
||||||
|
reply.subject = "RE: #{topic.subject}"
|
||||||
|
if topic.children << reply
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when "JournalsForMessage"
|
when "JournalsForMessage"
|
||||||
jour = JournalsForMessage.find params[:id]
|
jour = JournalsForMessage.find params[:id]
|
||||||
parent_id = params[:id]
|
|
||||||
author_id = current_user.id
|
# if jour.jour_type == "Project"
|
||||||
reply_user_id = jour.user_id
|
# if jour.project.is_public == false && !current_user.member_of?(jour.project)
|
||||||
reply_id = params[:id]
|
# status = -1
|
||||||
content = params[:content]
|
# tip = 1
|
||||||
options = {:user_id => author_id,
|
# end
|
||||||
:status => true,
|
# elsif jour.jour_type == "Course"
|
||||||
:m_parent_id => parent_id,
|
# if jour.course.is_public == 0 && !current_user.member_of_course?(jour.course)
|
||||||
:m_reply_id => reply_id,
|
# status = -1
|
||||||
:reply_id => reply_user_id,
|
# tip = 0
|
||||||
:notes => content,
|
# end
|
||||||
:is_readed => false}
|
# end
|
||||||
jfm = jour.user.add_jour(nil, nil, nil, options)
|
|
||||||
if jfm.errors.empty?
|
if status == 0
|
||||||
(JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now)
|
parent_id = params[:id]
|
||||||
result = 2
|
author_id = current_user.id
|
||||||
|
reply_user_id = jour.user_id
|
||||||
|
reply_id = params[:id]
|
||||||
|
content = params[:content]
|
||||||
|
options = {:user_id => author_id,
|
||||||
|
:status => true,
|
||||||
|
:m_parent_id => parent_id,
|
||||||
|
:m_reply_id => reply_id,
|
||||||
|
:reply_id => reply_user_id,
|
||||||
|
:notes => content,
|
||||||
|
:is_readed => false}
|
||||||
|
jfm = jour.user.add_jour(nil, nil, nil, options)
|
||||||
|
if jfm.errors.empty?
|
||||||
|
(JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now)
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when 'Issue'
|
when 'Issue'
|
||||||
issue = Issue.find params[:id]
|
issue = Issue.find params[:id]
|
||||||
is_jour = Journal.new
|
|
||||||
is_jour.user_id = current_user.id
|
# if issue.project.is_public == false && !current_user.member_of?(issue.project)
|
||||||
is_jour.notes = params[:content]
|
# status = -1
|
||||||
is_jour.journalized = issue
|
# tip = 1
|
||||||
if is_jour.save
|
# end
|
||||||
result = 2
|
|
||||||
|
if status == 0
|
||||||
|
is_jour = Journal.new
|
||||||
|
is_jour.user_id = current_user.id
|
||||||
|
is_jour.notes = params[:content]
|
||||||
|
is_jour.journalized = issue
|
||||||
|
if is_jour.save
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when 'BlogComment'
|
when 'BlogComment'
|
||||||
blog = BlogComment.find(params[:id]).root
|
blog = BlogComment.find(params[:id]).root
|
||||||
|
@ -97,7 +236,9 @@ module Mobile
|
||||||
result = 3
|
result = 3
|
||||||
end
|
end
|
||||||
present :result, result
|
present :result, result
|
||||||
present :status, 0
|
present :status, status
|
||||||
|
present :tip, tip
|
||||||
|
present :subscribe,subscribe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,17 +7,32 @@ module Mobile
|
||||||
|
|
||||||
desc "get special news"
|
desc "get special news"
|
||||||
post ':id' do
|
post ':id' do
|
||||||
authenticate!
|
begin
|
||||||
user = current_user
|
# authenticate!
|
||||||
|
user = current_user
|
||||||
|
|
||||||
#0一级回复的更多 1 二级回复的更多
|
#0一级回复的更多 1 二级回复的更多
|
||||||
type = params[:type] || 0
|
type = params[:type] || 0
|
||||||
page = params[:page] || 0
|
page = params[:page] || 0
|
||||||
news = News.find params[:id]
|
news = News.find params[:id]
|
||||||
present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
|
|
||||||
present :type, type
|
is_public = 1
|
||||||
present :page, page
|
|
||||||
present :status, 0
|
if news.project
|
||||||
|
is_public = news.project.is_public
|
||||||
|
elsif news.course
|
||||||
|
is_public = news.course.is_public
|
||||||
|
end
|
||||||
|
|
||||||
|
present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
|
||||||
|
present :type, type
|
||||||
|
present :page, page
|
||||||
|
present :is_public, is_public
|
||||||
|
present :status, 0
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,9 +28,10 @@ module Mobile
|
||||||
ss = SyllabusesService.new
|
ss = SyllabusesService.new
|
||||||
|
|
||||||
sy = ::Syllabus.find(params[:id])
|
sy = ::Syllabus.find(params[:id])
|
||||||
sy.courses = sy.courses.not_deleted
|
|
||||||
|
|
||||||
present :data, sy, with: Mobile::Entities::Syllabus,user: current_user
|
result = {:title=>sy.title, :id=>sy.id , :user_id=>sy.user_id,:courses=>sy.courses.not_deleted}
|
||||||
|
|
||||||
|
present :data, result, with: Mobile::Entities::Syllabus,user: current_user
|
||||||
present :status, 0
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Mobile
|
||||||
logger.debug "openid ============== #{openid}"
|
logger.debug "openid ============== #{openid}"
|
||||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw
|
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw && uw.real?
|
||||||
|
|
||||||
user, last_login_on = User.try_to_login(params[:login], params[:password])
|
user, last_login_on = User.try_to_login(params[:login], params[:password])
|
||||||
raise "用户名或密码错误,请重新输入" unless user
|
raise "用户名或密码错误,请重新输入" unless user
|
||||||
|
@ -37,12 +37,17 @@ module Mobile
|
||||||
|
|
||||||
raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat
|
raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat
|
||||||
|
|
||||||
UserWechat.create!(
|
if uw && !uw.real?
|
||||||
|
uw.migrate_user(user)
|
||||||
|
else
|
||||||
|
UserWechat.create!(
|
||||||
openid: openid,
|
openid: openid,
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.login, Time.now.strftime("%Y-%m-%d"))
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d"))
|
||||||
present status: 0, message: '您已成功绑定Trustie平台'
|
present status: 0, message: '您已成功绑定Trustie平台'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,22 +58,38 @@ module Mobile
|
||||||
requires :password, type: String, desc: 'password'
|
requires :password, type: String, desc: 'password'
|
||||||
end
|
end
|
||||||
post do
|
post do
|
||||||
|
|
||||||
openid = session[:wechat_openid]
|
openid = session[:wechat_openid]
|
||||||
logger.debug "openid ============== #{openid}"
|
logger.debug "openid ============== #{openid}"
|
||||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
|
|
||||||
|
uw = UserWechat.where(openid: openid).first
|
||||||
|
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw && uw.real?
|
||||||
us = UsersService.new
|
us = UsersService.new
|
||||||
user = us.register params.merge(:password_confirmation => params[:password],
|
user = us.register params.merge(:password_confirmation => params[:password],
|
||||||
:should_confirmation_password => true)
|
:should_confirmation_password => true)
|
||||||
raise user.errors.full_messages.first if user.new_record?
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
UserWechat.create!(
|
#自动激活
|
||||||
|
if Setting.self_registration != '3'
|
||||||
|
# user = automatically_register(user)
|
||||||
|
user.activate
|
||||||
|
user.last_login_on = Time.now
|
||||||
|
if user.save
|
||||||
|
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if uw && !uw.real?
|
||||||
|
user.update_attributes(:lastname=>uw.user[:lastname])
|
||||||
|
uw.migrate_user(user)
|
||||||
|
else
|
||||||
|
UserWechat.create!(
|
||||||
openid: openid,
|
openid: openid,
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.login, Time.now.strftime("%Y-%m-%d"))
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d"))
|
||||||
present :data, user, with: Mobile::Entities::User
|
present :data, user, with: Mobile::Entities::User
|
||||||
present :status, 0
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,23 +7,32 @@ module Mobile
|
||||||
|
|
||||||
desc "get one homework"
|
desc "get one homework"
|
||||||
post ':id' do
|
post ':id' do
|
||||||
authenticate!
|
begin
|
||||||
user = current_user
|
# authenticate!
|
||||||
|
user = current_user
|
||||||
|
|
||||||
#0一级回复的更多 1 二级回复的更多
|
#0一级回复的更多 1 二级回复的更多
|
||||||
type = params[:type] || 0
|
type = params[:type] || 0
|
||||||
page = params[:page] || 0
|
page = params[:page] || 0
|
||||||
|
|
||||||
if type == 0
|
is_public = 1
|
||||||
homework = HomeworkCommon.find params[:id]
|
|
||||||
present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework"
|
if type == 0
|
||||||
else
|
homework = HomeworkCommon.find params[:id]
|
||||||
jour = JournalsForMessage.find params[:id]
|
is_public = homework.course.is_public
|
||||||
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page,comment_type: "homework"
|
present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework"
|
||||||
|
else
|
||||||
|
jour = JournalsForMessage.find params[:id]
|
||||||
|
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page,comment_type: "homework"
|
||||||
|
end
|
||||||
|
present :type, type
|
||||||
|
present :page, page
|
||||||
|
present :is_public, is_public
|
||||||
|
present :status, 0
|
||||||
|
rescue Exception=>e
|
||||||
|
present :status, -1
|
||||||
|
present :message, e.message
|
||||||
end
|
end
|
||||||
present :type, type
|
|
||||||
present :page, page
|
|
||||||
present :status, 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,9 +65,9 @@ module Mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
|
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
|
||||||
roleName = member.roles[0].name if member
|
role_ids = member.role_ids if member
|
||||||
|
|
||||||
if roleName && (roleName == "TeachingAsistant" || roleName == "Teacher" )
|
if role_ids && (role_ids.include?(7) || role_ids.include?(9) )
|
||||||
can_setting = true
|
can_setting = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,6 +76,15 @@ module Mobile
|
||||||
end
|
end
|
||||||
can_setting
|
can_setting
|
||||||
end
|
end
|
||||||
|
expose :is_member, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
|
current_user = options[:user]
|
||||||
|
if instance[:course]
|
||||||
|
course = instance[:course]
|
||||||
|
else
|
||||||
|
course = instance
|
||||||
|
end
|
||||||
|
current_user.member_of_course?(course)
|
||||||
|
end
|
||||||
expose :teacher, using: Mobile::Entities::User do |c, opt|
|
expose :teacher, using: Mobile::Entities::User do |c, opt|
|
||||||
if c.is_a? ::Course
|
if c.is_a? ::Course
|
||||||
c.teacher
|
c.teacher
|
||||||
|
|
|
@ -23,6 +23,16 @@ module Mobile
|
||||||
current_user.id == instance.user_id
|
current_user.id == instance.user_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expose :is_member, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
|
current_user = options[:user]
|
||||||
|
if instance[:project]
|
||||||
|
project = instance[:project]
|
||||||
|
else
|
||||||
|
project = instance
|
||||||
|
end
|
||||||
|
current_user.member_of?(project)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
expose :member_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
expose :member_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
instance.members.count
|
instance.members.count
|
||||||
|
|
|
@ -5,8 +5,8 @@ module Mobile
|
||||||
expose :id
|
expose :id
|
||||||
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
|
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
current_user = options[:user]
|
current_user = options[:user]
|
||||||
can_setting = instance.user_id == current_user.id ? true : false
|
can_setting = instance[:user_id] == current_user.id ? true : false
|
||||||
can_setting = false if instance.id.nil?
|
can_setting = false if instance[:id].nil?
|
||||||
can_setting
|
can_setting
|
||||||
end
|
end
|
||||||
expose :courses, using: Mobile::Entities::Course
|
expose :courses, using: Mobile::Entities::Course
|
||||||
|
|
|
@ -61,7 +61,7 @@ class AdminController < ApplicationController
|
||||||
if params[:syllabus_id] && params[:course_id]
|
if params[:syllabus_id] && params[:course_id]
|
||||||
course = Course.where("id = #{params[:course_id].to_i}").first
|
course = Course.where("id = #{params[:course_id].to_i}").first
|
||||||
unless course.nil?
|
unless course.nil?
|
||||||
course.update_column('syllabus_id', params[:syllabus_id].to_i)
|
course.update_attribute(:syllabus_id, params[:syllabus_id].to_i)
|
||||||
@flag = true
|
@flag = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -82,7 +82,7 @@ class AdminController < ApplicationController
|
||||||
syllabus.update_attributes(:title => params[:title], :eng_name => params[:eng_name], :user_id => @user.id)
|
syllabus.update_attributes(:title => params[:title], :eng_name => params[:eng_name], :user_id => @user.id)
|
||||||
syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content
|
syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content
|
||||||
if syllabus.save
|
if syllabus.save
|
||||||
course.update_column('syllabus_id', syllabus.id)
|
course.update_attribute(:syllabus_id, params[:syllabus_id].to_i)
|
||||||
@flag = params[:flag].to_i
|
@flag = params[:flag].to_i
|
||||||
@course = course
|
@course = course
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class AppliedProjectController < ApplicationController
|
||||||
else
|
else
|
||||||
@project = Project.find(params[:project_id])
|
@project = Project.find(params[:project_id])
|
||||||
end
|
end
|
||||||
if !@project || params[:invite_code].upcase.to_s != @project.invite_code
|
if !@project || params[:invite_code].strip.upcase.to_s != @project.invite_code
|
||||||
@flag = 1
|
@flag = 1
|
||||||
elsif User.current.member_of?(@project)
|
elsif User.current.member_of?(@project)
|
||||||
@flag = 2
|
@flag = 2
|
||||||
|
@ -75,6 +75,8 @@ class AppliedProjectController < ApplicationController
|
||||||
@project.project_infos << project_info
|
@project.project_infos << project_info
|
||||||
@project.user_grades << user_grades unless user_grades.first.user_id.nil?
|
@project.user_grades << user_grades unless user_grades.first.user_id.nil?
|
||||||
|
|
||||||
|
ps = ProjectsService.new
|
||||||
|
ps.send_wechat_join_project_notice User.current,@project,5,0
|
||||||
else
|
else
|
||||||
@flag = 4
|
@flag = 4
|
||||||
role = params[:member] == "member_manager" ? 3 : (params[:member] == "member_developer" ? 4 :5)
|
role = params[:member] == "member_manager" ? 3 : (params[:member] == "member_developer" ? 4 :5)
|
||||||
|
|
|
@ -10,7 +10,7 @@ class AtController < ApplicationController
|
||||||
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
|
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
|
||||||
|
|
||||||
#加上all
|
#加上all
|
||||||
if @user && @users.size > 0
|
if User.current.logged? && @users.size > 0
|
||||||
allUser = Struct.new(:id, :name).new
|
allUser = Struct.new(:id, :name).new
|
||||||
allUser.id = @users.map{|u| u.id}.join(",")
|
allUser.id = @users.map{|u| u.id}.join(",")
|
||||||
allUser.name = "all"
|
allUser.name = "all"
|
||||||
|
|
|
@ -77,19 +77,25 @@ class FilesController < ApplicationController
|
||||||
if params[:insite]
|
if params[:insite]
|
||||||
if q == "%%"
|
if q == "%%"
|
||||||
@result = []
|
@result = []
|
||||||
@searched_attach = paginateHelper @result,10
|
# @searched_attach = paginateHelper @result,10
|
||||||
else
|
else
|
||||||
@result = find_public_attache q,sort
|
@result = find_public_attache q,sort
|
||||||
@result = visable_attachemnts_insite @result,@course
|
@result = visable_attachemnts_insite @result,@course
|
||||||
@searched_attach = paginateHelper @result,10
|
# @searched_attach = paginateHelper @result,10
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@result = find_course_attache q,@course,sort
|
@result = find_course_attache q,@course,sort
|
||||||
@result = visable_attachemnts @result
|
@result = visable_attachemnts @result
|
||||||
@searched_attach = paginateHelper @result,10
|
# @searched_attach = paginateHelper @result,10
|
||||||
|
|
||||||
@tag_list = get_course_tag_list @course
|
@tag_list = get_course_tag_list @course
|
||||||
end
|
end
|
||||||
|
@all_attachments = @result
|
||||||
|
@limit = 10
|
||||||
|
@feedback_count = @all_attachments.count
|
||||||
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||||
|
@offset ||= @feedback_pages.offset
|
||||||
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||||
|
@obj_attachments = paginateHelper @all_attachments,10
|
||||||
#rescue Exception => e
|
#rescue Exception => e
|
||||||
# #render 'stores'
|
# #render 'stores'
|
||||||
# redirect_to search_course_files_url
|
# redirect_to search_course_files_url
|
||||||
|
@ -144,18 +150,26 @@ class FilesController < ApplicationController
|
||||||
if params[:insite]
|
if params[:insite]
|
||||||
if q == "%%"
|
if q == "%%"
|
||||||
@project_attachment_result = []
|
@project_attachment_result = []
|
||||||
@searched_attach = paginateHelper @project_attachment_result, 10
|
# @searched_attach = paginateHelper @project_attachment_result, 10
|
||||||
else
|
else
|
||||||
@project_attachment_result = find_public_attache q,sort
|
@project_attachment_result = find_public_attache q,sort
|
||||||
@project_attachment_result = visable_attachemnts_insite @project_attachment_result, @project
|
@project_attachment_result = visable_attachemnts_insite @project_attachment_result, @project
|
||||||
@searched_attach = paginateHelper @project_attachment_result, 10
|
# @searched_attach = paginateHelper @project_attachment_result, 10
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@project_attachment_result = find_project_attache q, @project,sort
|
@project_attachment_result = find_project_attache q, @project,sort
|
||||||
@project_attachment_result = visable_attachemnts @project_attachment_result
|
@project_attachment_result = visable_attachemnts @project_attachment_result
|
||||||
@searched_attach = paginateHelper @project_attachment_result,10
|
# @searched_attach = paginateHelper @project_attachment_result,10
|
||||||
@tag_list = get_project_tag_list @project
|
@tag_list = get_project_tag_list @project
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@all_attachments = @project_attachment_result
|
||||||
|
@limit = 10
|
||||||
|
@feedback_count = @all_attachments.count
|
||||||
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||||
|
@offset ||= @feedback_pages.offset
|
||||||
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||||
|
@obj_attachments = paginateHelper @all_attachments,10
|
||||||
#rescue Exception => e
|
#rescue Exception => e
|
||||||
# #render 'stores'
|
# #render 'stores'
|
||||||
# redirect_to search_course_files_url
|
# redirect_to search_course_files_url
|
||||||
|
@ -867,7 +881,17 @@ class FilesController < ApplicationController
|
||||||
else
|
else
|
||||||
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
|
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
|
||||||
end
|
end
|
||||||
@searched_attach = paginateHelper @result,10
|
|
||||||
|
@all_attachments = @result
|
||||||
|
@limit = 10
|
||||||
|
@feedback_count = @all_attachments.count
|
||||||
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||||
|
@offset ||= @feedback_pages.offset
|
||||||
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||||
|
@obj_attachments = paginateHelper @all_attachments,10
|
||||||
|
|
||||||
|
|
||||||
|
# @searched_attach = paginateHelper @result,10
|
||||||
if @project
|
if @project
|
||||||
@tag_list = get_project_tag_list @project
|
@tag_list = get_project_tag_list @project
|
||||||
@result_search_project = @result
|
@result_search_project = @result
|
||||||
|
|
|
@ -84,7 +84,8 @@ class MembersController < ApplicationController
|
||||||
# 添加成功后,申请人收到消息
|
# 添加成功后,申请人收到消息
|
||||||
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
|
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
|
||||||
:status => 6, :viewed => false, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
:status => 6, :viewed => false, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
||||||
|
ps = ProjectsService.new
|
||||||
|
ps.send_wechat_join_project_notice user,project,ap_role,0
|
||||||
# 添加成功后,批准人收到消息
|
# 添加成功后,批准人收到消息
|
||||||
# AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
|
# AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
|
||||||
# :status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
# :status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
||||||
|
@ -114,6 +115,11 @@ class MembersController < ApplicationController
|
||||||
@applied_message = AppliedMessage.find(params[:applied_message_id])
|
@applied_message = AppliedMessage.find(params[:applied_message_id])
|
||||||
# AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5,
|
# AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5,
|
||||||
# :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
# :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
||||||
|
ps = ProjectsService.new
|
||||||
|
user = User.find(@applied_message.applied_user_id)
|
||||||
|
ap_role = applied_project.try(:role)
|
||||||
|
ps.send_wechat_join_project_notice user,project,ap_role,1
|
||||||
|
|
||||||
applied_project.delete
|
applied_project.delete
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
class PullRequestsController < ApplicationController
|
class PullRequestsController < ApplicationController
|
||||||
before_filter :find_project_and_repository
|
before_filter :find_project_and_repository
|
||||||
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new]
|
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new,
|
||||||
|
:update_pull_request, :pull_request_comments, :create_pull_request_comment]
|
||||||
layout "base_projects"
|
layout "base_projects"
|
||||||
include PullRequestsHelper
|
include PullRequestsHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
@ -14,9 +15,19 @@ class PullRequestsController < ApplicationController
|
||||||
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"}
|
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"}
|
||||||
when "2"
|
when "2"
|
||||||
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}
|
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}
|
||||||
|
when "3"
|
||||||
|
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}
|
||||||
end
|
end
|
||||||
@requests_opened_count = @requests.count
|
@requests_opened_count = @requests.count
|
||||||
@requests_merged_count = params[:type] ? @requests.count : @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
|
@requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
|
||||||
|
@requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count
|
||||||
|
|
||||||
|
@limit = 10
|
||||||
|
@is_remote = true
|
||||||
|
@count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count)
|
||||||
|
@pages = Paginator.new @count, @limit, params['page'] || 1
|
||||||
|
@offset ||= @pages.offset
|
||||||
|
@requests = paginateHelper @requests, 10
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js
|
format.js
|
||||||
|
@ -84,6 +95,15 @@ class PullRequestsController < ApplicationController
|
||||||
@commits_count = @commits.count
|
@commits_count = @commits.count
|
||||||
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
|
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
|
||||||
@changes_count = @changes.count
|
@changes_count = @changes.count
|
||||||
|
@comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse
|
||||||
|
@comments_count = @comments.count
|
||||||
|
|
||||||
|
@limit = 10
|
||||||
|
@is_remote = true
|
||||||
|
@count = @comments_count
|
||||||
|
@pages = Paginator.new @count, @limit, params['page'] || 1
|
||||||
|
@offset ||= @pages.offset
|
||||||
|
@comments = paginateHelper @comments, 10
|
||||||
end
|
end
|
||||||
|
|
||||||
# Accept a merge request.
|
# Accept a merge request.
|
||||||
|
@ -99,6 +119,7 @@ class PullRequestsController < ApplicationController
|
||||||
def accept_pull_request
|
def accept_pull_request
|
||||||
begin
|
begin
|
||||||
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
|
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
|
||||||
|
PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
|
||||||
end
|
end
|
||||||
|
@ -107,16 +128,110 @@ class PullRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取某次请求的提交次数
|
# Updates a merge request.
|
||||||
def pull_request_commits
|
#
|
||||||
@type = parms[:type]
|
# @example
|
||||||
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
|
# Gitlab.update_merge_request(5, 42, :title => 'New title')
|
||||||
|
#
|
||||||
|
# @param [Integer] project The ID of a project.
|
||||||
|
# @param [Integer] id The ID of a merge request.
|
||||||
|
# @param [Hash] options A customizable set of options.
|
||||||
|
# @option options [String] :title The title of a merge request.
|
||||||
|
# @option options [String] :source_branch The source branch name.
|
||||||
|
# @option options [String] :target_branch The target branch name.
|
||||||
|
# @option options [Integer] :assignee_id The ID of a user to assign merge request.
|
||||||
|
# @option options [String] :state_event New state (close|reopen|merge).
|
||||||
|
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
|
||||||
|
def update_pull_request
|
||||||
|
begin
|
||||||
|
@g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)}
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
@message = e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取某次请求的改动
|
# Creates a merge request.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# Gitlab.create_merge_request(5, 'New merge request',
|
||||||
|
# :source_branch => 'source_branch', :target_branch => 'target_branch')
|
||||||
|
# Gitlab.create_merge_request(5, 'New merge request',
|
||||||
|
# :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42)
|
||||||
|
def create_pull_request_comment
|
||||||
|
content = params[:pull_request_comment]
|
||||||
|
begin
|
||||||
|
@comments = @g.create_merge_request_comment(@project.gpid, params[:id], content, User.current.gid)
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)}
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
@message = e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Gets the comments on a merge request.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# Gitlab.merge_request_comments(5, 1)
|
||||||
|
def pull_request_comments
|
||||||
|
begin
|
||||||
|
@comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse
|
||||||
|
@comments_count = @comments.count
|
||||||
|
|
||||||
|
@limit = 10
|
||||||
|
@is_remote = true
|
||||||
|
@count = @comments_count
|
||||||
|
@pages = Paginator.new @count, @limit, params['page'] || 1
|
||||||
|
@offset ||= @pages.offset
|
||||||
|
@comments = paginateHelper @comments, 10
|
||||||
|
rescue Exception => e
|
||||||
|
@message = e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get a list of merge request commits.
|
||||||
|
# Parameters:
|
||||||
|
# id (required) - The ID of a project
|
||||||
|
# merge_request_id (required) - The ID of MR
|
||||||
|
def pull_request_commits
|
||||||
|
begin
|
||||||
|
@type = params[:type]
|
||||||
|
@commits = @g.merge_request_commits(@project.gpid, params[:id])
|
||||||
|
@commits_count = @commits.count
|
||||||
|
|
||||||
|
@limit = 10
|
||||||
|
@is_remote = true
|
||||||
|
@count = @commits_count
|
||||||
|
@pages = Paginator.new @count, @limit, params['page'] || 1
|
||||||
|
@offset ||= @pages.offset
|
||||||
|
@commits = paginateHelper @commits, 10
|
||||||
|
rescue Exception => e
|
||||||
|
@message = e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Shows information about the merge request including its files and changes. With GitLab 8.2 the return fields upvotes and downvotes are deprecated and always return 0.
|
||||||
|
# Parameters:
|
||||||
|
# id (required) - The ID of a project
|
||||||
|
# merge_request_id (required) - The ID of MR
|
||||||
def pull_request_changes
|
def pull_request_changes
|
||||||
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
|
begin
|
||||||
@changes_count = @changes.count
|
@type = params[:type]
|
||||||
|
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
|
||||||
|
@changes_count = @changes.count
|
||||||
|
|
||||||
|
@limit = 10
|
||||||
|
@is_remote = true
|
||||||
|
@count = @changes_count
|
||||||
|
@pages = Paginator.new @count, @limit, params['page'] || 1
|
||||||
|
@offset ||= @pages.offset
|
||||||
|
@changes = paginateHelper @changes, 10
|
||||||
|
rescue Exception => e
|
||||||
|
@message = e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -17,6 +17,7 @@ class QualityAnalysisController < ApplicationController
|
||||||
|
|
||||||
# params 说明:{identifier:版本库名}
|
# params 说明:{identifier:版本库名}
|
||||||
def create
|
def create
|
||||||
|
logger.info("11111111111111111111111111111")
|
||||||
begin
|
begin
|
||||||
user_name = User.find(params[:user_id]).try(:login)
|
user_name = User.find(params[:user_id]).try(:login)
|
||||||
identifier = params[:identifier]
|
identifier = params[:identifier]
|
||||||
|
@ -32,12 +33,13 @@ class QualityAnalysisController < ApplicationController
|
||||||
projects_date = open(@sonar_address + "/api/projects/index").read
|
projects_date = open(@sonar_address + "/api/projects/index").read
|
||||||
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
|
||||||
quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first
|
quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first
|
||||||
if @client.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
|
if @client_jenkins.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
|
||||||
aa = @client.job.delete("#{job_name}")
|
aa = @client_jenkins.job.delete("#{job_name}")
|
||||||
quality_an.delete unless quality_an.blank?
|
quality_an.delete unless quality_an.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if the given job exists in Jenkins.
|
# Checks if the given job exists in Jenkins.
|
||||||
# unless @client.job.exists?(job_name)
|
unless @client_jenkins.job.exists?(job_name)
|
||||||
@g = Gitlab.client
|
@g = Gitlab.client
|
||||||
branch = params[:branch]
|
branch = params[:branch]
|
||||||
language = swith_language_type(params[:language])
|
language = swith_language_type(params[:language])
|
||||||
|
@ -59,20 +61,20 @@ class QualityAnalysisController < ApplicationController
|
||||||
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
||||||
|
|
||||||
# jenkins job创建
|
# jenkins job创建
|
||||||
jenkins_job = @client.job.create("#{job_name}", @doc.to_xml)
|
jenkins_job = @client_jenkins.job.create("#{job_name}", @doc.to_xml)
|
||||||
logger.info("Jenkins status of create ==> #{jenkins_job}")
|
logger.info("Jenkins status of create ==> #{jenkins_job}")
|
||||||
|
|
||||||
# 将地址作为hook值添加到gitlab
|
# 将地址作为hook值添加到gitlab
|
||||||
@g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}")
|
@g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}")
|
||||||
# job创建完成后自动运行job,如果运行成功则返回‘200’
|
# job创建完成后自动运行job,如果运行成功则返回‘200’
|
||||||
code = @client.job.build("#{job_name}")
|
code = @client_jenkins.job.build("#{job_name}")
|
||||||
logger.error("build result ==> #{code}")
|
logger.error("build result ==> #{code}")
|
||||||
|
|
||||||
# 判断调用sonar分析是否成功
|
# 判断调用sonar分析是否成功
|
||||||
# 等待启动时间处理, 最长时间为30分钟
|
# 等待启动时间处理, 最长时间为30分钟
|
||||||
for i in 0..360 do
|
for i in 0..360 do
|
||||||
sleep(5)
|
sleep(5)
|
||||||
@current_build_status = @client.job.get_current_build_status("#{job_name}")
|
@current_build_status = @client_jenkins.job.get_current_build_status("#{job_name}")
|
||||||
if (@current_build_status == "success" || @current_build_status == "failure")
|
if (@current_build_status == "success" || @current_build_status == "failure")
|
||||||
break
|
break
|
||||||
if i == 360
|
if i == 360
|
||||||
|
@ -86,7 +88,7 @@ class QualityAnalysisController < ApplicationController
|
||||||
sleep(10)
|
sleep(10)
|
||||||
|
|
||||||
# 获取sonar output结果
|
# 获取sonar output结果
|
||||||
console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"]
|
console_build = @client_jenkins.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"]
|
||||||
logger.info("@current_build_status is ==> #{@current_build_status}")
|
logger.info("@current_build_status is ==> #{@current_build_status}")
|
||||||
|
|
||||||
# 两种情况需要删除job:
|
# 两种情况需要删除job:
|
||||||
|
@ -94,14 +96,14 @@ class QualityAnalysisController < ApplicationController
|
||||||
# 2/creat和build成功,调用sonar启动失败则删除job
|
# 2/creat和build成功,调用sonar启动失败则删除job
|
||||||
# 错误信息存储需存到Trustie数据库,否则一旦job删除则无法获取这些信息
|
# 错误信息存储需存到Trustie数据库,否则一旦job删除则无法获取这些信息
|
||||||
if jenkins_job == '200' && code != '201'
|
if jenkins_job == '200' && code != '201'
|
||||||
@client.job.delete("#{job_name}")
|
@client_jenkins.job.delete("#{job_name}")
|
||||||
else
|
else
|
||||||
if @current_build_status == "failure"
|
if @current_build_status == "failure"
|
||||||
reg_console = /Exception:.*?\r/.match(console_build)
|
reg_console = /Exception:.*?\r/.match(console_build)
|
||||||
output = reg_console[0].gsub("\r", "") unless reg_console.nil?
|
output = reg_console[0].gsub("\r", "") unless reg_console.nil?
|
||||||
se = SonarError.where(:jenkins_job_name => job_name).first
|
se = SonarError.where(:jenkins_job_name => job_name).first
|
||||||
se.nil? ? SonarError.create(:project_id => @project.id, :jenkins_job_name => job_name, :output => output) : se.update_column(:output, output)
|
se.nil? ? SonarError.create(:project_id => @project.id, :jenkins_job_name => job_name, :output => output) : se.update_column(:output, output)
|
||||||
@client.job.delete("#{job_name}")
|
@client_jenkins.job.delete("#{job_name}")
|
||||||
elsif @current_build_status == "success"
|
elsif @current_build_status == "success"
|
||||||
if quality_an.blank?
|
if quality_an.blank?
|
||||||
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
|
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
|
||||||
|
@ -111,17 +113,24 @@ class QualityAnalysisController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# end
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @current_build_status == "success"
|
||||||
|
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
|
||||||
|
elsif @current_build_status == "failure"
|
||||||
|
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
@message = e.message
|
@message = e.message
|
||||||
end
|
logger.error("######################====>#{e.message}")
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @current_build_status == "success"
|
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name, :message => @message)}
|
||||||
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
|
# format.html{redirect_to :controller => 'repositories', :action => 'show', :id => @project, :repository_id => identifier}
|
||||||
elsif @current_build_status == "failure"
|
|
||||||
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name)}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_list
|
def error_list
|
||||||
|
@ -159,9 +168,9 @@ class QualityAnalysisController < ApplicationController
|
||||||
rep_id = Repository.where(:project_id => @project.id, :identifier => qa.rep_identifier).first.try(:id)
|
rep_id = Repository.where(:project_id => @project.id, :identifier => qa.rep_identifier).first.try(:id)
|
||||||
job_name = "#{qa.author_login}-#{rep_id}"
|
job_name = "#{qa.author_login}-#{rep_id}"
|
||||||
logger.info("result: job_name ###################==>#{job_name}")
|
logger.info("result: job_name ###################==>#{job_name}")
|
||||||
logger.info("result: @client.job ###################==>#{@client.job}")
|
logger.info("result: @client_jenkins.job ###################==>#{@client_jenkins.job}")
|
||||||
|
|
||||||
d_job = @client.job.delete(job_name)
|
d_job = @client_jenkins.job.delete(job_name)
|
||||||
logger.info("result: delete job ###################==>#{d_job}")
|
logger.info("result: delete job ###################==>#{d_job}")
|
||||||
qa.delete
|
qa.delete
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -198,7 +207,7 @@ class QualityAnalysisController < ApplicationController
|
||||||
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
|
||||||
|
|
||||||
# update成功则返回 ‘200’
|
# update成功则返回 ‘200’
|
||||||
jenkins_job = @client.job.update("#{job_name}", @doc.to_xml)
|
jenkins_job = @client_jenkins.job.update("#{job_name}", @doc.to_xml)
|
||||||
# 数据更新到Trustie数据
|
# 数据更新到Trustie数据
|
||||||
if jenkins_job == '200'
|
if jenkins_job == '200'
|
||||||
logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}")
|
logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}")
|
||||||
|
@ -278,9 +287,10 @@ class QualityAnalysisController < ApplicationController
|
||||||
@jenkins_address = Redmine::Configuration['jenkins_address']
|
@jenkins_address = Redmine::Configuration['jenkins_address']
|
||||||
jenkins_username = Redmine::Configuration['jenkins_username']
|
jenkins_username = Redmine::Configuration['jenkins_username']
|
||||||
jenkins_password = Redmine::Configuration['jenkins_password']
|
jenkins_password = Redmine::Configuration['jenkins_password']
|
||||||
|
logger.info("22222222222222222222222222222222")
|
||||||
# connect jenkins
|
# connect jenkins
|
||||||
@client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password)
|
@client_jenkins = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password)
|
||||||
|
logger.info("333333333333333333333333333333")
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error("failed to connect Jenkins ==> #{e}")
|
logger.error("failed to connect Jenkins ==> #{e}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -386,9 +386,9 @@ update
|
||||||
project_score.update_column(:changeset_num, @changesets_all_count)
|
project_score.update_column(:changeset_num, @changesets_all_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
# unless @changesets_latest_coimmit.blank?
|
unless @changesets_latest_coimmit.blank?
|
||||||
# update_commits_date(@project, @changesets_latest_coimmit)
|
update_commits_date(@project, @changesets_latest_coimmit)
|
||||||
# end
|
end
|
||||||
@creator = @project.owner.to_s
|
@creator = @project.owner.to_s
|
||||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||||
|
|
||||||
|
|
|
@ -597,6 +597,7 @@ class StudentWorkController < ApplicationController
|
||||||
student_work.description = params[:student_work][:description]
|
student_work.description = params[:student_work][:description]
|
||||||
student_work.homework_common_id = @homework.id
|
student_work.homework_common_id = @homework.id
|
||||||
student_work.user_id = User.current.id
|
student_work.user_id = User.current.id
|
||||||
|
student_work.commit_time = Time.now
|
||||||
student_work.save_attachments(params[:attachments])
|
student_work.save_attachments(params[:attachments])
|
||||||
render_attachment_warning_if_needed(student_work)
|
render_attachment_warning_if_needed(student_work)
|
||||||
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
|
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
|
||||||
|
@ -791,7 +792,7 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif @homework.homework_type == 1
|
elsif @homework.homework_type == 1
|
||||||
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0)
|
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil)
|
||||||
end
|
end
|
||||||
@student_work = StudentWork.new
|
@student_work = StudentWork.new
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -826,7 +827,7 @@ class StudentWorkController < ApplicationController
|
||||||
@new_score.user_id = User.current.id
|
@new_score.user_id = User.current.id
|
||||||
@new_score.student_work_id = @work.id
|
@new_score.student_work_id = @work.id
|
||||||
if @is_teacher && @work.work_status == 0
|
if @is_teacher && @work.work_status == 0
|
||||||
@work.update_column('work_status', 1)
|
@work.update_attributes(:work_status => 1, :commit_time => Time.now)
|
||||||
end
|
end
|
||||||
if User.current.admin?
|
if User.current.admin?
|
||||||
@new_score.reviewer_role = 1
|
@new_score.reviewer_role = 1
|
||||||
|
@ -867,6 +868,7 @@ class StudentWorkController < ApplicationController
|
||||||
update_org_activity(@homework.class,@homework.id)
|
update_org_activity(@homework.class,@homework.id)
|
||||||
if @work.save
|
if @work.save
|
||||||
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
|
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
|
||||||
|
@count = @homework.student_works.has_committed.count
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,7 @@ class UsersController < ApplicationController
|
||||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
|
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
|
||||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
|
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
|
||||||
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
|
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
|
||||||
:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks]
|
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks]
|
||||||
before_filter :auth_user_extension, only: :show
|
before_filter :auth_user_extension, only: :show
|
||||||
#before_filter :rest_user_score, only: :show
|
#before_filter :rest_user_score, only: :show
|
||||||
#before_filter :select_entry, only: :user_projects
|
#before_filter :select_entry, only: :user_projects
|
||||||
|
@ -353,14 +353,14 @@ class UsersController < ApplicationController
|
||||||
def dealwith_apply_request
|
def dealwith_apply_request
|
||||||
@msg = CourseMessage.find(params[:msg_id])
|
@msg = CourseMessage.find(params[:msg_id])
|
||||||
#CourseMessage content存的是role 7教辅 9 教师
|
#CourseMessage content存的是role 7教辅 9 教师
|
||||||
|
apply_user = User.find(@msg.course_message_id)
|
||||||
|
ids = @msg.content.split(",") # [@msg.content] msg content保存的是申请的职位角色
|
||||||
|
integer_ids = []
|
||||||
|
ids.each do |role_id|
|
||||||
|
integer_ids << role_id.to_i
|
||||||
|
end
|
||||||
case params[:agree]
|
case params[:agree]
|
||||||
when 'Y'
|
when 'Y'
|
||||||
apply_user = User.find(@msg.course_message_id)
|
|
||||||
ids = @msg.content.split(",") # [@msg.content] msg content保存的是申请的职位角色
|
|
||||||
integer_ids = []
|
|
||||||
ids.each do |role_id|
|
|
||||||
integer_ids << role_id.to_i
|
|
||||||
end
|
|
||||||
if apply_user.member_of_course?(Course.find(@msg.course_id))
|
if apply_user.member_of_course?(Course.find(@msg.course_id))
|
||||||
#将角色改为老师或者教辅
|
#将角色改为老师或者教辅
|
||||||
member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0]
|
member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0]
|
||||||
|
@ -383,11 +383,32 @@ class UsersController < ApplicationController
|
||||||
Course.find(@msg.course_id).members << members
|
Course.find(@msg.course_id).members << members
|
||||||
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1)
|
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1)
|
||||||
@msg.update_attributes(:status=>1,:viewed=>1)
|
@msg.update_attributes(:status=>1,:viewed=>1)
|
||||||
|
|
||||||
|
if integer_ids.include?(9)
|
||||||
|
cs = CoursesService.new
|
||||||
|
c = Course.find(@msg.course_id)
|
||||||
|
cs.send_wechat_join_class_notice apply_user,c,9,0
|
||||||
|
else
|
||||||
|
cs = CoursesService.new
|
||||||
|
c = Course.find(@msg.course_id)
|
||||||
|
cs.send_wechat_join_class_notice apply_user,c,7,0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'N'
|
when 'N'
|
||||||
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2)
|
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2)
|
||||||
@msg.update_attributes(:status=>2,:viewed=>1)
|
@msg.update_attributes(:status=>2,:viewed=>1)
|
||||||
|
|
||||||
|
if integer_ids.include?(9)
|
||||||
|
cs = CoursesService.new
|
||||||
|
c = Course.find(@msg.course_id)
|
||||||
|
cs.send_wechat_join_class_notice apply_user,c,9,1
|
||||||
|
else
|
||||||
|
cs = CoursesService.new
|
||||||
|
c = Course.find(@msg.course_id)
|
||||||
|
cs.send_wechat_join_class_notice apply_user,c,7,1
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
@ -599,7 +620,7 @@ class UsersController < ApplicationController
|
||||||
if(params[:type].blank? || params[:type] == "1") #我的题库
|
if(params[:type].blank? || params[:type] == "1") #我的题库
|
||||||
courses = @user.courses.where("is_delete = 1")
|
courses = @user.courses.where("is_delete = 1")
|
||||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||||
elsif params[:type] == "2" #公共题库
|
elsif params[:type] == "2" #公共题库
|
||||||
visible_course = Course.where("is_delete = 0")
|
visible_course = Course.where("is_delete = 0")
|
||||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||||
|
@ -1004,6 +1025,7 @@ class UsersController < ApplicationController
|
||||||
student_work.work_status = 1
|
student_work.work_status = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
student_work.commit_time = Time.now
|
||||||
student_work.save
|
student_work.save
|
||||||
send_message_to_teacher(student_work)
|
send_message_to_teacher(student_work)
|
||||||
homework.update_column(:updated_at, Time.now)
|
homework.update_column(:updated_at, Time.now)
|
||||||
|
@ -1460,6 +1482,7 @@ class UsersController < ApplicationController
|
||||||
def user_projects4show
|
def user_projects4show
|
||||||
@page = params[:page].to_i + 1
|
@page = params[:page].to_i + 1
|
||||||
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page * 10)
|
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page * 10)
|
||||||
|
@all_count = @user.projects.visible.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_course_activities
|
def user_course_activities
|
||||||
|
@ -1533,7 +1556,7 @@ class UsersController < ApplicationController
|
||||||
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
stu_courses = @user.courses.visible.not_deleted.select{|course| @user.has_student_role(course)}
|
||||||
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
stu_course_ids = stu_courses.empty? ? "(-1)" : "(" + stu_courses.map{|course| course.id}.join(',') + ")"
|
||||||
@receive_homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc").limit(5)
|
@receive_homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc").limit(5)
|
||||||
if (@manage_homeworks.empty? && @receive_homeworks.empty?) || (@receive_homeworks.empty?) || (!@manage_homeworks.empty? && !@receive_homeworks.empty? && @manage_homeworks.first.publish_time > @receive_homeworks.first.publish_time)
|
if (@manage_homeworks.empty? && @receive_homeworks.empty?) || (@receive_homeworks.empty?) || (!@manage_homeworks.empty? && !@receive_homeworks.empty? && @manage_homeworks.first.created_at > @receive_homeworks.first.created_at)
|
||||||
@manage_pre = true
|
@manage_pre = true
|
||||||
else
|
else
|
||||||
@manage_pre = false
|
@manage_pre = false
|
||||||
|
@ -3417,7 +3440,22 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_projectlist
|
def user_projectlist
|
||||||
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
||||||
|
#limit = 5
|
||||||
|
|
||||||
|
@my_projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
|
||||||
|
@my_projects_count = @my_projects.count
|
||||||
|
|
||||||
|
@my_joined_projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
|
||||||
|
@my_joined_projects_count = @my_joined_projects.count
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {render :layout => 'new_base_user'}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_project_list
|
||||||
|
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
|
||||||
|
#limit = 5
|
||||||
|
|
||||||
#确定 sort_type
|
#确定 sort_type
|
||||||
if @order.to_i == @type.to_i
|
if @order.to_i == @type.to_i
|
||||||
|
@ -3426,11 +3464,16 @@ class UsersController < ApplicationController
|
||||||
@c_sort = 2
|
@c_sort = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
sort_name = "updated_at"
|
sort_name = "updatetime"
|
||||||
sort_type = @c_sort == 1 ? "asc" : "desc"
|
sort_type = @c_sort == 1 ? "asc" : "desc"
|
||||||
|
|
||||||
#@projects = @user.projects.visible.order("#{sort_name} #{sort_type}")
|
#@projects = @user.projects.visible.order("#{sort_name} #{sort_type}")
|
||||||
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name} ").order("#{sort_name} #{sort_type}")
|
if @list_type.to_i == 1
|
||||||
|
@projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
|
||||||
|
else
|
||||||
|
@projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
|
||||||
|
end
|
||||||
|
@projects_count = @projects.count
|
||||||
|
|
||||||
#根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num
|
#根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num
|
||||||
if @order.to_i == 2
|
if @order.to_i == 2
|
||||||
|
@ -3447,18 +3490,8 @@ class UsersController < ApplicationController
|
||||||
@type = 1
|
@type = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
#分页
|
|
||||||
@limit = 10
|
|
||||||
@is_remote = true
|
|
||||||
@atta_count = @projects.count
|
|
||||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
|
||||||
@offset ||= @atta_pages.offset
|
|
||||||
@projects = paginateHelper @projects,@limit
|
|
||||||
@is_project = 1
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html {render :layout => 'new_base_user'}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ class WechatsController < ActionController::Base
|
||||||
on :fallback, respond: 'fallback message'
|
on :fallback, respond: 'fallback message'
|
||||||
|
|
||||||
on :click, with: 'FEEDBACK' do |request, key|
|
on :click, with: 'FEEDBACK' do |request, key|
|
||||||
request.reply.text "如有反馈问题,请直接切换至输入框,发微信给我们即可"
|
request.reply.text "如有问题反馈,请您:\n1、直接切换至输入框,发微信给我们。\n2、加入QQ群:173184401,我们直接互动。\n欢迎大家积极反馈,谢谢啦!"
|
||||||
end
|
end
|
||||||
|
|
||||||
on :click, with: 'MY_NEWS' do |request, key|
|
on :click, with: 'MY_NEWS' do |request, key|
|
||||||
|
@ -252,13 +252,16 @@ class WechatsController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def sendBind(request)
|
def sendBind(request)
|
||||||
|
tmpurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login&connect_redirect=1#wechat_redirect"
|
||||||
|
logger.info "tmpurl!!!!!!!!!!!!!!"
|
||||||
|
logger.info tmpurl
|
||||||
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "欢迎使用Trustie创新实践服务平台!
|
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "欢迎使用Trustie创新实践服务平台!
|
||||||
在这里您可以随时了解您的课程和项目动态,随时点赞和回复。
|
在这里您可以随时了解您的课程和项目动态,随时点赞和回复。
|
||||||
我们将会与微信不断结合,为您提供更有价值的服务。
|
我们将会与微信不断结合,为您提供更有价值的服务。
|
||||||
|
|
||||||
您还未绑定确实的用户,请先绑定,谢谢!" } }
|
您还未绑定确实的用户,请先绑定,谢谢!" } }
|
||||||
request.reply.news(news) do |article, n, index| # article is return object
|
request.reply.news(news) do |article, n, index| # article is return object
|
||||||
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login#wechat_redirect"
|
url = tmpurl
|
||||||
pic_url = "#{ROOT_URL}/images/weixin_pic.jpg"
|
pic_url = "#{ROOT_URL}/images/weixin_pic.jpg"
|
||||||
article.item title: "#{n[:title]}",
|
article.item title: "#{n[:title]}",
|
||||||
description: n[:content],
|
description: n[:content],
|
||||||
|
@ -284,7 +287,7 @@ class WechatsController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
|
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
|
||||||
content: "课程名称:#{course.name}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
|
content: "课程名称:#{course.syllabus.title}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
|
||||||
return request.reply.news(news) do |article, n, index| # article is return object
|
return request.reply.news(news) do |article, n, index| # article is return object
|
||||||
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect"
|
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect"
|
||||||
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
|
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
|
||||||
|
@ -314,7 +317,7 @@ class WechatsController < ActionController::Base
|
||||||
creator = User.find(project.user_id)
|
creator = User.find(project.user_id)
|
||||||
|
|
||||||
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入项目,开始研发吧!',
|
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入项目,开始研发吧!',
|
||||||
content: "项目名称:#{project.name}\n发起人:#{creator.name}\n进入项目,和小伙伴轻松的研发吧!"} }
|
content: "项目名称:#{project.name}\n发起人:#{creator.show_name}\n进入项目,和小伙伴轻松的研发吧!"} }
|
||||||
return request.reply.news(news) do |article, n, index| # article is return object
|
return request.reply.news(news) do |article, n, index| # article is return object
|
||||||
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/project?id='+project.id.to_s}&response_type=code&scope=snsapi_base&state=myproject#wechat_redirect"
|
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/project?id='+project.id.to_s}&response_type=code&scope=snsapi_base&state=myproject#wechat_redirect"
|
||||||
pic_url = "#{ROOT_URL}/images/wechat/project.jpg"
|
pic_url = "#{ROOT_URL}/images/wechat/project.jpg"
|
||||||
|
@ -333,10 +336,12 @@ class WechatsController < ActionController::Base
|
||||||
code = params[:code] || session[:wechat_code]
|
code = params[:code] || session[:wechat_code]
|
||||||
openid = get_openid_from_code(code)
|
openid = get_openid_from_code(code)
|
||||||
|
|
||||||
raise "无法获取到微信openid" unless openid
|
# raise "无法获取到微信openid" unless openid
|
||||||
|
|
||||||
|
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
||||||
|
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
raise "还未绑定trustie帐户" unless uw
|
raise "还未绑定trustie帐户" unless (uw && uw.bindtype == 0)
|
||||||
logger.debug "get_bind ============= #{uw}"
|
logger.debug "get_bind ============= #{uw}"
|
||||||
|
|
||||||
user = uw.user
|
user = uw.user
|
||||||
|
@ -349,13 +354,25 @@ class WechatsController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_bind
|
||||||
|
begin
|
||||||
|
code = params[:code] || session[:wechat_code]
|
||||||
|
open_id = get_openid_from_code(code)
|
||||||
|
raise "还未绑定trustie帐户" unless user_binded?(open_id)
|
||||||
|
render :json => {status: 0}
|
||||||
|
rescue Exception=>e
|
||||||
|
render :json => {status: -1, message: e.message}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def bind
|
def bind
|
||||||
begin
|
begin
|
||||||
|
|
||||||
code = params[:code] || session[:wechat_code]
|
code = params[:code] || session[:wechat_code]
|
||||||
openid = get_openid_from_code(code)
|
openid = get_openid_from_code(code)
|
||||||
|
|
||||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
|
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
|
||||||
raise "此微信号已绑定用户,不能重复绑定" if user_binded?(openid)
|
raise "此微信号已绑定用户,不能重复绑定" if user_binded?(openid)
|
||||||
|
|
||||||
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
||||||
|
@ -369,7 +386,7 @@ class WechatsController < ActionController::Base
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.login, format_time(Time.now))
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.show_name+"("+user.login+")", format_time(Time.now))
|
||||||
render :json => {status:0, msg: "绑定成功"}
|
render :json => {status:0, msg: "绑定成功"}
|
||||||
rescue Exception=>e
|
rescue Exception=>e
|
||||||
render :json => {status: -1, msg: e.message}
|
render :json => {status: -1, msg: e.message}
|
||||||
|
@ -398,8 +415,16 @@ class WechatsController < ActionController::Base
|
||||||
unless open_id
|
unless open_id
|
||||||
render 'wechats/open_wechat', layout: nil and return
|
render 'wechats/open_wechat', layout: nil and return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
logger.info "user_activities!!!!!!!!!!!!!!"
|
||||||
|
logger.info params
|
||||||
|
|
||||||
|
#保证下面的redirect_to "/wechat/user_activities##{@path}?id=...不会往下走
|
||||||
|
if params[:state] == nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
unless user_binded?(open_id)
|
unless (user_binded?(open_id) || params[:state] == "invite_code" || params[:state] == "project_invite_code" || params[:state] == "blog_comment" || params[:state] == "course_notice" || params[:state] == "project_discussion" || params[:state] == "course_discussion" || params[:state] == "homework" || params[:state] == "issues" || params[:state] == "journal_for_message")
|
||||||
@path = '/login'
|
@path = '/login'
|
||||||
else
|
else
|
||||||
if params[:state] == 'myclass'
|
if params[:state] == 'myclass'
|
||||||
|
@ -410,7 +435,14 @@ class WechatsController < ActionController::Base
|
||||||
|
|
||||||
session[:wechat_openid] = open_id
|
session[:wechat_openid] = open_id
|
||||||
if params[:code]
|
if params[:code]
|
||||||
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
if params[:userid]
|
||||||
|
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&userid=#{params[:userid]}" and return
|
||||||
|
elsif params[:id]
|
||||||
|
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
||||||
|
else
|
||||||
|
redirect_to "/wechat/user_activities##{@path}" and return
|
||||||
|
end
|
||||||
|
# redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render 'wechats/user_activities', layout: nil
|
render 'wechats/user_activities', layout: nil
|
||||||
|
@ -421,10 +453,19 @@ class WechatsController < ActionController::Base
|
||||||
def get_openid_from_code(code)
|
def get_openid_from_code(code)
|
||||||
return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test'
|
return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test'
|
||||||
openid = session[:wechat_openid]
|
openid = session[:wechat_openid]
|
||||||
|
|
||||||
unless openid
|
unless openid
|
||||||
if code
|
if code
|
||||||
openid = wechat.web_access_token(code)["openid"]
|
#不能联系调两次web_access_token 否则会提示请在微信客户端打开次链接
|
||||||
|
info = wechat.web_access_token(code)
|
||||||
|
openid =info["openid"]
|
||||||
|
access_token =info["access_token"]
|
||||||
|
if access_token
|
||||||
|
session[:access_token] = access_token
|
||||||
|
end
|
||||||
|
refresh_token = info["refresh_token"]
|
||||||
|
if refresh_token
|
||||||
|
session[:refresh_token] = refresh_token
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -437,6 +478,11 @@ class WechatsController < ActionController::Base
|
||||||
|
|
||||||
def user_binded?(openid)
|
def user_binded?(openid)
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
|
if uw && uw.bindtype == 0
|
||||||
|
uw
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_url
|
def current_url
|
||||||
|
|
|
@ -2172,7 +2172,7 @@ module ApplicationHelper
|
||||||
candown = User.current.member_of_org?(org) || ((attachment.is_public == 1 || attachment.get_status_by_attach(User.current.id) == 2) && org.allow_guest_download == true)
|
candown = User.current.member_of_org?(org) || ((attachment.is_public == 1 || attachment.get_status_by_attach(User.current.id) == 2) && org.allow_guest_download == true)
|
||||||
elsif attachment.container.is_a?(OrgDocumentComment)
|
elsif attachment.container.is_a?(OrgDocumentComment)
|
||||||
org = attachment.container.organization
|
org = attachment.container.organization
|
||||||
candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
|
candown = org.allow_guest_download || User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
|
||||||
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
|
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
|
||||||
attachment.container.board.course
|
attachment.container.board.course
|
||||||
course = attachment.container.board.course
|
course = attachment.container.board.course
|
||||||
|
@ -2738,7 +2738,7 @@ module ApplicationHelper
|
||||||
link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
|
link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
|
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 #匿评作业,且作业状态不是在开启匿评之前
|
||||||
link_to "作品匿评", student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品"
|
link_to "作品匿评", student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品"
|
||||||
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
|
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
|
||||||
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "匿评已结束"
|
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "匿评已结束"
|
||||||
|
@ -2841,7 +2841,7 @@ module ApplicationHelper
|
||||||
#获取当前作业的提交截止时间/互评截止时间
|
#获取当前作业的提交截止时间/互评截止时间
|
||||||
def cur_homework_end_time homework
|
def cur_homework_end_time homework
|
||||||
str = ""
|
str = ""
|
||||||
if homework.anonymous_comment == 0 && homework.end_time < Date.today && homework.homework_detail_manual
|
if homework.anonymous_comment == 0 && homework.end_time && homework.end_time < Date.today && homework.homework_detail_manual
|
||||||
str = "互评截止:#{format_date homework.homework_detail_manual.evaluation_end}"
|
str = "互评截止:#{format_date homework.homework_detail_manual.evaluation_end}"
|
||||||
else
|
else
|
||||||
str = "提交截止:#{homework.end_time ? (format_date homework.end_time) : ' -- '}"
|
str = "提交截止:#{homework.end_time ? (format_date homework.end_time) : ' -- '}"
|
||||||
|
@ -3436,3 +3436,9 @@ def course_syllabus_option user = User.current
|
||||||
end
|
end
|
||||||
type
|
type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 获取项目动态更新时间
|
||||||
|
def get_forge_act_message(act, type)
|
||||||
|
forge_act = ForgeActivity.where(:forge_act_id => act.id, :forge_act_type => type).first
|
||||||
|
format_time(forge_act.nil? ? act.created_on : forge_act.try(:updated_at))
|
||||||
|
end
|
||||||
|
|
|
@ -18,12 +18,6 @@ module OrganizationsHelper
|
||||||
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
|
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取项目动态更新时间
|
|
||||||
def get_forge_act_message(act, type)
|
|
||||||
forge_act = ForgeActivity.where(:forge_act_id => act.id, :forge_act_type => type).first
|
|
||||||
format_time(forge_act.nil? ? act.created_on : forge_act.try(:updated_at))
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_default_name field
|
def get_default_name field
|
||||||
case field.name
|
case field.name
|
||||||
when 'activity' then
|
when 'activity' then
|
||||||
|
|
|
@ -14,4 +14,37 @@ module PullRequestsHelper
|
||||||
User.find(user_id).try(:login)
|
User.find(user_id).try(:login)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 获取接受PullRequest用户的信息
|
||||||
|
def accept_user pull_request_id
|
||||||
|
PullRequest.where(:pull_request_id => pull_request_id).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_state state
|
||||||
|
case state
|
||||||
|
when "open","reopened"
|
||||||
|
l(:label_state_open)
|
||||||
|
when "closed"
|
||||||
|
l(:label_state_closed)
|
||||||
|
when "merged"
|
||||||
|
l(:label_state_merged)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def type_count type, requests_opened_count, requests_merged_count, requests_closed_count
|
||||||
|
case type
|
||||||
|
when nil, "1"
|
||||||
|
requests_opened_count
|
||||||
|
when "2"
|
||||||
|
requests_merged_count
|
||||||
|
when "3"
|
||||||
|
requests_closed_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 判断是否允许创建Pull Request
|
||||||
|
# 如果分支相同,并且项目相同则提示
|
||||||
|
def judge_pr_allow
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,23 +1,33 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
module QualityAnalysisHelper
|
module QualityAnalysisHelper
|
||||||
|
|
||||||
|
def sonar_time sonar_name
|
||||||
|
sonar = open(@sonar_address + "/api/resources/index?resource=#{sonar_name}&depth=0").read
|
||||||
|
sonar =JSON.parse(sonar).first['date']
|
||||||
|
end
|
||||||
|
|
||||||
def sqale_rating_status val
|
def sqale_rating_status val
|
||||||
arr = []
|
arr = []
|
||||||
if val <= 5
|
if val <= 5
|
||||||
arr << "很好"
|
arr << "很好"
|
||||||
arr << "b_green2"
|
arr << "b_green2"
|
||||||
|
arr << "A"
|
||||||
elsif val. > 5 && val <= 10
|
elsif val. > 5 && val <= 10
|
||||||
arr << "较好"
|
arr << "较好"
|
||||||
arr << "b_slow_yellow"
|
arr << "b_slow_yellow"
|
||||||
|
arr << "B"
|
||||||
elsif val > 10 && val <= 20
|
elsif val > 10 && val <= 20
|
||||||
arr << "中等"
|
arr << "中等"
|
||||||
arr << "b_yellow"
|
arr << "b_yellow"
|
||||||
|
arr << "C"
|
||||||
elsif val > 20 && val <= 50
|
elsif val > 20 && val <= 50
|
||||||
arr << "较差"
|
arr << "较差"
|
||||||
arr << "b_slow_red"
|
arr << "b_slow_red"
|
||||||
|
arr << "D"
|
||||||
elsif val > 20
|
elsif val > 20
|
||||||
arr << "很差"
|
arr << "很差"
|
||||||
arr << "b_red"
|
arr << "b_red"
|
||||||
|
arr << "E"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ module RepositoriesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取文件目录的最新动态
|
# 获取文件目录的最新动态
|
||||||
def get_trees_last_changes(project_id, rev, ent_name, g)
|
def get_trees_last_changes(gpid, rev, ent_name, g)
|
||||||
begin
|
begin
|
||||||
tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name)
|
tree_changes = g.rep_last_changes(gpid, :rev => rev, :path => ent_name)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts e
|
puts e
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,6 +80,7 @@ class Course < ActiveRecord::Base
|
||||||
after_update :update_files_public,:update_course_ealasticsearch_index
|
after_update :update_files_public,:update_course_ealasticsearch_index
|
||||||
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index
|
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index
|
||||||
before_destroy :delete_all_members,:delete_course_ealasticsearch_index
|
before_destroy :delete_all_members,:delete_course_ealasticsearch_index
|
||||||
|
after_save :log_infor
|
||||||
|
|
||||||
safe_attributes 'extra',
|
safe_attributes 'extra',
|
||||||
'time',
|
'time',
|
||||||
|
@ -504,6 +505,10 @@ class Course < ActiveRecord::Base
|
||||||
ticket
|
ticket
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log_infor
|
||||||
|
Rails.logger.info "##########################################################course's syllabus_id is #{self.syllabus_id}."
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class HomeworkCommon < ActiveRecord::Base
|
||||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||||
if count == 0
|
if count == 0
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name},#{l(:label_new_homework_template)}:", self.course.name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
|
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name},#{l(:label_new_homework_template)}", self.course.name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
@ -173,7 +173,7 @@ class News < ActiveRecord::Base
|
||||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||||
if count == 0
|
if count == 0
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200
|
content = self.title
|
||||||
ws.class_notice m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.course.name, self.author.show_name, format_time(self.created_on), content, "点击查看通知详情"
|
ws.class_notice m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.course.name, self.author.show_name, format_time(self.created_on), content, "点击查看通知详情"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1254,12 +1254,14 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
|
|
||||||
def create_project_ealasticsearch_index
|
def create_project_ealasticsearch_index
|
||||||
|
return if Rails.env.development?
|
||||||
if self.is_public
|
if self.is_public
|
||||||
self.__elasticsearch__.index_document
|
self.__elasticsearch__.index_document
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_project_ealasticsearch_index
|
def update_project_ealasticsearch_index
|
||||||
|
return if Rails.env.development?
|
||||||
if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
|
if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
|
||||||
begin
|
begin
|
||||||
self.__elasticsearch__.update_document
|
self.__elasticsearch__.update_document
|
||||||
|
@ -1276,6 +1278,7 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_project_ealasticsearch_index
|
def delete_project_ealasticsearch_index
|
||||||
|
return if Rails.env.development?
|
||||||
begin
|
begin
|
||||||
self.__elasticsearch__.delete_document
|
self.__elasticsearch__.delete_document
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
class PullRequest < ActiveRecord::Base
|
||||||
|
attr_accessible :gpid, :pull_request_id, :user_id
|
||||||
|
validates_uniqueness_of :pull_request_id
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
#学生提交作品表
|
#学生提交作品表
|
||||||
class StudentWork < ActiveRecord::Base
|
class StudentWork < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value, :work_status
|
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time
|
||||||
|
|
||||||
belongs_to :homework_common
|
belongs_to :homework_common
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
|
@ -228,7 +228,7 @@ class User < Principal
|
||||||
# Prevents unauthorized assignments
|
# Prevents unauthorized assignments
|
||||||
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
|
||||||
|
|
||||||
LOGIN_LENGTH_LIMIT = 25
|
LOGIN_LENGTH_LIMIT = 30
|
||||||
MAIL_LENGTH_LIMIT = 60
|
MAIL_LENGTH_LIMIT = 60
|
||||||
|
|
||||||
validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
class UserWechat < ActiveRecord::Base
|
class UserWechat < ActiveRecord::Base
|
||||||
attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country,
|
attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country,
|
||||||
:headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id
|
:headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id, :bindtype
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
def real?
|
||||||
|
bindtype == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def migrate_user(u)
|
||||||
|
self.bindtype = 0
|
||||||
|
old_user = user.id
|
||||||
|
self.user = u
|
||||||
|
self.save
|
||||||
|
|
||||||
|
## 主要是将comment 迁移
|
||||||
|
User.delete(old_user)
|
||||||
|
|
||||||
|
JournalsForMessage.where(user_id: old_user).update_all(user_id: u.id)
|
||||||
|
Journal.where(user_id: old_user).update_all(user_id: u.id)
|
||||||
|
Comment.where(author_id: old_user).update_all(author_id: u.id)
|
||||||
|
Message.where(author_id: old_user).update_all(author_id: u.id)
|
||||||
|
BlogComment.where(author_id: old_user).update_all(author_id: u.id)
|
||||||
|
UserActivity.where(user_id: old_user).update_all(user_id: u.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,7 +97,7 @@ class CoursesService
|
||||||
end
|
end
|
||||||
users = []
|
users = []
|
||||||
@members.each do |m|
|
@members.each do |m|
|
||||||
img_url = url_to_avatar(m.user)
|
img_url = "/images/"+url_to_avatar(m.user)
|
||||||
gender = m.user.user_extensions.gender.nil? ? 0 : m.user.user_extensions.gender
|
gender = m.user.user_extensions.gender.nil? ? 0 : m.user.user_extensions.gender
|
||||||
work_unit = get_user_work_unit m.user
|
work_unit = get_user_work_unit m.user
|
||||||
location = get_user_location m.user
|
location = get_user_location m.user
|
||||||
|
@ -108,14 +108,14 @@ class CoursesService
|
||||||
end
|
end
|
||||||
|
|
||||||
#双重身份 学生列表中不显示
|
#双重身份 学生列表中不显示
|
||||||
unless (params[:role] == '2' && role_ids.length >= 2)
|
# unless (params[:role] == '2' && role_ids.length >= 2)
|
||||||
users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender,
|
users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender,
|
||||||
:work_unit => work_unit, :mail => m.user.mail, :location => location,
|
:work_unit => work_unit, :mail => m.user.mail, :location => location,
|
||||||
role_name: m.roles.first.name,
|
role_name: m.roles.first.name,
|
||||||
name: m.user.show_name,
|
name: m.user.show_name,
|
||||||
roles_id: role_ids.include?(7) ? 7 : (role_ids.include?(9) ? 9 : 10 ),
|
roles_id: role_ids.include?(7) ? 7 : (role_ids.include?(9) ? 9 : 10 ),
|
||||||
:brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname}
|
:brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname}
|
||||||
end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
users
|
users
|
||||||
|
@ -223,16 +223,20 @@ class CoursesService
|
||||||
end
|
end
|
||||||
if integer_ids.include?(9)
|
if integer_ids.include?(9)
|
||||||
message = "您已同意教师"+apply_user.show_name+",加入班级"
|
message = "您已同意教师"+apply_user.show_name+",加入班级"
|
||||||
|
send_wechat_join_class_notice apply_user,c,9,0
|
||||||
else
|
else
|
||||||
message = "您已同意助教"+apply_user.show_name+",加入班级"
|
message = "您已同意助教"+apply_user.show_name+",加入班级"
|
||||||
|
send_wechat_join_class_notice apply_user,c,7,0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
CourseMessage.create(:user_id => apply_user.id, :course_id => c.id, :viewed => false,:content=> messages.content,:course_message_id=>current_user.id,:course_message_type=>'CourseRequestDealResult',:status=>2)
|
CourseMessage.create(:user_id => apply_user.id, :course_id => c.id, :viewed => false,:content=> messages.content,:course_message_id=>current_user.id,:course_message_type=>'CourseRequestDealResult',:status=>2)
|
||||||
messages.update_attributes(:status=>2,:viewed=>1)
|
messages.update_attributes(:status=>2,:viewed=>1)
|
||||||
if integer_ids.include?(9)
|
if integer_ids.include?(9)
|
||||||
message = "您已拒绝教师"+apply_user.show_name+",加入班级"
|
message = "您已拒绝教师"+apply_user.show_name+",加入班级"
|
||||||
|
send_wechat_join_class_notice apply_user,c,9,1
|
||||||
else
|
else
|
||||||
message = "您已拒绝助教"+apply_user.show_name+",加入班级"
|
message = "您已拒绝助教"+apply_user.show_name+",加入班级"
|
||||||
|
send_wechat_join_class_notice apply_user,c,7,1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
status = 0
|
status = 0
|
||||||
|
@ -528,6 +532,33 @@ class CoursesService
|
||||||
{:state => @state,:course => course}
|
{:state => @state,:course => course}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#加入班级结果
|
||||||
|
def send_wechat_join_class_notice user,course,role_id,result
|
||||||
|
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count
|
||||||
|
if count == 0
|
||||||
|
ws = WechatService.new
|
||||||
|
|
||||||
|
role_name = role_id == 7 ? "助教" : role_id == 9 ? "教师" : "学生"
|
||||||
|
result_name = result == 0 ? "通过" : "被拒绝"
|
||||||
|
content = "您以"+role_name+"身份加入班级的申请已"+result_name+"。"
|
||||||
|
|
||||||
|
if result == 0
|
||||||
|
title = "恭喜您加入班级成功。"
|
||||||
|
remark = "点击查看班级详情。"
|
||||||
|
uid = 0
|
||||||
|
type = "class"
|
||||||
|
else
|
||||||
|
title = "很遗憾您未能成功加入班级。"
|
||||||
|
remark = "点击查看申请详情。"
|
||||||
|
uid = user.id
|
||||||
|
type = "review_class_member"
|
||||||
|
end
|
||||||
|
ws = WechatService.new
|
||||||
|
ws.class_notice user.id, type, course.id, title, course.name, user.show_name, format_time(Time.now), content, remark,uid
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#多个角色加入课程
|
#多个角色加入课程
|
||||||
def join_course_roles params,current_user
|
def join_course_roles params,current_user
|
||||||
course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
||||||
|
@ -587,6 +618,7 @@ class CoursesService
|
||||||
course.members << members
|
course.members << members
|
||||||
StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id)
|
StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id)
|
||||||
@state = 0
|
@state = 0
|
||||||
|
send_wechat_join_class_notice current_user,course,10,0
|
||||||
else
|
else
|
||||||
is_stu = false
|
is_stu = false
|
||||||
if role_ids.include?("10")
|
if role_ids.include?("10")
|
||||||
|
@ -595,6 +627,7 @@ class CoursesService
|
||||||
course.members << members
|
course.members << members
|
||||||
StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id)
|
StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id)
|
||||||
is_stu = true
|
is_stu = true
|
||||||
|
send_wechat_join_class_notice current_user,course,10,0
|
||||||
end
|
end
|
||||||
#如果已经发送过消息了,那么就要给个提示
|
#如果已经发送过消息了,那么就要给个提示
|
||||||
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = '#{role_str}' and course_message_id = #{current_user.id} and course_id = #{course.id} and status = 0").count != 0
|
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = '#{role_str}' and course_message_id = #{current_user.id} and course_id = #{course.id} and status = 0").count != 0
|
||||||
|
|
|
@ -256,7 +256,7 @@ class HomeworkService
|
||||||
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")
|
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")
|
||||||
jours.each do |jour|
|
jours.each do |jour|
|
||||||
user = jour.user
|
user = jour.user
|
||||||
img_url = url_to_avatar(jour.user)
|
img_url = "/images/"+url_to_avatar(jour.user)
|
||||||
datetime = jour.created_on
|
datetime = jour.created_on
|
||||||
content = jour.notes
|
content = jour.notes
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,6 +117,27 @@ class ProjectsService
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#加入项目结果
|
||||||
|
def send_wechat_join_project_notice user,project,role_id,result
|
||||||
|
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count
|
||||||
|
if count == 0
|
||||||
|
result_name = result == 0 ? "已同意" : "已拒绝"
|
||||||
|
if result == 0
|
||||||
|
title = "恭喜您加入项目成功。"
|
||||||
|
remark = "点击查看项目详情。"
|
||||||
|
uid = 0
|
||||||
|
type = "project"
|
||||||
|
else
|
||||||
|
title = "很遗憾您未能成功加入项目。"
|
||||||
|
remark = "点击查看申请详情。"
|
||||||
|
uid = user.id
|
||||||
|
type = "review_project_member"
|
||||||
|
end
|
||||||
|
ws = WechatService.new
|
||||||
|
ws.join_project_notice user.id, "project", project.id,title, project.name,result_name, remark,uid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def join_project params,current_user
|
def join_project params,current_user
|
||||||
status = -1
|
status = -1
|
||||||
project = Project.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
project = Project.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
||||||
|
@ -128,6 +149,10 @@ class ProjectsService
|
||||||
if current_user.member_of?(project) #如果已经是成员
|
if current_user.member_of?(project) #如果已经是成员
|
||||||
member = project.member_principals.includes(:roles, :principal).where("user_id=?",current_user.id).first
|
member = project.member_principals.includes(:roles, :principal).where("user_id=?",current_user.id).first
|
||||||
status = member.member_roles[0].role_id
|
status = member.member_roles[0].role_id
|
||||||
|
|
||||||
|
#将之前的申请都改为已拒绝
|
||||||
|
applied_messages = AppliedMessage.where(:project_id => project.id, :status => true, :applied_user_id=>current_user.id,:applied_type => "AppliedProject")
|
||||||
|
applied_messages.update_all(:status=>5)
|
||||||
else
|
else
|
||||||
if params[:invite_code].present?
|
if params[:invite_code].present?
|
||||||
|
|
||||||
|
@ -146,6 +171,11 @@ class ProjectsService
|
||||||
project.project_infos << project_info
|
project.project_infos << project_info
|
||||||
|
|
||||||
status = 0
|
status = 0
|
||||||
|
send_wechat_join_project_notice current_user,project,5,0
|
||||||
|
|
||||||
|
#将之前的申请都改为已拒绝
|
||||||
|
applied_messages = AppliedMessage.where(:project_id => project.id, :status => true, :applied_user_id=>current_user.id,:applied_type => "AppliedProject")
|
||||||
|
applied_messages.update_all(:status=>5)
|
||||||
else
|
else
|
||||||
if !AppliedProject.where(:project_id => project.id, :user_id => current_user.id).first.nil?
|
if !AppliedProject.where(:project_id => project.id, :user_id => current_user.id).first.nil?
|
||||||
status = 8
|
status = 8
|
||||||
|
@ -181,7 +211,7 @@ class ProjectsService
|
||||||
user = User.find(m.applied_user_id)
|
user = User.find(m.applied_user_id)
|
||||||
|
|
||||||
if user
|
if user
|
||||||
img_url = url_to_avatar(user)
|
img_url = "/images/"+url_to_avatar(user)
|
||||||
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
|
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
|
||||||
work_unit = get_user_work_unit user
|
work_unit = get_user_work_unit user
|
||||||
location = get_user_location user
|
location = get_user_location user
|
||||||
|
@ -210,7 +240,7 @@ class ProjectsService
|
||||||
status = applied_message.status
|
status = applied_message.status
|
||||||
user = User.find(params[:user_id])
|
user = User.find(params[:user_id])
|
||||||
if user
|
if user
|
||||||
img_url = url_to_avatar(user)
|
img_url = "/images/"+url_to_avatar(user)
|
||||||
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
|
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
|
||||||
work_unit = get_user_work_unit user
|
work_unit = get_user_work_unit user
|
||||||
location = get_user_location user
|
location = get_user_location user
|
||||||
|
@ -239,7 +269,12 @@ class ProjectsService
|
||||||
if apply_message
|
if apply_message
|
||||||
if user.member_of?(project)
|
if user.member_of?(project)
|
||||||
message = "已经是该项目的成员了"
|
message = "已经是该项目的成员了"
|
||||||
applied_messages.update_all(:status=>7)
|
u_member = project.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
|
||||||
|
if u_member.member_roles[0].role_id == 5
|
||||||
|
applied_messages.update_all(:status=>5)
|
||||||
|
else
|
||||||
|
applied_messages.update_all(:status=>7)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
applied_project = apply_message.applied
|
applied_project = apply_message.applied
|
||||||
ap_role = applied_project.try(:role)
|
ap_role = applied_project.try(:role)
|
||||||
|
@ -266,6 +301,8 @@ class ProjectsService
|
||||||
|
|
||||||
message = "您已同意"+rolename+user.show_name+",加入项目"
|
message = "您已同意"+rolename+user.show_name+",加入项目"
|
||||||
|
|
||||||
|
send_wechat_join_project_notice user,project,ap_role,0
|
||||||
|
|
||||||
else
|
else
|
||||||
#拒绝
|
#拒绝
|
||||||
AppliedMessage.create(:user_id => user.id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4,
|
AppliedMessage.create(:user_id => user.id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4,
|
||||||
|
@ -275,6 +312,8 @@ class ProjectsService
|
||||||
applied_project.delete
|
applied_project.delete
|
||||||
|
|
||||||
message = "您已拒绝"+rolename+user.show_name+",加入项目"
|
message = "您已拒绝"+rolename+user.show_name+",加入项目"
|
||||||
|
|
||||||
|
send_wechat_join_project_notice user,project,ap_role,1
|
||||||
end
|
end
|
||||||
|
|
||||||
status = 0
|
status = 0
|
||||||
|
|
|
@ -36,24 +36,21 @@ class SyllabusesService
|
||||||
# courses.each do |c|
|
# courses.each do |c|
|
||||||
# other.courses << c[:course] unless c[:course].syllabus
|
# other.courses << c[:course] unless c[:course].syllabus
|
||||||
# end
|
# end
|
||||||
|
result = []
|
||||||
|
i = 0
|
||||||
|
|
||||||
courses = user.courses.not_deleted
|
courses = user.courses.not_deleted
|
||||||
syllabus_ids = courses.empty? ? '(-1)' : "(" + courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
|
syllabus_ids = courses.empty? ? '(-1)' : "(" + courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
|
||||||
syllabuses = Syllabus.where("id in #{syllabus_ids} or user_id = #{user.id}").order("updated_at desc")
|
syllabuses = Syllabus.where("id in #{syllabus_ids} or user_id = #{user.id}").order("updated_at desc")
|
||||||
|
|
||||||
syllabuses.each do |syllabus|
|
syllabuses.each do |syllabus|
|
||||||
syllabus.courses = courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("time desc")
|
tmp_courses = courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc")
|
||||||
|
result[i] = {:title=>syllabus.title, :id=>syllabus.id , :user_id=>syllabus.user_id,:courses=>tmp_courses }
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
# syllabuses.to_a
|
||||||
# syllabuses.to_a << other
|
# syllabuses
|
||||||
|
result
|
||||||
syllabuses.to_a
|
|
||||||
#管理权限 can_setting
|
|
||||||
# syllabuses.each do |s|
|
|
||||||
# s = judge_can_setting(s,user)
|
|
||||||
# end
|
|
||||||
|
|
||||||
syllabuses
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_create_course(course, user)
|
def after_create_course(course, user)
|
||||||
|
@ -72,7 +69,7 @@ class SyllabusesService
|
||||||
if count == 0
|
if count == 0
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
title = "恭喜您创建班级成功。"
|
title = "恭喜您创建班级成功。"
|
||||||
ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情。"
|
ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 1, "点击查看班级详情。"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class UsersService
|
||||||
#id用户id
|
#id用户id
|
||||||
def show_user(params)
|
def show_user(params)
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
img_url = url_to_avatar(@user)
|
img_url = "/images/"+url_to_avatar(@user)
|
||||||
gender = @user.user_extensions.gender.nil? ? 0 : @user.user_extensions.gender
|
gender = @user.user_extensions.gender.nil? ? 0 : @user.user_extensions.gender
|
||||||
work_unit = get_user_work_unit @user
|
work_unit = get_user_work_unit @user
|
||||||
location = get_user_location @user
|
location = get_user_location @user
|
||||||
|
@ -224,7 +224,7 @@ class UsersService
|
||||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||||
course_list = []
|
course_list = []
|
||||||
membership.each do |mp|
|
membership.each do |mp|
|
||||||
course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)}
|
course_list << {:course => mp.course,:img_url => "/images/"+url_to_avatar(mp.course),:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)}
|
||||||
end
|
end
|
||||||
course_list
|
course_list
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,11 +111,17 @@ class WechatService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def two_keys_template(openid, template_id, type, id, first, key1, key2, remark="")
|
def two_keys_template(openid, template_id, type, id, first, key1, key2, remark="",uid)
|
||||||
|
# tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"
|
||||||
|
tmpurl = Wechat.config.auto_openid_url_1+"?id="+id.to_s+Wechat.config.auto_openid_url_2+type+Wechat.config.auto_openid_url_3
|
||||||
|
if uid && uid != 0
|
||||||
|
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"+ "&user_id="+uid.to_s
|
||||||
|
# tmpurl = Wechat.config.auto_openid_url_1+"?id="+id.to_s+ "&user_id="+uid.to_s+Wechat.config.auto_openid_url_2+type+Wechat.config.auto_openid_url_3
|
||||||
|
end
|
||||||
data = {
|
data = {
|
||||||
touser:openid,
|
touser:openid,
|
||||||
template_id:template_id,
|
template_id:template_id,
|
||||||
url:"#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}/#{id}",#/assets/wechat/app.html#/#{type}/#{id}
|
url:tmpurl,#/assets/wechat/app.html#/#{type}/#{id}
|
||||||
topcolor:"#FF0000",
|
topcolor:"#FF0000",
|
||||||
data:{
|
data:{
|
||||||
first: {
|
first: {
|
||||||
|
@ -140,9 +146,11 @@ class WechatService
|
||||||
end
|
end
|
||||||
|
|
||||||
def three_keys_template(openid, template_id, type, id, first, key1, key2, key3, remark="",uid)
|
def three_keys_template(openid, template_id, type, id, first, key1, key2, key3, remark="",uid)
|
||||||
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}/#{id}"
|
# tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"
|
||||||
|
tmpurl = Wechat.config.auto_openid_url_1+"?id="+id.to_s+Wechat.config.auto_openid_url_2+type+Wechat.config.auto_openid_url_3
|
||||||
if uid && uid != 0
|
if uid && uid != 0
|
||||||
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"+ "&user_id="+uid.to_s
|
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"+ "&user_id="+uid.to_s
|
||||||
|
# tmpurl = Wechat.config.auto_openid_url_1+"?id="+id.to_s+ "&user_id="+uid.to_s+Wechat.config.auto_openid_url_2+type+Wechat.config.auto_openid_url_3
|
||||||
end
|
end
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -177,9 +185,11 @@ class WechatService
|
||||||
end
|
end
|
||||||
|
|
||||||
def four_keys_template(openid, template_id, type, id, first, key1, key2, key3, key4, remark="",uid)
|
def four_keys_template(openid, template_id, type, id, first, key1, key2, key3, key4, remark="",uid)
|
||||||
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}/#{id}"
|
# tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"
|
||||||
|
tmpurl = Wechat.config.auto_openid_url_1+"?id="+id.to_s+Wechat.config.auto_openid_url_2+type+Wechat.config.auto_openid_url_3
|
||||||
if uid && uid != 0
|
if uid && uid != 0
|
||||||
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"+ "&user_id="+uid.to_s
|
tmpurl = "#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/#{type}?id=#{id}"+ "&user_id="+uid.to_s
|
||||||
|
# tmpurl = Wechat.config.auto_openid_url_1+"?id="+id.to_s+ "&user_id="+uid.to_s+Wechat.config.auto_openid_url_2+type+Wechat.config.auto_openid_url_3
|
||||||
end
|
end
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -223,7 +233,7 @@ class WechatService
|
||||||
data = {
|
data = {
|
||||||
touser:uw.openid,
|
touser:uw.openid,
|
||||||
template_id:Wechat.config.binding_succ_notice,
|
template_id:Wechat.config.binding_succ_notice,
|
||||||
url:"#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities",
|
url:Wechat.config.auto_openid_url_1+Wechat.config.auto_openid_url_2+"activites"+Wechat.config.auto_openid_url_3,
|
||||||
topcolor:"#FF0000",
|
topcolor:"#FF0000",
|
||||||
data:{
|
data:{
|
||||||
first: {
|
first: {
|
||||||
|
@ -292,13 +302,26 @@ class WechatService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def join_class_notice(user_id, type, id, first, key1, key2, key3,remark="")
|
||||||
|
# uw = UserWechat.where(user_id: user_id).first
|
||||||
|
# unless uw.nil?
|
||||||
|
# data = three_keys_template uw.openid,Wechat.config.join_class_notice, type, id, first, key1, key2, key3, remark
|
||||||
|
# begin
|
||||||
|
# req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||||
|
# rescue Exception => e
|
||||||
|
# Rails.logger.error "[join_class__notice] ===> #{e}"
|
||||||
|
# end
|
||||||
|
# Rails.logger.info "send over. #{req}"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
def create_class_notice(user_id, type, id, first, key1, key2, key3, remark="")
|
def create_class_notice(user_id, type, id, first, key1, key2, key3, remark="")
|
||||||
uw = UserWechat.where(user_id: user_id).first
|
uw = UserWechat.where(user_id: user_id).first
|
||||||
unless uw.nil?
|
unless uw.nil?
|
||||||
data = {
|
data = {
|
||||||
touser:uw.openid,
|
touser:uw.openid,
|
||||||
template_id:Wechat.config.create_class_notice,
|
template_id:Wechat.config.create_class_notice,
|
||||||
url:"#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/class?id="+id.to_s,
|
url:Wechat.config.auto_openid_url_1+"?id="+id.to_s+Wechat.config.auto_openid_url_2+"class"+Wechat.config.auto_openid_url_3,
|
||||||
topcolor:"#FF0000",
|
topcolor:"#FF0000",
|
||||||
data:{
|
data:{
|
||||||
first: {
|
first: {
|
||||||
|
@ -339,7 +362,7 @@ class WechatService
|
||||||
data = {
|
data = {
|
||||||
touser:uw.openid,
|
touser:uw.openid,
|
||||||
template_id:Wechat.config.create_project_notice,
|
template_id:Wechat.config.create_project_notice,
|
||||||
url:"#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/project?id="+id.to_s,
|
url:Wechat.config.auto_openid_url_1+"?id="+id.to_s+Wechat.config.auto_openid_url_2+"project"+Wechat.config.auto_openid_url_3,
|
||||||
topcolor:"#FF0000",
|
topcolor:"#FF0000",
|
||||||
data:{
|
data:{
|
||||||
first: {
|
first: {
|
||||||
|
@ -383,4 +406,19 @@ class WechatService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def join_project_notice(user_id, type, id, first, key1, key2,remark="",uid=0)
|
||||||
|
uw = UserWechat.where(user_id: user_id).first
|
||||||
|
unless uw.nil?
|
||||||
|
data = two_keys_template uw.openid,Wechat.config.join_project_notice, type, id, first, key1, key2,remark,uid
|
||||||
|
begin
|
||||||
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||||
|
rescue Exception => e
|
||||||
|
Rails.logger.error "[join_project_notice] ===> #{e}"
|
||||||
|
end
|
||||||
|
Rails.logger.info "send over. #{req}"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,11 +1,11 @@
|
||||||
[
|
[
|
||||||
<% @users && @users.each_with_index do |person,index| %>
|
<% @users && @users.each_with_index do |person,index| %>
|
||||||
<% if index == 0 %>
|
<% if index == 0 %>
|
||||||
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
|
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
|
||||||
<%= index != @users.size-1 ? ',' : '' %>
|
<%= index != @users.size-1 ? ',' : '' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
{"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
|
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
|
||||||
<%= index != @users.size-1 ? ',' : '' %>
|
<%= index != @users.size-1 ? ',' : '' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
<span>测验时长:<%= exercise.time %>分钟</span>
|
<span>测验时长:<%= exercise.time %>分钟</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<pre class="fontGrey2 font_cus"><%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%></pre>
|
<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;">
|
||||||
|
<%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
|
||||||
|
</pre>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
|
@ -1,19 +1,14 @@
|
||||||
<% curse_attachments.each do |file| %>
|
<% curse_attachments.each do |file| %>
|
||||||
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
|
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
|
||||||
<div id="resource_detail_<%=file.id %>">
|
<div id="resource_detail_<%=file.id %>">
|
||||||
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
|
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
|
||||||
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if curse_attachments.count == 10%>
|
|
||||||
<% if params[:action] == 'search' %>
|
|
||||||
<%=link_to "点击展开更多", search_course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
|
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
|
||||||
<%=link_to "点击展开更多", course_files_path(:course_id => course.id, :page => @page), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
<% end %>
|
||||||
<%end%>
|
<% end %>
|
||||||
<% end%>
|
|
||||||
|
<ul class="wlist">
|
||||||
|
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -66,17 +66,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if project_attachments.count == 10%>
|
<ul class="wlist">
|
||||||
<% if params[:action] == 'search_project' %>
|
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
|
||||||
<!--<ul class="wlist">-->
|
</ul>
|
||||||
<!--<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>-->
|
|
||||||
<!--</ul>-->
|
|
||||||
<%=link_to "点击展开更多", search_project_project_files_path({:project_id => project.id, :page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
|
||||||
<%else%>
|
|
||||||
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
|
|
||||||
<%=link_to "点击展开更多", project_files_path(:project_id => project.id,:page => @page),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
|
|
||||||
<%end%>
|
|
||||||
<% end%>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<% if @course %>
|
<% if @course %>
|
||||||
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments}) %>");
|
||||||
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
<% elsif @project %>
|
<% elsif @project %>
|
||||||
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list', :locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments})%>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>");
|
||||||
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
<% elsif @org_subfield %>
|
<% elsif @org_subfield %>
|
||||||
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/org_subfield_list', :locals => {org_subfield:@org_subfield, all_attachments:@all_attachments, sort:@sort, order:@order, org_subfield_attachments:@obj_attachments})%>");
|
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/org_subfield_list', :locals => {org_subfield:@org_subfield, all_attachments:@all_attachments, sort:@sort, order:@order, org_subfield_attachments:@obj_attachments})%>");
|
||||||
<%end %>
|
<%end %>
|
|
@ -1,6 +1,3 @@
|
||||||
<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> //搜索的时候有时候是需要加载下一页,有时候是直接替换当前 #course_list。这个根据 page来判定
|
|
||||||
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach} )%>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
||||||
<% else %>
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
$("#course_list").html("<%= escape_javascript(render :partial => 'files/course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
|
|
||||||
$("#attachment_count").html("<%= @result.count%>")
|
|
||||||
<% end %>
|
|
||||||
|
|
|
@ -1,7 +1,2 @@
|
||||||
<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> //搜索的时候有时候是需要加载下一页,有时候是直接替换当前 #course_list。这个根据 page来判定
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>");
|
||||||
$("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list',
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
:locals => {project: @project, all_attachments:@result, sort:@sort, order:@order, project_attachments:@searched_attach})%>");
|
|
||||||
<% else %>
|
|
||||||
$("#course_list").html("<%= escape_javascript(render :partial => 'files/project_list',:locals => {project:@project, all_attachments:@result, sort:@sort, order:@order,project_attachments:@searched_attach})%>");
|
|
||||||
$("#attachment_count").html("<%= @project_attachment_result.count %>")
|
|
||||||
<% end %>
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<% if @course %>
|
<% if @course %>
|
||||||
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/course_file',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>");
|
||||||
$("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>");
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
$("#attachment_count").html("<%= @result.count%>")
|
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>");
|
$("#resource_list").html("<%= escape_javascript( render :partial => 'files/project_file',:locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments}) %>");
|
||||||
$("#attachment_count").html("<%= @result_search_project.count%>")
|
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -2,5 +2,5 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_su
|
||||||
showModal('ajax-modal', '513px');
|
showModal('ajax-modal', '513px');
|
||||||
$('#ajax-modal').siblings().remove();
|
$('#ajax-modal').siblings().remove();
|
||||||
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 480px;'><img src='/images/bid/close.png' width='26px' height='26px' /></a>");
|
||||||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
$('#ajax-modal').parent().css("top","30%").css("left","40%").css("border","3px solid #269ac9");
|
||||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
$('#ajax-modal').parent().addClass("popbox_polls");
|
|
@ -3,6 +3,8 @@
|
||||||
<% student_num = studentCount(@course) %>
|
<% student_num = studentCount(@course) %>
|
||||||
<% course_file_num = visable_attachemnts_incourse(@course).count %>
|
<% course_file_num = visable_attachemnts_incourse(@course).count %>
|
||||||
<p class="sy_cgrey mb10">
|
<p class="sy_cgrey mb10">
|
||||||
|
<%= link_to(@course.teacher.show_name, user_path(@course.teacher), :class => 'sy_cgrey') %>
|
||||||
|
>
|
||||||
<% if @course.syllabus %>
|
<% if @course.syllabus %>
|
||||||
<%=link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class => 'sy_cgrey' %>
|
<%=link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class => 'sy_cgrey' %>
|
||||||
>
|
>
|
||||||
|
@ -17,7 +19,9 @@
|
||||||
<ul class="sy_class_setting_text">
|
<ul class="sy_class_setting_text">
|
||||||
<li><%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "sy_class_option" %></li>
|
<li><%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "sy_class_option" %></li>
|
||||||
<li><%= link_to "复制班级", copy_course_course_path(@course.id),:remote=>true, :class => "sy_class_option" %></li>
|
<li><%= link_to "复制班级", copy_course_course_path(@course.id),:remote=>true, :class => "sy_class_option" %></li>
|
||||||
<li><%= link_to "进入课程", syllabus_path(@course.syllabus), :class => "sy_class_option", :target => "_blank" %></li>
|
<% if @course.syllabus %>
|
||||||
|
<li><%= link_to "进入课程", syllabus_path(@course.syllabus), :class => "sy_class_option", :target => "_blank" %></li>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<%= javascript_include_tag "feedback" %>
|
||||||
|
|
||||||
|
<div class="scrollsidebar" id="scrollsidebar">
|
||||||
|
<div class="side_content">
|
||||||
|
<div class="side_list">
|
||||||
|
<div class="side_title">
|
||||||
|
<a title="<%= l(:button_hide) %>" class="close_btn">
|
||||||
|
<span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="side_center">
|
||||||
|
<div class="custom_service">
|
||||||
|
<% get_memo %>
|
||||||
|
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
|
||||||
|
<%= f.text_area :subject, :id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
|
||||||
|
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
|
||||||
|
<label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label>
|
||||||
|
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;height:21px" id="" onclick="">
|
||||||
|
<%= l(:label_submit)%>
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="mt5" style="color: #269ac9;cursor: default">
|
||||||
|
<!--<a target="hiddentab" href="http://wpa.qq.com/msgrd?v=1&uin=1554253403&site=qq&menu=yes" style="color: #269ac9;">-->
|
||||||
|
<%#= l(:label_technical_support) %>
|
||||||
|
<!--白 羽</a> http://shang.qq.com/wpa/qunwpa?idkey=4fe2d63a4527cddce038f04f0b1d728a62082074fb4a74870a5444ee1a6910ad-->
|
||||||
|
<!--<p style="text-align: center"> 请加入师姐师兄答疑群</p> <p style="text-align: center"></p>-->
|
||||||
|
<!--<a href="mqqapi://card/show_pslcard?src_type=internal&version=1&uin=173184401&card_type=group&source=qrcode">QQ群号:173184401</a>-->
|
||||||
|
<a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=fb938b1f6f991fc100f3d32b6ef38b7888dd4097c71d0eb8b239eaa8749a6afd"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="Trustie师姐师兄答疑群" title="Trustie师姐师兄答疑群"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="side_bottom"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="show_btn">
|
||||||
|
<span><%= l(:label_submit)%></span>
|
||||||
|
<a href="javascript:void(0)" class="closeSidebar"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -5,27 +5,27 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</h3>
|
</h3>
|
||||||
<ul class="sy_info mt15" id="all_syllabus_attr">
|
<ul class="sy_info mt15" id="all_syllabus_attr">
|
||||||
<li><label >创建教师</label><span class="fl ml10 sy_cgrey"><%=syllabus.user.show_name %></span></li>
|
<li><label >创建教师</label><span class="fl ml10 sy_cgrey w110"><%=syllabus.user.show_name %></span></li>
|
||||||
<% unless syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == '' %>
|
<% unless syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == '' %>
|
||||||
<li><label>课程性质</label><span class="fl ml10 sy_cgrey"><%=syllabus.syllabus_type_str %></span></li>
|
<li><label>课程性质</label><span class="fl ml10 sy_cgrey w110"><%=syllabus.syllabus_type_str %></span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless syllabus.credit.nil? || syllabus.credit == '' %>
|
<% unless syllabus.credit.nil? || syllabus.credit == '' %>
|
||||||
<li><label>学分</label><span class="fl ml10 sy_cgrey"><%=syllabus.credit %>学分</span></li>
|
<li><label>学分</label><span class="fl ml10 sy_cgrey w110"><%=syllabus.credit %>学分</span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless syllabus.hours.nil? || syllabus.hours == '' %>
|
<% unless syllabus.hours.nil? || syllabus.hours == '' %>
|
||||||
<li><label>总学时</label><span class="fl ml10 sy_cgrey"><%=syllabus.hours %>学时</span></li>
|
<li><label>总学时</label><span class="fl ml10 sy_cgrey w110"><%=syllabus.hours %>学时</span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless syllabus.theory_hours.nil? || syllabus.theory_hours == '' %>
|
<% unless syllabus.theory_hours.nil? || syllabus.theory_hours == '' %>
|
||||||
<li><label>理论学时</label><span class="fl ml10 sy_cgrey"><%=syllabus.theory_hours %>学时</span></li>
|
<li><label>理论学时</label><span class="fl ml10 sy_cgrey w110"><%=syllabus.theory_hours %>学时</span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless syllabus.practice_hours.nil? || syllabus.practice_hours == '' %>
|
<% unless syllabus.practice_hours.nil? || syllabus.practice_hours == '' %>
|
||||||
<li><label>实践学时</label><span class="fl ml10 sy_cgrey"><%=syllabus.practice_hours %>学时</span></li>
|
<li><label>实践学时</label><span class="fl ml10 sy_cgrey w110"><%=syllabus.practice_hours %>学时</span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless syllabus.applicable_major.nil? || syllabus.applicable_major == '' %>
|
<% unless syllabus.applicable_major.nil? || syllabus.applicable_major == '' %>
|
||||||
<li><label>适用专业</label><span class="fl ml10 sy_cgrey"><%=syllabus.applicable_major %></span></li>
|
<li><label>适用专业</label><span class="fl ml10 sy_cgrey w110" style="word-wrap:break-word;"><%=syllabus.applicable_major %></span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless syllabus.pre_course.nil? || syllabus.pre_course == '' %>
|
<% unless syllabus.pre_course.nil? || syllabus.pre_course == '' %>
|
||||||
<li><label>先修课程</label><span class="fl ml10 sy_cgrey"><%=syllabus.pre_course %></span></li>
|
<li><label>先修课程</label><span class="fl ml10 sy_cgrey w110" style="word-wrap:break-word;"><%=syllabus.pre_course %></span></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == '' %>
|
<% if syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == '' %>
|
||||||
|
|
|
@ -82,7 +82,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if all_count > (page.to_i+1) * 10%>
|
<% if all_count > (page.to_i+1) * 10%>
|
||||||
<input type="hidden" value="<%= page%>" id="course_page_num">
|
|
||||||
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_course" onclick="show_more_course('<%= user_courses4show_user_path(user.id,:page => page)%>');">
|
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_course" onclick="show_more_course('<%= user_courses4show_user_path(user.id,:page => page)%>');">
|
||||||
<span class="user_icons_moreclass"></span>
|
<span class="user_icons_moreclass"></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<li>
|
<li>
|
||||||
<span class="user_icons_class"></span>
|
<span class="user_icons_class"></span>
|
||||||
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
|
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
|
||||||
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "course_list_menu hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
|
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "project_list_menu hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
|
||||||
|
|
||||||
<div class="user_navmore_box">
|
<div class="user_navmore_box">
|
||||||
<ul class="<%#= count > 0 ? 'shild shildP':'subNavArrow'%>">
|
<ul class="<%#= count > 0 ? 'shild shildP':'subNavArrow'%>">
|
||||||
|
@ -59,17 +59,16 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if all_count > (page.to_i+1) * 10%>
|
<% if all_count > (page.to_i+1) * 10%>
|
||||||
<input type="hidden" value="<%= page%>" id="project_page_num">
|
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_project" onclick="show_more_project('<%= user_projects4show_user_path(user.id,:page => page)%>');">
|
||||||
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_project" onclick="show_more_project('<%= user_projects4show_user_path(user.id)%>');">
|
|
||||||
<span class="user_icons_moreclass"></span>
|
<span class="user_icons_moreclass"></span>
|
||||||
</a>
|
</a>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var projectcount = <%= @user.projects.visible.count %>;
|
var projectcount = <%= all_count %>;
|
||||||
var projectshowcount = document.getElementsByClassName("course_list_menu").length;
|
var projectshowcount = document.getElementsByClassName("project_list_menu").length;
|
||||||
|
|
||||||
if((projectcount <= projectshowcount)&&(projectcount > 5)){
|
if((projectcount <= projectshowcount)&&(projectcount > 10)){
|
||||||
$("#user_show_more_project").hide();
|
$("#user_show_more_project").hide();
|
||||||
$('#user_hide_project').show();
|
$('#user_hide_project').show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,10 @@
|
||||||
<div class="homepageContent">
|
<div class="homepageContent">
|
||||||
<div class="homepageLeft mt10" id="LSide">
|
<div class="homepageLeft mt10" id="LSide">
|
||||||
<div class="user_leftinfo mb10">
|
<div class="user_leftinfo mb10">
|
||||||
<% if User.current.logged?%>
|
<% if User.current.logged? && User.current == @user%>
|
||||||
<%=link_to image_tag(url_to_avatar(@user),width:"74", height: "74", :id => 'nh_user_tx'), my_clear_user_avatar_temp_path, :class => "user_leftinfo_img", :remote => true%>
|
<%=link_to image_tag(url_to_avatar(@user),width:"74", height: "74", :id => 'nh_user_tx'), my_clear_user_avatar_temp_path, :class => "user_leftinfo_img", :remote => true%>
|
||||||
|
<% elsif User.current.logged? %>
|
||||||
|
<a href="javascript:void(0)" style="cursor: default;" class="user_leftinfo_img"><%=image_tag(url_to_avatar(@user),width:"74", height: "74", :id=>'nh_user_tx') %></a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<img src="images/user/male.jpg" width="74" height="74" />
|
<img src="images/user/male.jpg" width="74" height="74" />
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -175,17 +177,17 @@
|
||||||
</li>
|
</li>
|
||||||
<% if is_current_user %>
|
<% if is_current_user %>
|
||||||
<li id="user_02" class="user_icons_new">
|
<li id="user_02" class="user_icons_new">
|
||||||
<%= link_to "新建课程", new_syllabus_path(:host=> Setting.host_course), :target => "_blank"%>
|
<%= link_to "新建课程", new_syllabus_path(:host=> Setting.host_course), :target => "_blank", :style => "font-size:14px;" %>
|
||||||
</li>
|
</li>
|
||||||
<li id="user_03" class="user_icons_new">
|
<li id="user_03" class="user_icons_new">
|
||||||
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course), :target => "_blank"%>
|
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course), :target => "_blank", :style => "font-size:14px;" %>
|
||||||
</li>
|
</li>
|
||||||
<li id="user_04" class="user_icons_addclass">
|
<li id="user_04" class="user_icons_addclass">
|
||||||
<%= link_to "加入班级",join_private_courses_courses_path,:remote => true, :method => "post"%>
|
<%= link_to "加入班级",join_private_courses_courses_path,:remote => true, :method => "post", :style => "font-size:14px;" %>
|
||||||
</li>
|
</li>
|
||||||
<% if @user == User.current %>
|
<% if @user == User.current %>
|
||||||
<li id="user_05" class="user_icons_myhw">
|
<li id="user_05" class="user_icons_myhw">
|
||||||
<%=link_to '我的作业', my_homeworks_user_path(@user.id), :target => "_blank" %>
|
<%=link_to '我的作业', my_homeworks_user_path(@user.id), :target => "_blank", :style => "font-size:14px;" %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -212,10 +214,10 @@
|
||||||
</li>
|
</li>
|
||||||
<% if is_current_user %>
|
<% if is_current_user %>
|
||||||
<li id="user_07" class="user_icons_new">
|
<li id="user_07" class="user_icons_new">
|
||||||
<%= link_to "新建项目", new_project_path(:host=> Setting.host_name), :target => "_blank"%>
|
<%= link_to "新建项目", new_project_path(:host=> Setting.host_name), :target => "_blank", :style => "font-size:14px;" %>
|
||||||
</li>
|
</li>
|
||||||
<li id="user_08" class="user_icons_addproject">
|
<li id="user_08" class="user_icons_addproject">
|
||||||
<%= link_to "加入项目", applied_join_project_path, :remote => true, :method => "post"%>
|
<%= link_to "加入项目", applied_join_project_path, :remote => true, :method => "post", :style => "font-size:14px;" %>
|
||||||
</li>
|
</li>
|
||||||
<!--<li id="user_09" class="user_icons_myissues">-->
|
<!--<li id="user_09" class="user_icons_myissues">-->
|
||||||
<!--<a href="#user_09" >我的任务</a>-->
|
<!--<a href="#user_09" >我的任务</a>-->
|
||||||
|
@ -328,7 +330,6 @@
|
||||||
for(var i = 10; i < target.length; i++){
|
for(var i = 10; i < target.length; i++){
|
||||||
target.eq(i).slideToggle();
|
target.eq(i).slideToggle();
|
||||||
}
|
}
|
||||||
$('#homepageLeftMenuForge').slideToggle();
|
|
||||||
$('#hide_show_projecticon').toggleClass("user_icons_closeclass");
|
$('#hide_show_projecticon').toggleClass("user_icons_closeclass");
|
||||||
$('#hide_show_projecticon').toggleClass("user_icons_moreclass");
|
$('#hide_show_projecticon').toggleClass("user_icons_moreclass");
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%= render :partial => 'layouts/new_feedback' %>
|
<%= render :partial => 'layouts/forbidden_new_feedback' %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<%= render :partial => 'layouts/footer_show' %>
|
<%= render :partial => 'layouts/footer_show' %>
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li><label class="fl">说明:</label><textarea id = "remarks" class="winbox_textarea fl" placeholder="如果您有特别需要说明的内容请填入"></textarea></li>
|
<li><label class="fl">说明:</label><textarea id = "remarks" class="winbox_textarea fl" placeholder="如果您有特别需要说明的内容请填入"></textarea></li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<li><label class="fl"> </label><button class="fl winbox_btn_blue mt10" onclick = "commit_add_school();">确定</button></li>
|
<li><label class="fl"> </label><button id="apply_school" class="fl winbox_btn_blue mt10">确定</button></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -103,8 +103,9 @@
|
||||||
if(data.result == 0){
|
if(data.result == 0){
|
||||||
$("input[name='province']").val(data.name);
|
$("input[name='province']").val(data.name);
|
||||||
$("input[name='occupation']").val(data.school_id);
|
$("input[name='occupation']").val(data.school_id);
|
||||||
|
|
||||||
var htmlvalue = "</br><div style='width:550px;text-align:center'>添加成功!您可以继续使用了。</div></br><div style='width:550px;text-align:center'>后续我们将对您的高校(单位)进行审核,如有问题我们再联系您。</div></br><div style='width:67px; margin:0 auto; text-align:center'></div>";
|
var htmlvalue = "</br><div style='width:550px;text-align:center'>添加成功!您可以继续使用了。</div></br><div style='width:550px;text-align:center'>后续我们将对您的高校(单位)进行审核,如有问题我们再联系您。</div></br><div style='width:67px; margin:0 auto; text-align:center'></div>";
|
||||||
|
//$('#province').onload();
|
||||||
|
//$('#my_account_form_link').click();
|
||||||
pop_up_box(htmlvalue,500,30,50);
|
pop_up_box(htmlvalue,500,30,50);
|
||||||
}
|
}
|
||||||
else if (data.result == 1){
|
else if (data.result == 1){
|
||||||
|
@ -119,7 +120,32 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function pop_up_box(value,tWidth,tTop,tLeft){
|
||||||
|
|
||||||
|
if(!tWidth){
|
||||||
|
var tWidth = 580;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tTop){
|
||||||
|
var tTop = 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tLeft){
|
||||||
|
var tLeft = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#ajax-modal").html(value);
|
||||||
|
showModal('ajax-modal', tWidth + "px");
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal(); my_account_form_submit();' style='margin-right: 5px; margin-top:-10px;right:0;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", tTop+"%").css("left", tLeft+"%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function hideModal(){
|
||||||
|
$('#ajax-modal').hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
function ifNameRepeat(){
|
function ifNameRepeat(){
|
||||||
|
|
||||||
//名称不能为空也不能重复
|
//名称不能为空也不能重复
|
||||||
|
@ -147,4 +173,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#apply_school').on("click",(function(e){
|
||||||
|
commit_add_school();
|
||||||
|
}));
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
<span id="identity_hint" style="display: none"></span>
|
<span id="identity_hint" style="display: none"></span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;"><%= text_field_tag :lastname,@user.lastname+@user.firstname,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210" %>
|
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;"><%= text_field_tag :lastname,@user.lastname+@user.firstname,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210" %><span id="last_name_notice" class="none c_red">姓名不能为空</span>
|
||||||
|
|
||||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">
|
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">
|
||||||
<% if User.current.user_extensions && User.current.user_extensions.gender && User.current.user_extensions.gender == 1 %>
|
<% if User.current.user_extensions && User.current.user_extensions.gender && User.current.user_extensions.gender == 1 %>
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
<li style="height:auto;"><textarea name="description" class="w450 h200" maxlength="255" style="resize:none;"><%= (@user.user_extensions.nil?) ? '' : @user.user_extensions.description %></textarea></li>
|
<li style="height:auto;"><textarea name="description" class="w450 h200" maxlength="255" style="resize:none;"><%= (@user.user_extensions.nil?) ? '' : @user.user_extensions.description %></textarea></li>
|
||||||
<li style="display:none;"><%= f.select :language, :Chinese => :zh, :English => :en %></li>
|
<li style="display:none;"><%= f.select :language, :Chinese => :zh, :English => :en %></li>
|
||||||
<li class="ml2">
|
<li class="ml2">
|
||||||
<a href="javascript:void(0);" id="my_account_form_link" class="blue_btn fl" style="background: #3b94d6; padding: 0 25px;">确定</a>
|
<a href="javascript:void(0);" id="my_account_form_link" class="blue_btn fl" onclick="my_account_form_submit();" style="background: #3b94d6; padding: 0 25px;">确定</a>
|
||||||
<input type="submit" id="my_account_form_btn" style="display:none;"/>
|
<input type="submit" id="my_account_form_btn" style="display:none;"/>
|
||||||
<!--<a href="javascript:void(0);" class="grey_btn ml10 fl">取消</a>-->
|
<!--<a href="javascript:void(0);" class="grey_btn ml10 fl">取消</a>-->
|
||||||
</li>
|
</li>
|
||||||
|
@ -560,44 +560,80 @@
|
||||||
$("#users_tb_2").click();
|
$("#users_tb_2").click();
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
$('#my_account_form_link').on("click",(function(e){
|
// $('#my_account_form_link').on("click",(function(e){
|
||||||
//$('#my_account_form_link').click(function(e){
|
// //$('#my_account_form_link').click(function(e){
|
||||||
if($("#userIdentity").val() == -1 ) {
|
// if($("#userIdentity").val() == -1 ) {
|
||||||
$("#identity_hint").html('<span style="color:red">请选择身份</span>').show();
|
// $("#identity_hint").html('<span style="color:red">请选择身份</span>').show();
|
||||||
e.stopImmediatePropagation();
|
// e.stopImmediatePropagation();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if( $("input[name='province']").val().trim() != '' && $("input[name='occupation']").val().trim() == ''){ //学校名字和id不对的话
|
// if( $("input[name='province']").val().trim() != '' && $("input[name='occupation']").val().trim() == ''){ //学校名字和id不对的话
|
||||||
$("#hint").html('<span style="color:red">单位名称必须是从下拉列表中选择的,不能手动修改</span>').show();
|
// $("#hint").html('<span style="color:red">单位名称必须是从下拉列表中选择的,不能手动修改</span>').show();
|
||||||
e.stopImmediatePropagation();
|
// e.stopImmediatePropagation();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//姓名不能为空
|
// //姓名不能为空
|
||||||
if( $("#lastname").val() == '' ){
|
// if( $("#lastname").val() == '' ){
|
||||||
$("#lastname").focus();
|
// $("#lastname").focus();
|
||||||
e.stopImmediatePropagation();
|
// $("#last_name_notice").show();
|
||||||
return;
|
// e.stopImmediatePropagation();
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
if( $("input[name='province']").val().trim() == '' ){ //学校名字必须填写
|
//
|
||||||
$("#hint").html('<span style="color:red">高校(单位)名称不能为空</span>').show();
|
// if( $("input[name='province']").val().trim() == '' ){ //学校名字必须填写
|
||||||
e.stopImmediatePropagation();
|
// $("#hint").html('<span style="color:red">高校(单位)名称不能为空</span>').show();
|
||||||
return;
|
// e.stopImmediatePropagation();
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
if($("#no").is(":visible") == true && $("#no").val() == ""){
|
//
|
||||||
$("#no").focus();
|
// if($("#no").is(":visible") == true && $("#no").val() == ""){
|
||||||
e.stopImmediatePropagation();
|
// $("#no").focus();
|
||||||
return;
|
// e.stopImmediatePropagation();
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
$('#my_account_form_btn').click();
|
//
|
||||||
}));
|
// $('#my_account_form').submit();
|
||||||
|
// }));
|
||||||
$('#my_password_form_link').click(function(){
|
$('#my_password_form_link').click(function(){
|
||||||
$('#my_password_form_btn').click();
|
$('#my_password_form_btn').click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function my_account_form_submit(){
|
||||||
|
if($("#userIdentity").val() == -1 ) {
|
||||||
|
$("#identity_hint").html('<span style="color:red">请选择身份</span>').show();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( $("input[name='province']").val().trim() != '' && $("input[name='occupation']").val().trim() == ''){ //学校名字和id不对的话
|
||||||
|
$("#hint").html('<span style="color:red">单位名称必须是从下拉列表中选择的,不能手动修改</span>').show();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//姓名不能为空
|
||||||
|
if( $("#lastname").val() == '' ){
|
||||||
|
$("#lastname").focus();
|
||||||
|
$("#last_name_notice").show();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $("input[name='province']").val().trim() == '' ){ //学校名字必须填写
|
||||||
|
$("#hint").html('<span style="color:red">高校(单位)名称不能为空</span>').show();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($("#no").is(":visible") == true && $("#no").val() == ""){
|
||||||
|
$("#no").focus();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#my_account_form').submit();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function g(o){return document.getElementById(o);}
|
function g(o){return document.getElementById(o);}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||||
<label><span class="c_red">*</span> <%= l(:label_projects_new_name)%> :</label>
|
<label><span class="c_red">*</span> <%= l(:label_projects_new_name)%> :</label>
|
||||||
<input type="text" name="project[name]" id="project_name" class="courses_input" maxlength="100" onkeyup="regex_project_name();">
|
<input type="text" name="project[name]" id="project_name" class="courses_input" maxlength="100" placeholder="例如:团队协作方法与机制研究" onkeyup="regex_project_name();">
|
||||||
<span class="c_red" id="project_name_notice" style="display: none;">项目名称不能为空</span>
|
<span class="c_red" id="project_name_notice" style="display: none;">项目名称不能为空</span>
|
||||||
</li>
|
</li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
<% if @forked_project.nil? %>
|
<% if @forked_project.nil? %>
|
||||||
<%= select_tag :branch, options_for_select(@source_rev), :id => "pull_request_branch", :name => "target_branch", :value => "target_branch",:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
|
<%= select_tag :branch, options_for_select(@source_rev), :id => "pull_request_branch", :name => "target_branch", :value => "target_branch",:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
|
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" id="pull_request_project" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
|
||||||
<option value="source_project_name"><%= @source_project_name %></option>
|
<option name="<%= @project.id %>" value="source_project_name" ><%= @source_project_name %></option>
|
||||||
<option value="forked_project_name"><%= @forked_project_name %></option>
|
<option name="<%= @forked_project.id %>" value="forked_project_name" ><%= @forked_project_name %></option>
|
||||||
</select>
|
</select>
|
||||||
<select name="target_branch" id="pull_request_branch" class = "ml30 fontGrey3 fb fl" style = "width:140px; padding:5px 0 5px 5px;">
|
<select name="target_branch" id="pull_request_branch" class = "ml30 fontGrey3 fb fl" style = "width:140px; padding:5px 0 5px 5px;">
|
||||||
<% @source_rev.each do |rev| %>
|
<% @source_rev.each do |rev| %>
|
||||||
|
@ -25,8 +25,9 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<p id="pull_request_project_hidden" style="display: none"><%= @forked_project.nil? ? "" : @project.id %></p>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<p id ="pull_request_branch_error" class="ml100 fontGrey2 mt5 c_red" style="display: none">同一个项目的源分支和目标分支不能相同</p>
|
<p id ="pull_request_branch_error" class="ml100 fontGrey2 mt5 c_red" style="display: none">没有内容可以合并,请切换一个不同的分支</p>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
|
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
|
||||||
|
@ -56,7 +57,9 @@
|
||||||
{
|
{
|
||||||
var source_branch = $.trim($("#source_branch").val());
|
var source_branch = $.trim($("#source_branch").val());
|
||||||
var target_branch = $.trim($("#pull_request_branch").val());
|
var target_branch = $.trim($("#pull_request_branch").val());
|
||||||
if(source_branch == target_branch)
|
var target_project = $.trim($("#pull_request_project").children().attr("name"));
|
||||||
|
var target_forked_project = $.trim($("#pull_request_project_hidden").text());
|
||||||
|
if(target_project == target_forked_project && source_branch == target_branch)
|
||||||
{
|
{
|
||||||
$("#pull_request_branch_error").show();
|
$("#pull_request_branch_error").show();
|
||||||
return false;
|
return false;
|
||||||
|
@ -71,7 +74,7 @@
|
||||||
//提交pull request
|
//提交pull request
|
||||||
function pull_request_commit()
|
function pull_request_commit()
|
||||||
{
|
{
|
||||||
if(regex_pr_name())
|
if(regex_pr_name() && regex_branch())
|
||||||
{
|
{
|
||||||
$("#pull_request_form").submit();
|
$("#pull_request_form").submit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<% unless @changes.blank? %>
|
<% if !@changes.blank? && @type == "3" %>
|
||||||
<% @changes.each do |cd| %>
|
<% @changes.each do |cd| %>
|
||||||
<div class="showing-changes-row fontGrey2" style="width:710px;">
|
<div class="showing-changes-row fontGrey2" style="width:710px;">
|
||||||
<a class="linkGrey3" id="changed-files">
|
<a class="linkGrey3" id="changed-files">
|
||||||
|
@ -29,5 +29,13 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<div class="merge-discussion-input">
|
||||||
|
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create_pull_request_comment', :project_id => @project.id), :id => 'pull_request_comment_form', :method => "post", :remote => true) do %>
|
||||||
|
<textarea id="pull_request_comment" name="pull_request_comment"></textarea>
|
||||||
|
<span id ="pr_comment_tip" class="fontGrey2 c_red" style="display: none">内容不能为空</span>
|
||||||
|
<a href="javascript:void(0);" class="BlueCirBtn mt10" onclick="pull_request_commit()">留言</a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% @comments.each do |comment| %>
|
||||||
|
<div class="merge-discussion-content merge-discussion-automatic">
|
||||||
|
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %>
|
||||||
|
<span class="fl fontGrey2"><%= time_tag(comment.created_at) %>前</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="merge-discussion-detail"><%= comment.note %></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function regex_pr_comment()
|
||||||
|
{
|
||||||
|
var comment = $.trim($("#pull_request_comment").val());
|
||||||
|
if(comment.length == 0)
|
||||||
|
{
|
||||||
|
$("#pr_comment_tip").show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#pr_comment_tip").hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//提交pull request_comment
|
||||||
|
function pull_request_commit()
|
||||||
|
{
|
||||||
|
if(regex_pr_comment())
|
||||||
|
{
|
||||||
|
$("#pull_request_comment_form").submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,19 +1,32 @@
|
||||||
<% @commits.each do |commit| %>
|
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
|
||||||
<div class="new-merge-wrap">
|
<% if !@commits.blank? && @type == "2" %>
|
||||||
<div class="merge-commit-time">
|
<% @commits.each do |commit| %>
|
||||||
<img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span>
|
<div class="new-merge-wrap">
|
||||||
<!--<p class="mt10 fontGrey2">1次提交</p>-->
|
<div class="merge-commit-time">
|
||||||
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %>创建于<%= time_tag(commit.created_at) %>前</p>
|
<img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span>
|
||||||
</div>
|
<!--<p class="mt10 fontGrey2">1次提交</p>-->
|
||||||
<div class="merge-commit-detail">
|
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前</p>
|
||||||
<span class="fontGrey3 fb"><%= commit.title %></span>
|
</div>
|
||||||
|
<div class="merge-commit-detail">
|
||||||
|
<span class="fontGrey3 fb"><%= commit.title %></span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="merge-commit-code">
|
<div class="merge-commit-code">
|
||||||
<span class="fontGrey3">
|
<span class="fontGrey3">
|
||||||
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
|
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<% @requests.each do |request| %>
|
<% @requests.each do |request| %>
|
||||||
<li>
|
<li>
|
||||||
<% request %>
|
<% request %>
|
||||||
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
|
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl hidden", :style => "width:100%;"%>
|
||||||
<!--<a href="javascript:void(0);" class="fr fontGrey2 fb"><img src="/images/comments.png" class="mr5" width="15" />0</a><span class="fr mr15 fb fontGrey2">关闭</span>-->
|
<!--<a href="javascript:void(0);" class="fr fontGrey2 fb"><img src="/images/comments.png" class="mr5" width="15" />0</a><span class="fr mr15 fb fontGrey2">关闭</span>-->
|
||||||
<div class="cl mb5"></div>
|
<div class="cl mb5"></div>
|
||||||
<span class="fontGrey2">由 <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %></span>
|
<span class="fontGrey2">由 <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %></span>
|
||||||
|
@ -12,4 +12,13 @@
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
|
@ -4,14 +4,17 @@
|
||||||
|
|
||||||
<div id="pull_request_show">
|
<div id="pull_request_show">
|
||||||
<div id="mergeShow" class="f14 fontGrey2 merge-show">
|
<div id="mergeShow" class="f14 fontGrey2 merge-show">
|
||||||
<span class="mr10 open-status"><%= @request.state == "merged" ? "已合并" : "待处理" %></span><span class="mr10">合并请求</span> 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %>
|
<span class="mr10 open-status"><%= get_state(@request.state) %></span><span class="mr10">合并请求</span> 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 前提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %> 前
|
||||||
<!--<a href="javascript:void(0);" class="BlueCirBtnMini fr mt5">编辑</a>-->
|
<% unless @request.state == "merged" %>
|
||||||
|
<%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %>
|
||||||
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
|
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
|
||||||
<div class="mt10 mb15">
|
|
||||||
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
|
|
||||||
|
|
||||||
|
<div class="mt10 mb15">
|
||||||
|
<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>
|
||||||
|
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
|
||||||
<% if @commits_count == 0 && @changes_count == 0 %>
|
<% if @commits_count == 0 && @changes_count == 0 %>
|
||||||
<div class="merge-commit-option mt15">
|
<div class="merge-commit-option mt15">
|
||||||
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
|
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
|
||||||
|
@ -21,29 +24,42 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @request.state == "merged" %>
|
<% if @request.state == "merged" %>
|
||||||
<div class="merge-commit-option mt15">
|
<div class="merge-commit-option mt15">
|
||||||
<span class="fontGrey3 fb" style="font-size:13px;"><%#= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %> 前合并</span><br />
|
<% if accept_user(@request.id).blank? %>
|
||||||
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
|
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
|
||||||
|
<% else %>
|
||||||
|
<span class="fontGrey3 fb" style="font-size:13px;"><%= link_to User.find(accept_user(@request.id).user_id), user_path(accept_user(@request.id).user_id), :class => "link-blue" %> 于 <%= time_tag(accept_user(@request.id).created_at) %> 前合并</span><br />
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if is_project_manager?(User.current.id, @project.id) %>
|
<% if is_project_manager?(User.current.id, @project.id) %>
|
||||||
<div class="merge-commit-option mt15">
|
<div class="merge-commit-option mt15">
|
||||||
<%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn", :remote => true %>
|
<% if @request.state == "closed" %>
|
||||||
|
该请求已被关闭
|
||||||
|
<% else %>
|
||||||
|
<%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn", :remote => true %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="merge-record" style="border-top:1px solid #ddd;">
|
<ul class="merge-record" style="border-top:1px solid #ddd;">
|
||||||
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
|
<li><%= link_to "留言<span class='project-number-dot'>#{@comments_count}</span>".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id, :type => "1"), :remote => true, :class => "active" %></li>
|
||||||
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
|
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => "2"), :remote => true %></li>
|
||||||
|
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => "3"), :remote => true %></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
|
<% if @type == nil || @type == "1" %>
|
||||||
<div id="merge_record_0">
|
<div id="merge_record_0">
|
||||||
|
<%= render :partial => "pull_requests/pull_request_comments" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div id="merge_record_1" class="undis">
|
||||||
<%= render :partial => "pull_requests/pull_request_commits" %>
|
<%= render :partial => "pull_requests/pull_request_commits" %>
|
||||||
</div>
|
</div>
|
||||||
<div id="merge_record_1" class="undis">
|
<div id="merge_record_2" class="undis">
|
||||||
<%= render :partial => "pull_requests/pull_request_changes" %>
|
<%= render :partial => "pull_requests/pull_request_changes" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -51,19 +67,13 @@
|
||||||
<script>
|
<script>
|
||||||
$("#pull_request_show").parent().css("width","730px");
|
$("#pull_request_show").parent().css("width","730px");
|
||||||
|
|
||||||
$("#changed-files").toggle(function(){
|
|
||||||
$("#changed-files-detail").show();
|
|
||||||
},function(){
|
|
||||||
$("#changed-files-detail").hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".merge-record li a").click(function(){
|
$(".merge-record li a").click(function(){
|
||||||
$(".merge-record li a").removeClass("active");
|
$(".merge-record li a").removeClass("active");
|
||||||
$(this).addClass("active");
|
$(this).addClass("active");
|
||||||
|
|
||||||
var index = $(".merge-record li a").index(this);
|
var index = $(".merge-record li a").index(this);
|
||||||
|
|
||||||
$("#merge_record_0, #merge_record_1").hide();
|
$("#merge_record_0, #merge_record_1, #merge_record_2").hide();
|
||||||
$("#merge_record_" + index).show();
|
$("#merge_record_" + index).show();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
|
@ -2,6 +2,7 @@
|
||||||
<ul id="mergeBanner" class="project-merge-banner">
|
<ul id="mergeBanner" class="project-merge-banner">
|
||||||
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
|
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
|
||||||
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
|
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
|
||||||
|
<li><%= link_to "已关闭<span class='project-number-dot'>#{@requests_closed_count}</span>".html_safe, project_pull_requests_path(:type => "3"), :remote => true %></li>
|
||||||
|
|
||||||
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
|
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
<%= render "pull_requests/pull_requests_list" %>
|
<%= render "pull_requests/pull_requests_list" %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$("#mergeBanner").parent().css("width","730px");
|
$("#mergeBanner").parent().css("width","730px");
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');
|
$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes") %>');
|
|
@ -0,0 +1 @@
|
||||||
|
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_comments") %>');
|
|
@ -1 +1 @@
|
||||||
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>');
|
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits") %>');
|
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb10">
|
<div class="mb10">
|
||||||
<div>
|
<div>
|
||||||
<%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"], "#{@quality_analysis.language}"), :id => 'branch', :class => "analysis-option-box" %>
|
<%= select_tag :language, options_for_select(["java","python","c#"], "#{@quality_analysis.language}"), :id => 'branch', :class => "analysis-option-box" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#quality_analyses_edit_form').submit();hideModal()">提交</a></div>
|
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#quality_analyses_edit_form').submit();hideModal()">提交</a></div>
|
||||||
|
|
|
@ -10,22 +10,23 @@
|
||||||
<li class="analysis-result-version fl fontBlue2" >分支</li>
|
<li class="analysis-result-version fl fontBlue2" >分支</li>
|
||||||
<li class="analysis-result-loc fl fontBlue2" >语言</li>
|
<li class="analysis-result-loc fl fontBlue2" >语言</li>
|
||||||
<li class="analysis-result-debt fl fontBlue2" >路径</li>
|
<li class="analysis-result-debt fl fontBlue2" >路径</li>
|
||||||
<li class="analysis-result-time fl fontBlue2" ></li>
|
<li class="analysis-result-time fl fontBlue2" >最近更新</li>
|
||||||
<!--<li class="analysis-result-time fl fontBlue2" >bianji</li>-->
|
<li class="analysis-result-edit fl fontBlue2" ></li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</ul>
|
</ul>
|
||||||
<% if @quality_analyses.count >0 %>
|
<% if @quality_analyses && @quality_analyses.count >0 %>
|
||||||
<% @quality_analyses.each do |qa| %>
|
<% @quality_analyses.each do |qa| %>
|
||||||
<ul class="analysis-result-list">
|
<ul class="analysis-result-list">
|
||||||
<li title="Name" title="名称"><%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></li>
|
<li title="<%= qa.author_login+ ':' +qa.rep_identifier %>"><%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></li>
|
||||||
<li class="analysis-result-version fl fontBlue2 hidden" title="分支名"><%= qa.branch %></li>
|
<li class="analysis-result-version fl fontBlue2 hidden" title="<%= qa.branch %>"><%= qa.branch %></li>
|
||||||
<li class="analysis-result-loc fl fontBlue2 hidden" title="语言"><%= qa.language %></li>
|
<li class="analysis-result-loc fl fontBlue2 hidden" title="<%= qa.language %>"><%= qa.language %></li>
|
||||||
<li class="analysis-result-debt fl fontBlue2 hidden" title="路径"><%= qa.path %></li>
|
<li class="analysis-result-debt fl fontBlue2 hidden" title="<%= qa.path %>"><%= qa.path %></li>
|
||||||
|
<li class="analysis-result-time fl fontBlue2 hidden" title="<%= sonar_time(qa.sonar_name).blank? ? qa.created_at : sonar_time(qa.sonar_name) %>"><%= format_time(sonar_time(qa.sonar_name).blank? ? qa.created_at : sonar_time(qa.sonar_name)) %></li>
|
||||||
<% if User.current.try(:login) == qa.author_login || User.current.admin? || is_project_manager?(User.current.id, @project.id) %>
|
<% if User.current.try(:login) == qa.author_login || User.current.admin? || is_project_manager?(User.current.id, @project.id) %>
|
||||||
<li class="analysis-result-time fl" title="编辑">
|
<li class="analysis-result-edit fl fontBlue2 hidden" title="<%= qa.path %>">
|
||||||
<%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %><span style="color: #888"> / </span>
|
<%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %><span style="color: #888"> / </span>
|
||||||
<%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %>
|
<%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<div class="project_r_h">
|
<div class="project_r_h">
|
||||||
<h2 class="project_h2" style="width:180px;">质量分析</h2>
|
<h2 class="project_h2" style="width:180px;">质量分析</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="button-rep">当前分支:<%= params[:branch] %></div>
|
<div class="button-rep">当前分支:<%= params[:branch] %></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="tac f20 fb mt35 mb30">项目代码质量分析报告</div>
|
<div class="tac f20 fb mt35 mb30">项目代码质量分析报告</div>
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
<div class="analysis-genral">
|
<div class="analysis-genral">
|
||||||
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
|
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
|
||||||
<p class="fontGrey3">质量等级</p>
|
<p class="fontGrey3">质量等级</p>
|
||||||
<p class="fontBlue2 pr"><%= @ha["sqale_rating"] %>
|
<p class="fontBlue2 pr"><%= sqale_rating_status(@ha["sqale_rating"].to_i)[2] %>
|
||||||
<span class="f10 c_white analysis-genral-icon <%= sqale_rating_status(@ha["sqale_rating"].to_i)[1] %> borderRadius">
|
<span class="f10 c_white analysis-genral-icon <%= sqale_rating_status(@ha["sqale_rating"].to_i)[1] %> borderRadius">
|
||||||
<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %>
|
<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
<div class="c_red">本次分析失败,原因如下:</div>
|
<div class="c_red">本次分析失败,原因如下:</div>
|
||||||
<% if @build_console_result == false %>
|
<% if @build_console_result == false %>
|
||||||
分析超时
|
分析超时
|
||||||
|
<% elsif params[:message] %>
|
||||||
|
<%= params[:message] %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= h @error_list.try(:output).html_safe %>
|
<%= h @error_list.try(:output).html_safe %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -26,19 +26,19 @@
|
||||||
</td>
|
</td>
|
||||||
<div id="children_tree">
|
<div id="children_tree">
|
||||||
<td class="tree-comments c_grey hidden">
|
<td class="tree-comments c_grey hidden">
|
||||||
<div class="hidden" title="<%= (latest_changes.message) if latest_changes && latest_changes.message %>">
|
<div class="hidden" title="<%= (latest_changes.message) if latest_changes %>">
|
||||||
<%= (latest_changes.message) if latest_changes && latest_changes.message %>
|
<%= (latest_changes.message) if latest_changes %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="tree-author c_grey">
|
<td class="tree-author c_grey">
|
||||||
<div class="hidden" title="<%= (latest_changes.author) if latest_changes && latest_changes.author %>">
|
<div class="hidden" title="<%= (latest_changes.author_name) if latest_changes %>">
|
||||||
<%= (latest_changes.author) if latest_changes && latest_changes.author %>
|
<%= (latest_changes.author_name) if latest_changes %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="tree-age c_grey">
|
<td class="tree-age c_grey">
|
||||||
<div class="hidden" title="<%= format_time(latest_changes.time) %>">
|
<div class="hidden" title="<%= format_time(latest_changes.time) if latest_changes %>">
|
||||||
<%# 为了转换UTC时间,时差8小时 %>
|
<%# 为了转换UTC时间,时差8小时 %>
|
||||||
<%= distance_of_time_in_words(latest_changes.time, Time.now + 8.hours) if latest_changes && latest_changes.time %>
|
<%= distance_of_time_in_words(latest_changes.time, Time.now) if latest_changes %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb10">
|
<div class="mb10">
|
||||||
<div>
|
<div>
|
||||||
<%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %>
|
<%= select_tag :language, options_for_select(["java","python","c#"]), :id => 'branch', :class => "analysis-option-box" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-indicator').css('opacity','0.8').text('正在分析中…………(大概需要30分钟,请耐心等待)').show();$('#quality_analyses_form').submit();hideModal()">提交</a></div>
|
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="$('#ajax-indicator').css('opacity','0.8').text('正在分析中…………(大概需要30分钟,请耐心等待)').show();$('#quality_analyses_form').submit();hideModal()">提交</a></div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<span class="c_dark f14 fb fl mr15">
|
<span class="c_dark f14 fb fl mr15">
|
||||||
作品
|
作品
|
||||||
<font class="f12 c_red">
|
<font class="f12 c_red">
|
||||||
(<%= @student_work_count%>人已交)
|
(<span id="student_work_count"><%= @student_work_count%></span>人已交)
|
||||||
</font>
|
</font>
|
||||||
<%# my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
|
<%# my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
|
||||||
<% my_work = cur_user_works_for_homework @homework %>
|
<% my_work = cur_user_works_for_homework @homework %>
|
||||||
|
|
|
@ -17,3 +17,5 @@ $("#score_list_<%= @work.id%>").removeAttr("style");
|
||||||
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work, :index => 1}) %>");
|
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work, :index => 1}) %>");
|
||||||
$("#work_num_<%= @work.id%>").html(num);
|
$("#work_num_<%= @work.id%>").html(num);
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
||||||
|
$("#student_work_count").html("<%=@count %>");
|
||||||
|
|
|
@ -31,9 +31,11 @@
|
||||||
|
|
||||||
<div class="HomeWorkCon mt15" nhname='student_work_form'>
|
<div class="HomeWorkCon mt15" nhname='student_work_form'>
|
||||||
<%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
|
<%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
|
||||||
<div class=" c_red mb10">
|
<% if @homework.anonymous_comment == 0 %>
|
||||||
提示:作品名称和描述中不要出现真实的姓名信息
|
<div class=" c_red mb10">
|
||||||
</div>
|
提示:作品名称和描述中不要出现真实的姓名信息
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% if @homework.homework_type == 3 %>
|
<% if @homework.homework_type == 3 %>
|
||||||
<span id="min_num_member" style="display: none"><%=@homework.homework_detail_group.min_num %></span>
|
<span id="min_num_member" style="display: none"><%=@homework.homework_detail_group.min_num %></span>
|
||||||
|
|
|
@ -235,9 +235,11 @@
|
||||||
:action => 'create',
|
:action => 'create',
|
||||||
:homework => @homework.id
|
:homework => @homework.id
|
||||||
},:remote=>true ) do |f| %>
|
},:remote=>true ) do |f| %>
|
||||||
<div class=" c_red mb10">
|
<% if @homework.anonymous_comment == 0 %>
|
||||||
提示:作品名称和描述中不要出现真实的姓名信息
|
<div class=" c_red mb10">
|
||||||
</div>
|
提示:作品名称和描述中不要出现真实的姓名信息
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% if @homework.homework_type == 3 %>
|
<% if @homework.homework_type == 3 %>
|
||||||
<span id="min_num_member" style="display: none"><%=@homework.homework_detail_group.min_num %></span>
|
<span id="min_num_member" style="display: none"><%=@homework.homework_detail_group.min_num %></span>
|
||||||
|
|
|
@ -135,9 +135,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% if activity.student_works.has_committed.count != 0 %>
|
<% if activity.student_works.has_committed.count != 0 %>
|
||||||
<% sw = activity.student_works.has_committed.reorder("created_at desc").first %>
|
<% sw = activity.student_works.has_committed.reorder("commit_time desc").first %>
|
||||||
<div class="mt10 homepagePostDeadline mb10">
|
<div class="mt10 homepagePostDeadline mb10">
|
||||||
# <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
|
# <%=time_from_now sw.commit_time %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="hw_popup_box">
|
<div class="hw_popup_box" style="padding-bottom:30px;">
|
||||||
<div class="hw_popup_top clear">
|
<div class="hw_popup_top clear">
|
||||||
<a href="javascript:void(0);" class="hw_icons_close fr" style="outline: none;" onclick="hideModal()"></a>
|
<a href="javascript:void(0);" class="hw_icons_close fr" style="outline: none;" onclick="hideModal()"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div id="user_join_projects_list">
|
||||||
|
<%= render :partial => 'users/project_list', :locals => {:projects => @my_joined_projects, :list_type => 2, :count => @my_joined_projects_count}%>
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div id="user_projects_list">
|
||||||
|
<%= render :partial => 'users/project_list', :locals => {:projects => @my_projects, :list_type => 1, :count => @my_projects_count}%>
|
||||||
|
</div>
|
|
@ -0,0 +1,63 @@
|
||||||
|
<div class="syllabus_category">
|
||||||
|
<% unless projects.empty? %>
|
||||||
|
<% if @type.to_i == 2 %>
|
||||||
|
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to "人气", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %>
|
||||||
|
<% if @type.to_i == 1 %>
|
||||||
|
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortdownbtn sort_no fr", :remote => true %>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to "时间", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt fr", :remote => true %>
|
||||||
|
<% end %>
|
||||||
|
<span class="grayTxt fl "><%=@user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "参与"%>的项目</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="syllabus_courses_box" id="project_li_<%=list_type %>">
|
||||||
|
<% if projects.empty? %>
|
||||||
|
<div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||||
|
<% if list_type == 1 %>
|
||||||
|
<p class="sy_tab_con_p"><%=@user == User.current ? "您" : "他" %>还没有创建项目~~<br />
|
||||||
|
<%= link_to "创建项目", new_project_path(:host=> Setting.host_name), :target => "_blank", :class => "sy_btn_green ml5 mt5" if @user == User.current %>
|
||||||
|
</p>
|
||||||
|
<% else %>
|
||||||
|
<p class="sy_tab_con_p"><%=@user == User.current ? "您" : "他" %>还没有加入项目~~<br />
|
||||||
|
<%= link_to "加入项目", applied_join_project_path, :remote => true, :method => "post", :class => "sy_btn_green ml5 mt5" if @user == User.current %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% projects.each_with_index do |project, i| %>
|
||||||
|
<div class="syllabus_courses_list <%= i > 4 ? 'none' : ''%>" style="cursor: default;">
|
||||||
|
<div class="sy_courses_open">
|
||||||
|
<span class="icons_project_list fl mt5 mr10"></span>
|
||||||
|
<h3><%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
|
||||||
|
<% unless project.is_public? %>
|
||||||
|
<span class="hw_icon_private fl"></span>
|
||||||
|
<% end %>
|
||||||
|
<% projectUser = User.where("id=?",project.user_id).first %>
|
||||||
|
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="fl sy_p_grey">更新时间:<%= format_date(project.updatetime) %></p>
|
||||||
|
<div class=" fr">
|
||||||
|
<p class="list-info fr grayTxt">
|
||||||
|
<%= link_to project.members.count, member_project_path(project), :class => "c_blue" %><span class="mr5">成员 |</span>
|
||||||
|
<%= link_to project.project_score.issue_num, project_issues_path(project), :class => "c_blue" %><span class="mr5">问题 |</span>
|
||||||
|
<%= link_to project.project_score.attach_num, project_files_path(project), :class => "c_blue" %><span class="mr5">资源</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if count > 5 %>
|
||||||
|
<div class="syllabus_courses_list">
|
||||||
|
<p class="new_projectlist_more"><a id="project_more_<%=list_type %>" href="javascript:void(0);" data-count="<%= count %>" data-init="0" onclick="expand_projects('#project_more_<%=list_type %>', '#project_li_<%=list_type %>', <%=count%>);">共<%=count %>个项目,点击全部展开</a></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div><!--syllabus_courses_box end-->
|
|
@ -29,7 +29,7 @@
|
||||||
发帖时间:<%= format_time(activity.created_on) %>
|
发帖时间:<%= format_time(activity.created_on) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="homepagePostDate fl ml15">
|
<div class="homepagePostDate fl ml15">
|
||||||
更新时间:<%= get_forge_act_message(activity, activity.class) %>
|
更新时间:<%= get_forge_act_message(activity, activity.class.to_s) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% if activity.parent_id.nil? %>
|
<% if activity.parent_id.nil? %>
|
||||||
|
|
|
@ -24,11 +24,4 @@
|
||||||
<div class="courseSendCancel">
|
<div class="courseSendCancel">
|
||||||
<a href="javascript:void(0);" class="sendSourceText linkGrey6" id="cancel_group">取消</a>
|
<a href="javascript:void(0);" class="sendSourceText linkGrey6" id="cancel_group">取消</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<script type="text/javascript">
|
|
||||||
$(function(){
|
|
||||||
if($.trim($("#base_on_project").val()) == 1) {
|
|
||||||
$("#base_on_project").attr('checked','checked');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -146,9 +146,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% if homework_common.student_works.has_committed.count != 0 %>
|
<% if homework_common.student_works.has_committed.count != 0 %>
|
||||||
<% sw = homework_common.student_works.has_committed.reorder("created_at desc").first %>
|
<% sw = homework_common.student_works.has_committed.reorder("commit_time desc").first %>
|
||||||
<div class="mt10 homepagePostDeadline mb10">
|
<div class="mt10 homepagePostDeadline mb10">
|
||||||
# <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
|
# <%=time_from_now sw.commit_time %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -302,7 +302,7 @@
|
||||||
|
|
||||||
<% count=homework_common.journals_for_messages.count %>
|
<% count=homework_common.journals_for_messages.count %>
|
||||||
<div class="homepagePostReply">
|
<div class="homepagePostReply">
|
||||||
<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => homework_common, :user_activity_id => -1, :is_in_course => is_in_course,:course_activity=>-1} %>
|
<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => homework_common, :user_activity_id => homework_common.id, :is_in_course => is_in_course,:course_activity=>-1} %>
|
||||||
|
|
||||||
<% comments = homework_common.journals_for_messages.reorder("created_on desc").limit(3) %>
|
<% comments = homework_common.journals_for_messages.reorder("created_on desc").limit(3) %>
|
||||||
<% if count > 0 %>
|
<% if count > 0 %>
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
} else {
|
} else {
|
||||||
$("#anonymous_comment").attr('checked',false);
|
$("#anonymous_comment").attr('checked',false);
|
||||||
}
|
}
|
||||||
|
if($.trim($("#base_on_project").val()) == 1) {
|
||||||
|
$("#base_on_project").attr('checked','checked');
|
||||||
|
}
|
||||||
<% if edit_mode && homework.is_program_homework? %>
|
<% if edit_mode && homework.is_program_homework? %>
|
||||||
$("#BluePopupBox a.BlueCirBtn").click();
|
$("#BluePopupBox a.BlueCirBtn").click();
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -601,7 +601,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p>申请班级:<%= Course.find(ma.course_id).name%></p>
|
<p>申请班级:<%= Course.find(ma.course_id).name%></p>
|
||||||
<div class="fl">班级描述:</div>
|
<div class="fl">班级描述:</div>
|
||||||
<div class="ml60"><%= Course.find(ma.course_id).description.html_safe %></div>
|
<div class="ml60"><%= Course.find(ma.course_id).description.nil? ? "" : Course.find(ma.course_id).description.html_safe %></div>
|
||||||
<p>申请职位:<%= ma.content == '9' ? "教师" : "教辅"%></p>
|
<p>申请职位:<%= ma.content == '9' ? "教师" : "教辅"%></p>
|
||||||
</div>
|
</div>
|
||||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||||
|
|
|
@ -1,3 +1,86 @@
|
||||||
|
<div class="syllabus_box">
|
||||||
|
<h2 class="syllabus_h2_top"><span class="icon_course fl mt7 mr5"></span>项目列表</h2>
|
||||||
|
<div class="syllabus_category">
|
||||||
|
<a class="sortdownbtn sort_no fr"></a><a href="#" class="sortTxt fr">人气</a>
|
||||||
|
<a class="sortupbtn fr"></a><a href="#" class="sortTxt fr ">时间</a>
|
||||||
|
<span class="grayTxt fl ">我创建的项目</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="syllabus_courses_box">
|
||||||
|
<% @projects.each do |project|%>
|
||||||
|
<div class="syllabus_courses_list" style="cursor: default">
|
||||||
|
<div class="sy_courses_open">
|
||||||
|
<span class="icons_project_list fl mt5 mr10"></span>
|
||||||
|
<h3><%= link_to "#{project.name}", project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
|
||||||
|
<% unless project.is_public? %>
|
||||||
|
<span class="hw_icon_private fl"></span>
|
||||||
|
<% end %>
|
||||||
|
<% projectUser = User.where("id=?",project.user_id).first %>
|
||||||
|
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="fl sy_p_grey">更新时间:<%= format_date(project.updated_on) %></p>
|
||||||
|
<div class=" fr">
|
||||||
|
<p class="list-info fr grayTxt">
|
||||||
|
<%= link_to project.members.count, member_project_path(project), :class => "c_blue" %><span class="mr5">成员 |</span>
|
||||||
|
<%= link_to project.project_score.issue_num, project_issues_path(project), :class => "c_blue" %><span class="mr5">问题 |</span>
|
||||||
|
<%= link_to project.project_score.attach_num, file_project_path(project), :class => "c_blue" %><span class="mr5">资源</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="syllabus_courses_list ">
|
||||||
|
<p class="new_projectlist_more"><a href="javascript:void(0);" >共100个项目,点击全部展开</a></p>
|
||||||
|
</div>
|
||||||
|
</div><!--syllabus_courses_box end-->
|
||||||
|
</div><!--syllabus_box end-->
|
||||||
|
|
||||||
|
<div class="" style="height:20px; background:#eaebec;"></div>
|
||||||
|
<div class="syllabus_box">
|
||||||
|
<div class="syllabus_category">
|
||||||
|
<a class="sortdownbtn sort_no fr"></a><a href="#" class="sortTxt fr">人气</a>
|
||||||
|
<a class="sortupbtn fr"></a><a href="#" class="sortTxt fr ">时间</a>
|
||||||
|
<span class="grayTxt fl ">我参与的项目</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="syllabus_courses_box">
|
||||||
|
<% @projects.each do |project| %>
|
||||||
|
<div class="syllabus_courses_list" style="cursor: default;">
|
||||||
|
<div class="sy_courses_open">
|
||||||
|
<span class="icons_project_list fl mt5 mr10"></span>
|
||||||
|
<h3><%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
|
||||||
|
<% unless project.is_public? %>
|
||||||
|
<span class="hw_icon_private fl"></span>
|
||||||
|
<% end %>
|
||||||
|
<% projectUser = User.where("id=?",project.user_id).first %>
|
||||||
|
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="fl sy_p_grey">更新时间:<%= format_date(project.updated_on) %></p>
|
||||||
|
<div class=" fr">
|
||||||
|
<p class="list-info fr grayTxt">
|
||||||
|
<%= link_to project.members.count, member_project_path(project), :class => "c_blue" %><span class="mr5">成员 |</span>
|
||||||
|
<%= link_to project.project_score.issue_num, project_issues_path(project), :class => "c_blue" %><span class="mr5">问题 |</span>
|
||||||
|
<%= link_to project.project_score.attach_num, file_project_path(project), :class => "c_blue" %><span class="mr5">资源</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="syllabus_courses_list ">
|
||||||
|
<p class="new_projectlist_more"><a href="javascript:void(0);" >共100个项目,点击全部展开</a></p>
|
||||||
|
</div>
|
||||||
|
</div><!--syllabus_courses_box end-->
|
||||||
|
</div><!--syllabus_box end-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="listbox" id="project-list">
|
<div class="listbox" id="project-list">
|
||||||
<h2 class="list-h2">项目列表</h2>
|
<h2 class="list-h2">项目列表</h2>
|
||||||
<div class="category">
|
<div class="category">
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
$("#choose_courses_notice").html("");
|
$("#choose_courses_notice").html("");
|
||||||
<% else %>
|
<% else %>
|
||||||
var htmlvalue = "<%= escape_javascript(render :partial => 'users/homework_repository_detail') %>";
|
var htmlvalue = "<%= escape_javascript(render :partial => 'users/homework_repository_detail') %>";
|
||||||
pop_box_new(htmlvalue,820,155);
|
pop_box_new(htmlvalue,820,800);
|
||||||
<% end %>
|
<% end %>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<% if @list_type.to_i == 1 %>
|
||||||
|
$("#user_projects_list").html('<%= escape_javascript(render :partial => 'users/project_list', :locals => {:projects => @projects, :list_type => 1, :count => @projects_count}) %>');
|
||||||
|
<% else %>
|
||||||
|
$("#user_join_projects_list").html('<%= escape_javascript(render :partial => 'users/project_list', :locals => {:projects => @projects, :list_type => 2, :count => @projects_count}) %>');
|
||||||
|
<% end %>
|
|
@ -27,9 +27,19 @@
|
||||||
<%# end %>
|
<%# end %>
|
||||||
</div>
|
</div>
|
||||||
<p id="nodata" class="nodata" style="display:<%= @list.count > 0 ? 'none' : 'block' %>;"><%= l(:label_no_data) %></p>
|
<p id="nodata" class="nodata" style="display:<%= @list.count > 0 ? 'none' : 'block' %>;"><%= l(:label_no_data) %></p>
|
||||||
|
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<ul class="wlist" style=" border:none;">-->
|
||||||
|
<!--<%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>-->
|
||||||
|
<!--</ul>-->
|
||||||
|
<!--<div class="cl"></div>-->
|
||||||
</div>
|
</div>
|
||||||
<ul class="wlist" style=" border:none;">
|
|
||||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
|
||||||
</ul>
|
|
||||||
<div class="cl"></div>
|
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
|
|
|
@ -1 +1,39 @@
|
||||||
<%= render :partial => 'users/user_project_list'%>
|
<div class="syllabus_box">
|
||||||
|
<h2 class="syllabus_h2_top"><span class="icon_course fl mt7 mr5"></span>项目列表</h2>
|
||||||
|
<%= render :partial => 'users/my_projects'%>
|
||||||
|
<div class="" style="height:20px; background:#eaebec;"></div>
|
||||||
|
<%= render :partial => 'users/my_joined_projects'%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
//如果右边的列表比左边的高度低则将右边的高度设为与左边对齐
|
||||||
|
$(function() {
|
||||||
|
var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 20;
|
||||||
|
var rightHeight = $(".homepageRight").height();
|
||||||
|
if (rightHeight < leftHeight) {
|
||||||
|
var diffHeight = leftHeight - rightHeight;
|
||||||
|
var tmpHeight = $(".syllabus_box").height() + diffHeight;
|
||||||
|
$(".syllabus_box").css("minHeight", tmpHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function expand_projects(btnid,container,count){
|
||||||
|
var target = $(container).children('.syllabus_courses_list');
|
||||||
|
var btn = $(btnid);
|
||||||
|
if(btn.data('init')=='0'){
|
||||||
|
btn.data('init',1);
|
||||||
|
btn.html('点击收起');
|
||||||
|
target.show();
|
||||||
|
}else{
|
||||||
|
btn.data('init',0);
|
||||||
|
btn.html('共' + count + '个项目,点击全部展开');
|
||||||
|
target.hide();
|
||||||
|
target.eq(0).show();
|
||||||
|
target.eq(1).show();
|
||||||
|
target.eq(2).show();
|
||||||
|
target.eq(3).show();
|
||||||
|
target.eq(4).show();
|
||||||
|
btn.parent().parent().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
$("#user_show_more_project").replaceWith("<%= escape_javascript( render :partial => 'layouts/user_projects',:locals => {:projects => @projects,:user => @user, :page => @page} )%>");
|
$("#user_show_more_project").replaceWith("<%= escape_javascript( render :partial => 'layouts/user_projects',:locals => {:projects => @projects,:user => @user, :page => @page, :all_count => @all_count} )%>");
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
window.g_debug = false; //调试标志,如果在本地请置为true
|
window.g_debug = false; //调试标志,如果在本地请置为true
|
||||||
window.apiUrl = '/api/v1/';
|
window.apiUrl = '/api/v1/';
|
||||||
window.g_redirect_path = '<%= @path %>';
|
window.g_redirect_path = '<%= @path %>';
|
||||||
window.g_localhost = "<%= Setting.protocol%>://"+"<%= Setting.host_name%>";
|
window.g_localhost = "<%= Setting.protocol %>"+ "://"+"<%= Setting.host_name%>";
|
||||||
|
window.g_appid = "<%= @appid %>";
|
||||||
<% if @course_id %>
|
<% if @course_id %>
|
||||||
window.g_courseid = <%= @course_id %>;
|
window.g_courseid = <%= @course_id %>;
|
||||||
<% elsif @project_id %>
|
<% elsif @project_id %>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue