Merge branch 'develop' into cs_optimize_txz

This commit is contained in:
Tim 2016-08-31 14:32:33 +08:00
commit 8bbcef83f2
356 changed files with 11714 additions and 4997 deletions

View File

@ -50,10 +50,10 @@ gem 'elasticsearch-model'
gem 'elasticsearch-rails'
#rails 3.2.22.2 bug
gem "test-unit", "~>3.0"
gem "test-unit", "~>3.0"
### profile
gem 'oneapm_rpm'
gem 'oneapm_rpm'
group :development do
gem 'grape-swagger'

View File

@ -13,50 +13,55 @@ module Mobile
requires :container_type, type: String
end
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"
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(",") + ")"
project_types = "('Message','Issue','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)
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')"
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
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

View File

@ -7,17 +7,22 @@ module Mobile
desc "get special topic"
post ':id' do
user = current_user
begin
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
blog = BlogComment.find params[:id]
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
blog = BlogComment.find params[:id]
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
end
end
end

View File

@ -100,15 +100,34 @@ module Mobile
params do
requires :token, type: String
requires :invite_code, type: String, desc: '邀请码'
requires :teacher_flag, type: Boolean
requires :assistant_flag, type: Boolean
requires :student_flag, type: Boolean
end
post "join" do
post "join_class" do
authenticate!
cs = CoursesService.new
status = cs.join_course({role: "10", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
{
status: status[:state],
message:CoursesService::JoinCourseError.message(status[:state])
}
roles_ids = []
if params[:teacher_flag]
roles_ids << "9"
elsif params[:assistant_flag]
roles_ids << "7"
end
if params[:student_flag]
roles_ids << "10"
end
if roles_ids.length <= 0
{status:-1,message:"请至少选择一个角色"}
else
cs = CoursesService.new
status = cs.join_course_roles({role: roles_ids, openid: params[:openid], invite_code: params[:invite_code]}, current_user)
{
status: status[:state],
message:CoursesService::JoinCourseError.message(status[:state])
}
end
end
@ -148,8 +167,20 @@ module Mobile
requires :course_id, type: Integer, desc: "课程id"
end
get 'teachers' do
course = Course.find(params[:course_id])
cs = CoursesService.new
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 :status, 0
end
@ -166,7 +197,53 @@ module Mobile
present :status, 0
end
desc "设置教辅"
desc "课程未审核列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'reviewers' do
authenticate!
cs = CoursesService.new
reviewers = cs.reviewers_list(params[:course_id])
present :data, reviewers, with: Mobile::Entities::User
present :status, 0
end
desc "课程单个未审核用户信息"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
requires :user_id, type: Integer, desc: "用户id"
end
post 'review_member_info' do
authenticate!
cs = CoursesService.new
result = cs.get_reviewer_info(params)
present :data, result[:reviewer], with: Mobile::Entities::User
present :status,result[:status]
end
desc "处理教师或助教的身份申请"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
requires :user_id, type: Integer, desc: "用户id"
requires :type, type: Integer, desc: "同意或拒绝"
end
post 'deal_join_apply' do
authenticate!
cs = CoursesService.new
result = cs.deal_join_apply(params,current_user)
present :status, result[:status]
present :message, result[:message]
end
desc "设置助教"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
@ -178,7 +255,7 @@ module Mobile
present :status, 0
end
desc "删除"
desc "删除"
params do
requires :token,type:String
requires :user_id,type:Integer,desc: '用户id'
@ -210,6 +287,30 @@ module Mobile
end
end
desc "获取课程动态"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'activities' do
authenticate!
user = current_user
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
activities = UserActivity.where("(container_type = 'Course' and container_id = #{params[:id]} and act_type in #{course_types})").order('updated_at desc')
page = params[:page] ? params[:page] : 0
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
end
desc "课程作业列表"
params do
requires :token, type: String
@ -448,24 +549,118 @@ module Mobile
requires :id, type: Integer
requires :token, type: String
requires :user_id, type: Integer
requires :role_id, type: Integer
requires :teacher_flag, type: Boolean
requires :assistant_flag, type: Boolean
requires :student_flag, type: Boolean
end
post 'edit_member_role' do
authenticate!
roles_id = []
if params[:teacher_flag]
roles_id << 9
elsif params[:assistant_flag]
roles_id << 7
end
if params[:student_flag]
roles_id << 10
end
c = Course.find("#{params[:id]}")
#7教辅 9教师 10学生
if c.tea_id == params[:user_id] || c.tea_id != current_user.id || !(params[:role_id] == 7 || params[:role_id] == 9 || params[:role_id] == 10)
if c.tea_id == params[:user_id] || c.tea_id != current_user.id || roles_id.length <= 0
present :status, -1
else
cs = CoursesService.new
status = cs.modify_user_course_role params
status = cs.modify_user_course_role params,roles_id
present :status, status
end
end
desc "发布班级通知"
params do
requires :id, type: Integer
requires :token, type: String
requires :text, type: String
requires :title, type: String
end
post ':id/publishnotice' do
authenticate!
#老师或教辅才能发通知
c = Course.find("#{params[:id]}")
my_member = c.member_principals.where("users.id=#{current_user.id}").first
roles_ids = []
my_member.roles.each do |role|
roles_ids << role.id
end
if my_member && (roles_ids.include?(7)|| roles_ids.include?(9) || roles_ids.include?(3))
tmpparams = {}
tmpparams['title'] = params[:title]
tmpparams['description'] = params[:text]
tmpparams['sticky'] = 0
news = News.new(:course => c, :author => current_user)
#render :layout => 'base_courses'
news.safe_attributes = tmpparams
news.save!
present :status, 0
else
present :status, -1
present :message,"学生不能发布通知"
end
end
desc "发布班级问题"
params do
requires :id, type: Integer
requires :token, type: String
requires :text, type: String
end
post ':id/publishissue' do
authenticate!
c = Course.find("#{params[:id]}")
boards = c.boards.includes(:last_message => :author).all
if c.boards.empty?
board = c.boards.build
board.name = "班级问答区"
board.description = c.name.to_s
board.project_id = -1
if board.save
boards = c.boards.includes(:last_message => :author).all
end
end
board = boards.first
message = Message.new
message.author = current_user
message.board = board
tmpparams = {}
tmpparams['subject'] = params[:title]
tmpparams['content'] = params[:text]
message.safe_attributes = tmpparams
message.save!
present :status, 0
end
end
end
end

View File

@ -8,17 +8,35 @@ module Mobile
desc "get special issuse"
post ':id' do
authenticate!
user = current_user
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
issue = Issue.find params[:id]
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
#is_public true 公开 false 私有 1公开 0私有
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
is_public = 1
if type == 0
issue = Issue.find params[:id]
issue.project.is_public
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
else
jour = Journal.find params[:id]
present :data, jour, with: Mobile::Entities::Issue,user: user,type: type,page: page
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
end
end

View File

@ -7,18 +7,33 @@ module Mobile
desc "get special journal"
post ':id' do
authenticate!
user = current_user
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
jour = JournalsForMessage.find params[:id]
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
jour = JournalsForMessage.find params[:id]
is_public = 1
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

View File

@ -7,17 +7,36 @@ module Mobile
desc "get special topic"
post ':id' do
authenticate!
user = current_user
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
message = Message.find params[:id]
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
message = Message.find params[:id]
is_public = 1
type_name = ""
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

View File

@ -11,69 +11,208 @@ module Mobile
params do
requires :type, type: String
requires :content, type: String
requires :token, type: String
end
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!
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]
result = 1
if params[:content]!="" && current_user
case type
when "HomeworkCommon"
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])
if (feedback.errors.empty?)
homework_common.update_column(:updated_at, Time.now)
result = 2
end
when "News"
news = News.find(params[:id])
comment = Comment.new
comment.comments = params[:content]
comment.author = current_user
if news.comments << comment
result = 2
# if news.project
# if news.project.is_public == false && !current_user.member_of?(news.project)
# status = -1
# 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
when "Message"
message = Message.find(params[:id])
board = Board.find(message.board_id)
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
# if message.project
# if message.project.is_public == false && !current_user.member_of?(message.project)
# status = -1
# tip = 1
# end
# elsif message.course
# if message.course.is_public == 0 && !current_user.member_of_course?(message.course)
# 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
when "JournalsForMessage"
jour = JournalsForMessage.find params[:id]
parent_id = params[:id]
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
# if jour.jour_type == "Project"
# if jour.project.is_public == false && !current_user.member_of?(jour.project)
# status = -1
# tip = 1
# end
# elsif jour.jour_type == "Course"
# if jour.course.is_public == 0 && !current_user.member_of_course?(jour.course)
# status = -1
# tip = 0
# end
# end
if status == 0
parent_id = params[:id]
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
when 'Issue'
issue = Issue.find params[:id]
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
# if issue.project.is_public == false && !current_user.member_of?(issue.project)
# status = -1
# tip = 1
# end
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
when 'BlogComment'
blog = BlogComment.find(params[:id]).root
@ -97,7 +236,9 @@ module Mobile
result = 3
end
present :result, result
present :status, 0
present :status, status
present :tip, tip
present :subscribe,subscribe
end
end
end

View File

@ -7,17 +7,37 @@ module Mobile
desc "get special news"
post ':id' do
authenticate!
user = current_user
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
news = News.find params[:id]
present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
is_public = 1
if type == 0
news = News.find params[:id]
if news.project
is_public = news.project.is_public
elsif news.course
is_public = news.course.is_public
end
else
news = Comment.find params[:id]
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

View File

@ -86,9 +86,24 @@ module Mobile
develop_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=4").all.sort
report_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=5").all.sort
review_master_members = []
review_develop_members = []
my_member = project.member_principals.where("users.id=#{current_user.id}").first
if my_member && my_member.roles[0] && my_member.roles[0].id == 3
ps = ProjectsService.new
user = current_user
review_master_members = ps.get_project_review_members(project,3,user)
review_develop_members = ps.get_project_review_members(project,4,user)
end
present :master_members,master_members, with: Mobile::Entities::ProjectMember
present :develop_members,develop_members, with: Mobile::Entities::ProjectMember
present :report_members,report_members, with: Mobile::Entities::ProjectMember
present :review_master_members,review_master_members
present :review_develop_members,review_develop_members
present :status, 0
end
@ -163,18 +178,96 @@ module Mobile
params do
requires :token, type: String
requires :invite_code, type: String, desc: '邀请码'
requires :role_id, type: Integer, desc: '身份'
end
post "join" do
post "join_project" do
authenticate!
# ps = ProjectsService.new
# status = ps.join_project({role: "5", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
#
# present :status, status
role_id = params[:role_id]
{status:-1, message: '该功能将在近日开放,敬请期待!' }
if role_id != 3 && role_id != 4 && role_id != 5
{status:-1,message:"请至少选择一个角色"}
else
ps = ProjectsService.new
status = ps.join_project({role: role_id, openid: params[:openid], invite_code: params[:invite_code]}, current_user)
{status:status, message:ProjectsService::JoinProjectError.message(status)}
end
# {status:-1, message: '该功能将在近日开放,敬请期待!' }
end
desc "项目单个未审核用户信息"
params do
requires :token, type: String
requires :project_id, type: Integer, desc: "项目id"
requires :user_id, type: Integer, desc: "用户id"
end
post 'review_member_info' do
authenticate!
ps = ProjectsService.new
result = ps.get_reviewer_info(params,current_user)
present :data, result[:reviewer], with: Mobile::Entities::User
present :status, result[:status]
end
desc "处理管理或开发的身份申请"
params do
requires :token, type: String
requires :project_id, type: Integer, desc: "项目id"
requires :user_id, type: Integer, desc: "用户id"
requires :type, type: Integer, desc: "同意或拒绝"
end
post 'deal_join_apply' do
authenticate!
ps = ProjectsService.new
result = ps.deal_join_apply(params,current_user)
present :status, result[:status]
present :message, result[:message]
end
desc "发布项目帖子"
params do
requires :id, type: Integer
requires :token, type: String
requires :text, type: String
end
post ':id/publishnote' do
authenticate!
project = Project.find("#{params[:id]}")
boards = project.boards.includes(:last_message => :author).all
if project.boards.empty?
board = project.boards.build
board.name = "项目讨论区"
board.description = project.name.to_s
board.course_id = -1
if board.save
boards = project.boards.includes(:last_message => :author).all
end
end
board = boards.first
message = Message.new
message.author = current_user
message.board = board
tmpparams = {}
tmpparams['subject'] = params[:title]
tmpparams['content'] = params[:text]
message.safe_attributes = tmpparams
message.save!
present :status, 0
end
end
end
end

View File

@ -28,9 +28,10 @@ module Mobile
ss = SyllabusesService.new
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
end

View File

@ -29,7 +29,7 @@ module Mobile
logger.debug "openid ============== #{openid}"
raise "无法获取到openid,请在微信中打开本页面" unless openid
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])
raise "用户名或密码错误,请重新输入" unless user
@ -37,12 +37,17 @@ module Mobile
raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat
UserWechat.create!(
if uw && !uw.real?
uw.migrate_user(user)
else
UserWechat.create!(
openid: openid,
user: user
)
)
end
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平台'
end
@ -53,22 +58,38 @@ module Mobile
requires :password, type: String, desc: 'password'
end
post do
openid = session[:wechat_openid]
logger.debug "openid ============== #{openid}"
raise "无法获取到openid,请在微信中打开本页面" unless openid
uw = UserWechat.where(openid: openid).first
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw && uw.real?
us = UsersService.new
user = us.register params.merge(:password_confirmation => params[:password],
:should_confirmation_password => true)
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,
user: user
)
)
end
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 :status, 0
end

View File

@ -7,23 +7,32 @@ module Mobile
desc "get one homework"
post ':id' do
authenticate!
user = current_user
begin
# authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
if type == 0
homework = HomeworkCommon.find params[:id]
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"
is_public = 1
if type == 0
homework = HomeworkCommon.find params[:id]
is_public = homework.course.is_public
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
present :type, type
present :page, page
present :status, 0
end
end
end

View File

@ -40,6 +40,8 @@ module Mobile
ac.act.subject unless ac.nil? || ac.act.nil?
elsif ac.act_type == "JournalsForMessage"
ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Poll"
ac.act.polls_name unless ac.nil? || ac.act.nil?
end
when :description
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
@ -48,6 +50,8 @@ module Mobile
strip_html(ac.act.content) unless ac.nil? || ac.act.nil?
elsif ac.act_type == "JournalsForMessage"
strip_html(ac.act.notes) unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Poll"
ac.act.polls_description unless ac.nil? || ac.act.nil?
end
when :latest_update
time_from_now ac.updated_at unless ac.nil?
@ -73,15 +77,15 @@ module Mobile
if ac.container_type == "Course"
case ac.act_type
when "HomeworkCommon"
"课程作业"
"班级作业"
when "News"
"课程通知"
"班级通知"
when "Message"
"课程问答"
"班级讨论"
when "Poll"
"课程问卷"
"班级问卷"
when "Course"
"课程"
"班级"
end
elsif ac.container_type == "Project"
case ac.act_type

View File

@ -23,6 +23,8 @@ module Mobile
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s
when :coursename
f.course.nil? ? "" : f.course.name
when :course_id
f.course.nil? ? 0 : f.course.id
end
end
@ -38,6 +40,7 @@ module Mobile
attachment_expose :file_dir
attachment_expose :attafile_size
attachment_expose :coursename #所属班级名
attachment_expose :course_id #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false

View File

@ -85,7 +85,7 @@ module Mobile
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && parents_reply.count != 2 && !opt[:bottom]
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
@ -104,9 +104,9 @@ module Mobile
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count >= 2 && !opt[:top]
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:bottom] = true
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
@ -125,6 +125,10 @@ module Mobile
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end

View File

@ -65,9 +65,9 @@ module Mobile
end
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
end
@ -76,6 +76,15 @@ module Mobile
end
can_setting
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|
if c.is_a? ::Course
c.teacher

View File

@ -34,15 +34,45 @@ module Mobile
'Issue'
when :act_id
issue.id
when :title
issue.subject
when :subject
issue.subject
when :description
issue.description
when :done_ratio
issue.done_ratio
end
end
elsif issue.is_a?(::Journal)
case f
when :content
issue[:notes]
when :lasted_comment
time_from_now issue.created_on
when :act_id
issue.id
end
end
end
end
expose :subject
expose :description
expose :author, using: Mobile::Entities::User
expose :done_ratio
issue_expose :subject
issue_expose :description
expose :author, using: Mobile::Entities::User do |f, opt|
if f.is_a?(::Issue)
f.send(:author)
end
end
expose :user,using: Mobile::Entities::User do |f, opt|
if f.is_a?(::Journal)
f.send(:user)
end
end
issue_expose :content
issue_expose :lasted_comment
issue_expose :done_ratio
issue_expose :title
issue_expose :act_type
issue_expose :act_id
issue_expose :created_on
@ -52,11 +82,29 @@ module Mobile
issue_expose :comment_count
issue_expose :project_name
issue_expose :praise_count
expose :issue_journals, using: Mobile::Entities::Journal do |f, opt|
expose :id
# expose :issue_journals, using: Mobile::Entities::Journal do |f, opt|
# if f.is_a?(::Issue)
# f.journals.where("notes is not null and notes != ''").reverse
# end
# end
expose :all_children, using: Mobile::Entities::Issue do |f, opt|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
if f.is_a?(::Issue)
f.journals.where("notes is not null and notes != ''").reverse
# f.journals_for_messages.reverse
if !opt[:children] && opt[:type] == 0
opt[:children] = true
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = f.journals.where("notes is not null and notes != ''").reorder("created_on desc")
all_comments[tStart..tEnd]
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
@ -64,6 +112,69 @@ module Mobile
has_praise = obj.empty? ? false : true
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance.is_a?(::Journal)
parents_reply = []
parents_reply = get_reply_parents(parents_reply, instance)
parents_reply.count
end
end
expose :parents_reply_bottom, using:Mobile::Entities::Issue do |f,opt|
if f.is_a? (::Journal)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::Issue do |f,opt|
if f.is_a? (::Journal)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
end
end
end

View File

@ -101,7 +101,7 @@ module Mobile
elsif opt[:comment_type] == "homework"
parents_reply = get_reply_parents(parents_reply, f)
end
if parents_reply.count > 0 && parents_reply.count != 2 && !opt[:bottom]
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
@ -125,9 +125,9 @@ module Mobile
elsif opt[:comment_type] == "homework"
parents_reply = get_reply_parents(parents_reply, f)
end
if parents_reply.count >= 2 && !opt[:top]
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:bottom] = true
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
@ -146,6 +146,10 @@ module Mobile
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end

View File

@ -33,6 +33,8 @@ module Mobile
when :comment_count
all_comments = []
get_all_children(all_comments, u).count
when :title
u.subject
end
end
end
@ -50,6 +52,7 @@ module Mobile
message_expose :course_project_name
message_expose :board_id
message_expose :subject
message_expose :title
message_expose :content
message_expose :comment_count
message_expose :praise_count
@ -92,7 +95,7 @@ module Mobile
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && parents_reply.count != 2 && !opt[:bottom]
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
@ -111,9 +114,9 @@ module Mobile
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count >= 2 && !opt[:top]
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:bottom] = true
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
@ -132,6 +135,10 @@ module Mobile
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end

View File

@ -28,6 +28,16 @@ module Mobile
f.comments.count
end
end
elsif f.is_a?(::Comment)
case field
when :content
f[:comments]
when :lasted_comment
time_from_now f.created_on
when :act_id
f.id
end
elsif f.is_a?(Hash) && !f.key?(field)
n = f[:news]
comments = f[:comments]
@ -43,14 +53,16 @@ module Mobile
end
end
end
news_expose :id
expose :id
#新闻标题
news_expose :title
expose :author,using: Mobile::Entities::User do |f, opt|
expose :user,using: Mobile::Entities::User do |f, opt|
obj = nil
if f.is_a?(::News) && f.respond_to?(:author)
obj = f.send(:author)
elsif f.is_a?(::Comment) && f.respond_to?(:author)
obj = f.send(:author)
elsif f.is_a?(Hash) && f.key?(:author)
obj = f[:author]
end
@ -73,14 +85,34 @@ module Mobile
news_expose :praise_count
#课程名字
news_expose :course_name
news_expose :lasted_comment
#评论
expose :comments, using: Mobile::Entities::Comment do |f, opt|
if f.is_a?(Hash) && f.key?(:comments)
f[:comments]
elsif f.is_a?(::News) && f.respond_to?(:comments)
f.comments.reverse
# expose :comments, using: Mobile::Entities::Comment do |f, opt|
# if f.is_a?(Hash) && f.key?(:comments)
# f[:comments]
# elsif f.is_a?(::News) && f.respond_to?(:comments)
# f.comments.reverse
# end
# end
news_expose :content
expose :all_children, using: Mobile::Entities::News do |f, opt|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
if f.is_a?(::News)
# f.journals_for_messages.reverse
if !opt[:children] && opt[:type] == 0
opt[:children] = true
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = f.comments.reorder("created_on desc")
all_comments[tStart..tEnd]
end
end
end
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
has_praise = false
current_user = options[:user]
@ -88,6 +120,69 @@ module Mobile
has_praise = obj.empty? ? false : true
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance.is_a?(::Comment)
parents_reply = []
parents_reply = get_reply_parents(parents_reply, instance)
parents_reply.count
end
end
expose :parents_reply_bottom, using:Mobile::Entities::News do |f,opt|
if f.is_a? (::Comment)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::News do |f,opt|
if f.is_a? (::Comment)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents(parents_reply, f)
if parents_reply.count > 2 && !opt[:top]
if opt[:type] == 1
opt[:top] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
elsif parents_reply.count == 2 && !opt[:top]
opt[:top] = true
parents_reply = parents_reply.reverse[0..0]
parents_reply.reverse
else
[]
end
end
end
end
end
end

View File

@ -4,8 +4,8 @@ module Mobile
expose :name
expose :id
expose :user_id
# expose :invite_code
# expose :qrcode
expose :invite_code
expose :qrcode
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
@ -23,6 +23,16 @@ module Mobile
current_user.id == instance.user_id
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|
instance.members.count

View File

@ -14,11 +14,11 @@ module Mobile
else
case f
when :roles_id
u.roles[0].id
# u.roles[0].id
u.roles.map {|r| r.id}
end
end
end
end
end

View File

@ -5,8 +5,8 @@ module Mobile
expose :id
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
can_setting = instance.user_id == current_user.id ? true : false
can_setting = false if instance.id.nil?
can_setting = instance[:user_id] == current_user.id ? true : false
can_setting = false if instance[:id].nil?
can_setting
end
expose :courses, using: Mobile::Entities::Course

View File

@ -34,6 +34,8 @@ module Mobile
'HomeworkCommon'
when :act_id
wh.id
when :title
wh.name
end
end
end
@ -59,6 +61,7 @@ module Mobile
expose :quotes
expose :is_open
expose :id
whomework_expose :title
whomework_expose :act_type
whomework_expose :act_id
whomework_expose :course_name

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the pull_requests controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -26,7 +26,15 @@ class AccountController < ApplicationController
if request.get?
@login = params[:login] || true
if User.current.logged?
redirect_to user_path(User.current)
# 判断用户基本资料是否完善,不完善讲强制完善基本资料,完善进入主页
user = UserExtensions.where(:user_id => User.current.id).first
if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil?
redirect_to my_account_path(:tip => 1)
elsif user.identity == 3 && user.school_id.nil?
redirect_to my_account_path(:tip => 1)
else
redirect_to user_path(User.current)
end
else
render :layout => 'login'
end
@ -127,7 +135,7 @@ class AccountController < ApplicationController
session[:auth_source_registration] = nil
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_path
redirect_to my_account_path(:tip=>1)
end
else
us = UsersService.new
@ -144,7 +152,7 @@ class AccountController < ApplicationController
if !@user.new_record?
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_url
redirect_to my_account_url(:tip=>1)
else
redirect_to signin_path
end
@ -347,9 +355,17 @@ class AccountController < ApplicationController
else
#by young
#redirect_back_or_default my_page_path
redirect_back_or_default User.current
# 基本资料不完善的用户,将强制用户完善基本资料。
user = UserExtensions.where(:user_id => User.current.id).first
if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil?
redirect_to my_account_path(:tip => 1)
elsif user.identity == 3 && user.school_id.nil?
redirect_to my_account_path(:tip => 1)
else
redirect_back_or_default User.current
#redirect_to my_account_url
#redirect_to User.current
end
end
end
end

View File

@ -61,7 +61,7 @@ class AdminController < ApplicationController
if params[:syllabus_id] && params[:course_id]
course = Course.where("id = #{params[:course_id].to_i}").first
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
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.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content
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
@course = course
respond_to do |format|
@ -612,58 +612,64 @@ class AdminController < ApplicationController
end
end
# 获取申请的高校列表
# status: 0 未审批; 1 已批阅;
# 单位审核
# 未审批tab页
# status: 0 未审批; 1 已批阅; 2已更改 3拒绝
def applied_schools
# 更新消息状态
if params[:flag]
applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first
applied_message.update_attribute(:viewed, true)
end
@name = params[:name] || ""
condition = "#{@name.strip}".gsub(" ","")
@apply_status = ApplyAddSchools.where("status = 0 and name like '%#{condition}%'").order('created_at desc')
@apply_count = @apply_status.count
@apply_pages = Paginator.new @apply_count, 30, params['page'] || 1
@apply_status = paginateHelper @apply_status, 30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
# 单位审核
# 已审批tab页
def has_applied_schools
@name = params[:name] || ""
condition = "#{@name.strip}".gsub(" ","")
@has_apply_status = ApplyAddSchools.where("(status = 1 or status = 2) and name like '%#{condition}%'").order('created_at desc')
@has_apply_count = @has_apply_status.count
@has_apply_pages = Paginator.new @has_apply_count, 30, params['page'] || 1
@has_apply_status = paginateHelper @has_apply_status, 30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
# 批准未审批的高校
# 单位审核:批准
# 消息发送,发送对象为申请人
# status: 0表示未批准 status1表示已批准 status 2表示已更改 status 3表示已拒绝
# status: 0表示未批准 status1表示已批准 status 2表示已更改 status 3表示已拒绝
def approve_applied_schools
applied_school = ApplyAddSchools.find params[:id]
applied_school.update_column('status', 1) unless applied_school.nil?
school = applied_school.school
school.update_attribute("province", applied_school.province)
AppliedMessage.create(:user_id => applied_school.user_id, :status => 1, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
AppliedMessage.create(:user_id => applied_school.user_id, :status => 1, :viewed => 0, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
# School.create(:user_id => applied_school.user_id, :status => 1, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
respond_to do |format|
format.html{ redirect_to unapplied_schools_url }
end
end
# 更改申请的高校名称
# REDO: 修改该字段
# REDO: 同步修改使用了改名称的用户单位
# 单位审核:更改
# 修改该字段
# 同步修改使用了改名称的用户单位
def edit_applied_schools
aas = ApplyAddSchools.find(params[:applied_id])
# aas.update_attribute(:name, params[:name])
@ -671,12 +677,12 @@ class AdminController < ApplicationController
school = School.find params[:school_id]
begin
aas.update_attribute(:status, 2)
AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => true, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name )
AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name )
users = UserExtensions.where("school_id = #{aas.school_id}")
users.each do |user|
user.update_column("school_id", school[0].id)
users.update_all(:school_id => school[0].id)
if aas.school_id != school[0].id.to_i
aas.school.destroy
end
aas.school.destroy
aas.update_attribute(:school_id, school[0].id)
rescue Exception => e
puts e
@ -686,12 +692,13 @@ class AdminController < ApplicationController
redirect_to unapplied_schools_url
end
# 单位审核:更改功能搜索合法学校弹框
def all_schools
apply_schools = ApplyAddSchools.where("status != 1")
apply_schools = ApplyAddSchools.where("status = 0")
apply_school_ids = apply_schools.empty? ? "(-1)" : "(" + apply_schools.map{|sc| sc.school_id}.join(',') + ")"
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@schools = School.where("id not in #{apply_school_ids} and #{School.table_name}.name like :p",:p=>search)
@schools = School.where("id not in #{apply_school_ids} and #{School.table_name}.name like :p", :p => search)
#@schools = School.all
else
#@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
@ -704,22 +711,21 @@ class AdminController < ApplicationController
end
end
# 删除申请的高校
# REDO: destroy关联删除
# REDO: 删除确认提示,是否删除
# REDO: 给申请人发送消息
# 单位审核:删除
def delete_applied_schools
applied_school = ApplyAddSchools.find(params[:id])
applied_school.update_attribute(:status, 3)
AppliedMessage.create(:user_id => applied_school.user_id, :status => 3, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
users = UserExtensions.where("school_id = #{applied_school.school_id}")
users.each do |user|
user.update_column("school_id", nil)
end
applied_school.school.destroy
# 未审批删除
if params[:tip] == "unapplied"
AppliedMessage.create(:user_id => applied_school.user_id, :status => 3, :viewed => 0, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
# 删除学校的用户
users = UserExtensions.where("school_id = #{applied_school.school_id}")
users.update_all(:school_id => nil)
applied_school.school.destroy
redirect_to unapplied_schools_url
# 已审批删除
elsif params[:tip] == "applied"
applied_school.destroy
redirect_to applied_schools_url
end
end

View File

@ -45,7 +45,7 @@ class AppliedProjectController < ApplicationController
end
# @flage:提示语标志1邀请码错误2已经是项目成员 3角色没有选择; 4申请成功
# role:成员角色 => 04管理人员5开发人员6:报告人员)
# role:成员角色 => 03管理人员4开发人员5:报告人员)
# 申请成功则发送消息
def applied_project_info
if params[:project_id].nil?
@ -53,7 +53,7 @@ class AppliedProjectController < ApplicationController
else
@project = Project.find(params[:project_id])
end
if !@project || params[:invite_code].to_s != @project.invite_code
if !@project || params[:invite_code].strip.upcase.to_s != @project.invite_code
@flag = 1
elsif User.current.member_of?(@project)
@flag = 2
@ -61,6 +61,22 @@ class AppliedProjectController < ApplicationController
@flag = 3
elsif !AppliedProject.where(:project_id => @project.id, :user_id => User.current.id).first.nil?
@flag = 5
elsif params[:member] == "member_reporter" && params[:invite_code].upcase.to_s == @project.invite_code
# 项目报告人员直接加入项目
@flag = 6
members = []
user_grades = []
project_info = []
members << Member.new(:role_ids => ["5"], :user_id => User.current.id)
user_grades << UserGrade.new(:user_id => User.current.id, :project_id => @project.id)
role = Role.find(5)
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => User.current.id) if role.allowed_to?(:is_manager)
@project.members << members
@project.project_infos << project_info
@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
@flag = 4
role = params[:member] == "member_manager" ? 3 : (params[:member] == "member_developer" ? 4 :5)

View File

@ -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
#加上all
if @user && @users.size > 0
if User.current.logged? && @users.size > 0
allUser = Struct.new(:id, :name).new
allUser.id = @users.map{|u| u.id}.join(",")
allUser.name = "all"

View File

@ -202,6 +202,11 @@ class AttachmentsController < ApplicationController
end
@attachment.save
@newfiledense = filedense
end
if @project
elsif @course
end
respond_to do |format|
format.js

View File

@ -12,11 +12,13 @@ class AvatarController < ApplicationController
@source_id = params[:source_id]
@temp_file = params[:avatar][:image]
@image_file = @temp_file.original_filename
@is_direct = params[:is_direct]
else
unless request.raw_post.nil?
@source_type = params[:source_type]
@source_id = params[:source_id]
@temp_file = request.raw_post
@is_direct = params[:is_direct]
if @temp_file.size > 0
if @temp_file.respond_to?(:original_filename)
@image_file = @temp_file.original_filename
@ -38,7 +40,7 @@ class AvatarController < ApplicationController
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
# 用户头像上传时进行特别处理
if @source_type == 'User'
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project')
diskfile += "temp"
@urlfile += "temp"
end
@ -105,7 +107,7 @@ class AvatarController < ApplicationController
path = File.dirname(diskfile)
if File.directory?(path) && File.exist?(diskfile)
# 用户头像进行特别处理
if @source_type == 'User'
if @source_type == 'User' || @source_type == 'Course' || @source_type == 'Project'
diskfile1 = diskfile + 'temp'
File.open(diskfile1, "wb") do |f|
buffer = "DELETE"

View File

@ -77,19 +77,25 @@ class FilesController < ApplicationController
if params[:insite]
if q == "%%"
@result = []
@searched_attach = paginateHelper @result,10
# @searched_attach = paginateHelper @result,10
else
@result = find_public_attache q,sort
@result = visable_attachemnts_insite @result,@course
@searched_attach = paginateHelper @result,10
# @searched_attach = paginateHelper @result,10
end
else
@result = find_course_attache q,@course,sort
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
# @searched_attach = paginateHelper @result,10
@tag_list = get_course_tag_list @course
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
# #render 'stores'
# redirect_to search_course_files_url
@ -144,18 +150,26 @@ class FilesController < ApplicationController
if params[:insite]
if q == "%%"
@project_attachment_result = []
@searched_attach = paginateHelper @project_attachment_result, 10
# @searched_attach = paginateHelper @project_attachment_result, 10
else
@project_attachment_result = find_public_attache q,sort
@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
else
@project_attachment_result = find_project_attache q, @project,sort
@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
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
# #render 'stores'
# redirect_to search_course_files_url
@ -311,6 +325,7 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
show_attachments @containers
# get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments
@ -363,6 +378,7 @@ class FilesController < ApplicationController
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
show_attachments @containers
# get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments
@ -426,6 +442,39 @@ class FilesController < ApplicationController
end
# 获取提示中私有、公开总数信息
def get_attachment_for_tip all_attachment
@tip_all_public_attachments = all_attachment.select{|attach| attach.is_public == 1}.count
if params[:project_id]
if User.current.member_of?(@project) || User.current.admin?
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count
else
if params[:tag_name]
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = 0
else
@tip_all_attachments = Attachment.where(:container_id => params[:project_id], :container_type => "Project").count
@tip_all_private_attachments = Attachment.where(:container_id => params[:project_id], :container_type => "Project", :is_public => 0).count
end
end
elsif params[:course_id]
if User.current.member_of_course?(@course) || User.current.admin?
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = all_attachment.select{|attach| attach.is_public == 0}.count
else
if params[:tag_name]
@tip_all_attachments = all_attachment.count
@tip_all_private_attachments = 0
else
@tip_all_attachments = Attachment.where(:container_id => params[:course_id], :container_type => "Course").count
@tip_all_private_attachments = Attachment.where(:container_id => params[:course_id], :container_type => "Course", :is_public => 0).count
end
end
end
end
def quote_resource_show
@file = Attachment.find(params[:id])
@can_quote = attachment_candown @file
@ -867,7 +916,18 @@ class FilesController < ApplicationController
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
end
@searched_attach = paginateHelper @result,10
@all_attachments = @result
get_attachment_for_tip(@all_attachments)
@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
@tag_list = get_project_tag_list @project
@result_search_project = @result

View File

@ -58,9 +58,10 @@ class HomeworkCommonController < ApplicationController
def edit
@user = User.current
@is_in_course = params[:is_in_course].to_i
@is_in_course = params[:is_in_course]
@is_manage = params[:is_manage]
@course_activity = params[:course_activity].to_i
if @is_in_course == 1 || @course_activity == 1
if @is_in_course.to_i == 1 || @course_activity == 1
@left_nav_type = 3
respond_to do |format|
format.html{render :layout => 'base_courses'}
@ -93,8 +94,10 @@ class HomeworkCommonController < ApplicationController
end
end
status = false
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
status = true
end
eval_start = homework_detail_manual.evaluation_start
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
@ -144,7 +147,15 @@ class HomeworkCommonController < ApplicationController
@homework_detail_programing.save if @homework_detail_programing
@homework_detail_group.save if @homework_detail_group
if params[:is_in_course] == "1"
if @homework.homework_type != 3 && homework_detail_manual.comment_status == 1 && status
create_works_list @homework
end
if params[:is_manage] == "1"
redirect_to manage_or_receive_homeworks_user_path(User.current.id)
elsif params[:is_manage] == "2"
redirect_to my_homeworks_user_path(User.current.id)
elsif params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => @course.id)
elsif params[:is_in_course] == "0"
redirect_to user_homeworks_user_path(User.current.id)

View File

@ -189,6 +189,15 @@ class IssuesController < ApplicationController
# 给该issue在它所在的项目中所有的issues中所在的位置给一个序号
@issue.project_issues_index = @issue.project.issues.last.nil? ? 1 : @issue.project.issues.last.project_issues_index + 1
if @issue.save
senduser = User.find(params[:issue][:assigned_to_id])
issue_id = @issue.id
issue_title = params[:issue][:subject]
priority_id = params[:issue][:priority_id]
ps = ProjectsService.new
ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
respond_to do |format|
format.html {
@ -512,10 +521,10 @@ class IssuesController < ApplicationController
def delete_journal
@issue = Issue.find(params[:id])
begin
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]).first
forge_acts.destroy unless forge_acts.nil?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]).first
at_message.destroy unless at_message.nil?
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id])
forge_acts.destroy_all unless forge_acts.empty?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id])
at_message.destroy_all unless at_message.empty?
Journal.delete(params[:journal_id])
rescue Exception => e
puts e
@ -581,6 +590,18 @@ class IssuesController < ApplicationController
end
end
@issue.safe_attributes = issue_attributes
senduser = User.find(params[:issue][:assigned_to_id])
if senduser.id != User.current.id
issue_id = @issue.id
issue_title = params[:issue][:subject]
priority_id = params[:issue][:priority_id]
ps = ProjectsService.new
ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id
end
@priorities = IssuePriority.active
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
true

View File

@ -75,13 +75,20 @@ class MembersController < ApplicationController
project.members << members
project.project_infos << project_info
project.user_grades << user_grades unless user_grades.first.user_id.nil?
@applied_message.update_attribute(:status, 2)
# 添加成功后所有管理员收到的消息状态都要更新
applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1,
:applied_type => "AppliedProject")
applied_messages.update_all(:status => 7, :viewed => true)
@applied_message = AppliedMessage.find(params[:applied_message_id])
# 添加成功后,申请人收到消息
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
:status => 6, :viewed => true, :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 ,
:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.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)
rescue Exception => e
puts e
end
@ -95,14 +102,24 @@ class MembersController < ApplicationController
# status(1申请的消息2已操作过该消息包括同意或者拒绝消息状态更新3拒绝消息4:被拒人收到消息5拒绝者收到消息6同意后申请人收到消息7同意后批准人收到消息)
def refused_allow_to_join_project
@applied_message = AppliedMessage.find(params[:applied_message_id])
@applied_message.update_attribute(:status, 3)
# @applied_message.update_attribute(:status, 3)
applied_project = @applied_message.applied
# 发送消息给被拒者,user_id对应的收到信息的用户
AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4,
:viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
# 发送消息给拒绝者
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 => false, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
# 拒绝功后所有管理员收到的消息状态都要更新
applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1,
:applied_type => "AppliedProject")
applied_messages.update_all(:status => 5, :viewed => true)
@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,
# :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
end
@ -212,7 +229,7 @@ class MembersController < ApplicationController
user_ids.each do |user_id|
member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
role_ids = attrs.delete(:role_ids)
role_ids = params[:membership][:role_ids]
#role = Role.find(params[:membership][:role_ids])
# 这里的判断只能通过角色名,可以弄成常量
if role_ids && role_ids.include?("10")

View File

@ -90,14 +90,34 @@ class MyController < ApplicationController
end
def clear_user_avatar_temp
@user = User.current
diskfile = disk_filename('User', @user.id)
if params[:course]
@course = Course.find params[:course]
diskfile = disk_filename('Course', @course.id)
elsif params[:project]
@project = Project.find params[:project]
diskfile = disk_filename('Project', @project.id)
else
@user = User.current
diskfile = disk_filename('User', @user.id)
end
diskfile1 = diskfile + 'temp'
File.delete(diskfile1) if File.exist?(diskfile1)
end
def save_user_avatar
@user = User.current
diskfile = disk_filename('User', @user.id)
if params[:source_id] && params[:source_type]
case params[:source_type]
when 'User'
@user = User.current
diskfile = disk_filename('User', @user.id)
when 'Course'
@course = Course.find params[:source_id]
diskfile = disk_filename('Course', @course.id)
when 'Project'
@project = Project.find params[:source_id]
diskfile = disk_filename('Project', @project.id)
end
end
diskfile1 = diskfile + 'temp'
begin
FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
@ -108,9 +128,21 @@ class MyController < ApplicationController
# Edit user's account
def account
# 更新消息状态
if params[:flag]
applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first
applied_message.update_attribute(:viewed, true)
end
# 基本资料不完善 @force为false 完善 @force为true
@force = false
if params[:tip]
@force = true
end
@user = User.current
lg=@user.login
lg = @user.login
@pref = @user.pref
diskfile = disk_filename('User', @user.id)
diskfile1 = diskfile + 'temp'
@ -133,8 +165,10 @@ class MyController < ApplicationController
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
#@user.login = params[:login]
unless @user.user_extensions.nil?
if @user.user_extensions.identity == 2
# 如果用户是从业者将单位名称保存至学校id字段
if @user.user_extensions.identity == 3
# @user.firstname = params[:enterprise_name]
@user.user_extensions.school_id = params[:occupation]
end
end
@ -145,7 +179,6 @@ class MyController < ApplicationController
# @se.occupation = params[:occupation]
# end
@se.school_id = params[:occupation]
@se.gender = params[:sex]
@se.location = params[:province] if params[:province]
@se.location_city = params[:city] if params[:city]
@ -168,11 +201,17 @@ class MyController < ApplicationController
@user.login = lg
end
end
# 不管前面是否有异常,如果文件已存在就删除
ensure
File.delete(diskfile1) if File.exist?(diskfile1)
end
render :layout=>'new_base_user'
# 基本资料不完善,无法使用其他功能,完善着可继续使用
if @force
render :layout => 'new_base_user_show'
else
render :layout => 'new_base_user'
end
end
# Destroys user's account

View File

@ -0,0 +1,259 @@
class PullRequestsController < ApplicationController
before_filter :authorize_logged
before_filter :find_project_and_repository
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"
include PullRequestsHelper
include ApplicationHelper
# 返回json格式
def index
type = params[:type]
case type
when nil, "1"
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"}
when "2"
@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
@requests_opened_count = @requests.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|
format.html
format.js
end
end
# 主要取源项目和目标项目分支及标识(用户名/版本库名)
def new
identifier = get_rep_identifier_by_project @project
@source_project_name = "#{get_user_name(@project.user_id)}/#{identifier}"
@source_rev = @g.branches(@project.gpid).map{|b| b.name}
# 获取forked源项目信息
if @project.forked_from_project_id
@forked_project = Project.find(@project.forked_from_project_id)
identifier = get_rep_identifier_by_project @forked_project
@forked_project_name = "#{get_user_name(@forked_project.user_id)}/#{identifier}"
@forked_rev = @g.branches(@forked_project.gpid).map{|b| b.name}
end
end
# Creates a merge request.
# If the operation is successful, 200 and the newly created merge request is returned. If an error occurs, an error number and a message explaining the reason is returned.
#
# @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)
#
# @param [Integer] project The ID of a project.
# @param [String] title The title of a merge request.
# @param [Hash] options A customizable set of options.
# @option options [String] :source_branch (required) The source branch name.
# @option options [String] :target_branch (required) The target branch name.
# @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
def create
title = params[:title]
description = params[:description]
source_branch = params[:source_branch]
target_branch = params[:target_branch]
begin
# 如果传送了目标项目ID则PR请求发至目标项目
if params[:forked_project_id] && params[:source_project] == "forked_project_name"
target_project_id = params[:forked_project_id].to_i
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
@fork_project_name = Project.find(@project.forked_from_project_id).try(:name)
@fork_pr_message = true if @fork_project_name
else
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
respond_to do |format|
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
end
end
rescue Exception => e
@message = e.message
end
end
def show
@type = params[:type]
@request = @g.merge_request(@project.gpid, params[:id])
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
@commits_count = @commits.count
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@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
# Accept a merge request.
# If merge success you get 200 OK.
# Accept a merge request.
#
# @example
# Gitlab.accept_pull_rquest(5, 1)
#
# @param [Integer] project The ID of a project.
# @param [Integer] id The ID of a merge request.
# @return [Gitlab::ObjectifiedHash]
def accept_pull_request
begin
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|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
end
rescue Exception => e
@message = e.message
end
end
# Updates a merge request.
#
# @example
# 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
# 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
begin
@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
private
def authorize_logged
if !User.current.logged?
redirect_to signin_path
return
end
end
def connect_gitlab
@g = Gitlab.client
end
def find_project_and_repository
@project = Project.find(params[:project_id])
render_404 if @project.gpid.blank?
@repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab")
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -17,6 +17,7 @@ class QualityAnalysisController < ApplicationController
# params 说明:{identifier版本库名}
def create
logger.info("11111111111111111111111111111")
begin
user_name = User.find(params[:user_id]).try(:login)
identifier = params[:identifier]
@ -32,12 +33,13 @@ class QualityAnalysisController < ApplicationController
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"]
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?
aa = @client.job.delete("#{job_name}")
if @client_jenkins.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
aa = @client_jenkins.job.delete("#{job_name}")
quality_an.delete unless quality_an.blank?
end
# Checks if the given job exists in Jenkins.
# unless @client.job.exists?(job_name)
unless @client_jenkins.job.exists?(job_name)
@g = Gitlab.client
branch = params[:branch]
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
# 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}")
# 将地址作为hook值添加到gitlab
@g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}")
# job创建完成后自动运行job,如果运行成功则返回200
code = @client.job.build("#{job_name}")
code = @client_jenkins.job.build("#{job_name}")
logger.error("build result ==> #{code}")
# 判断调用sonar分析是否成功
# 等待启动时间处理, 最长时间为30分钟
for i in 0..360 do
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")
break
if i == 360
@ -86,7 +88,7 @@ class QualityAnalysisController < ApplicationController
sleep(10)
# 获取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}")
# 两种情况需要删除job
@ -94,14 +96,14 @@ class QualityAnalysisController < ApplicationController
# 2/creat和build成功调用sonar启动失败则删除job
# 错误信息存储需存到Trustie数据库否则一旦job删除则无法获取这些信息
if jenkins_job == '200' && code != '201'
@client.job.delete("#{job_name}")
@client_jenkins.job.delete("#{job_name}")
else
if @current_build_status == "failure"
reg_console = /Exception:.*?\r/.match(console_build)
output = reg_console[0].gsub("\r", "") unless reg_console.nil?
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)
@client.job.delete("#{job_name}")
@client_jenkins.job.delete("#{job_name}")
elsif @current_build_status == "success"
if quality_an.blank?
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
@ -111,17 +113,24 @@ class QualityAnalysisController < ApplicationController
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
@message = e.message
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)}
logger.error("######################====>#{e.message}")
respond_to do |format|
format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name, :message => @message)}
# format.html{redirect_to :controller => 'repositories', :action => 'show', :id => @project, :repository_id => identifier}
end
end
end
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)
job_name = "#{qa.author_login}-#{rep_id}"
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}")
qa.delete
respond_to do |format|
@ -198,7 +207,7 @@ class QualityAnalysisController < ApplicationController
@doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties
# update成功则返回 200
jenkins_job = @client.job.update("#{job_name}", @doc.to_xml)
jenkins_job = @client_jenkins.job.update("#{job_name}", @doc.to_xml)
# 数据更新到Trustie数据
if jenkins_job == '200'
logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}")
@ -232,6 +241,21 @@ class QualityAnalysisController < ApplicationController
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read
@complexity =JSON.parse(complexity_date).first
# 获取排名结果
@g = Gitlab.client
@author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch)
@user_quality_infos = []
@author_infos.each do |author_info|
email = author_info.email
changes = author_info.changes.to_i
unresolved_issues = open(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false").read
unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i
all_issues = open(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}").read
all_issue_count = JSON.parse(all_issues)["total"].to_i
ratio = (changes == 0 ? 0 : format("%0.4f",unresolved_issue_count.to_f/changes.to_f))
@user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count}
end
# 按名称转换成hash键值对
@ha = {}
@complexity["msr"].each do |com|
@ -278,9 +302,10 @@ class QualityAnalysisController < ApplicationController
@jenkins_address = Redmine::Configuration['jenkins_address']
jenkins_username = Redmine::Configuration['jenkins_username']
jenkins_password = Redmine::Configuration['jenkins_password']
logger.info("22222222222222222222222222222222")
# 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
logger.error("failed to connect Jenkins ==> #{e}")
end

View File

@ -386,9 +386,9 @@ update
project_score.update_column(:changeset_num, @changesets_all_count)
end
# unless @changesets_latest_coimmit.blank?
# update_commits_date(@project, @changesets_latest_coimmit)
# end
unless @changesets_latest_coimmit.blank?
update_commits_date(@project, @changesets_latest_coimmit)
end
@creator = @project.owner.to_s
gitlab_address = Redmine::Configuration['gitlab_address']

View File

@ -188,11 +188,12 @@ class SchoolController < ApplicationController
user_extention.school_id = school.id
user_extention.save!
# status=4 向管理员发送信息
# 向管理员发送信息
users = User.where(:admin => 1)
users.each do |user|
AppliedMessage.create(:user_id => user.id, :status => 4, :applied_user_id => User.current.id, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name )
AppliedMessage.create(:user_id => user.id, :status => 0, :applied_user_id => User.current.id, :viewed => 0, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name )
end
else
data[:result] = 3
end

View File

@ -597,6 +597,7 @@ class StudentWorkController < ApplicationController
student_work.description = params[:student_work][:description]
student_work.homework_common_id = @homework.id
student_work.user_id = User.current.id
student_work.commit_time = Time.now
student_work.save_attachments(params[:attachments])
render_attachment_warning_if_needed(student_work)
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
@ -733,24 +734,33 @@ class StudentWorkController < ApplicationController
end
def destroy
if @work.destroy
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
pros = @work.student_work_projects.where("is_leader = 0")
pros.each do |pro|
pro.destroy
end
project = @work.student_work_projects.where("is_leader = 1").first
project.update_attributes(:student_work_id => nil)
elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
@work.student_work_projects.each do |pro2|
pro2.destroy
if @homework.homework_type == 3
if @work.destroy
if @homework.homework_detail_group.base_on_project == 1
pros = @work.student_work_projects.where("is_leader = 0")
pros.each do |pro|
pro.destroy
end
project = @work.student_work_projects.where("is_leader = 1").first
project.update_attributes(:student_work_id => nil)
elsif @homework.homework_detail_group.base_on_project == 0
@work.student_work_projects.each do |pro2|
pro2.destroy
end
end
end
respond_to do |format|
format.html {
redirect_to student_work_index_url(:homework => @homework.id)
}
end
else
@work.attachments.destroy_all
@work.student_works_scores.destroy_all
@work.course_messages.destroy_all
@work.student_work_tests.destroy_all
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil,:final_score => nil,:teacher_score => nil,:student_score => nil,:teaching_asistant_score => nil,:system_score => 0,:work_score => nil)
@work.update_column("work_score",nil)
end
respond_to do |format|
format.html {
redirect_to student_work_index_url(:homework => @homework.id)
}
end
end
@ -775,30 +785,35 @@ class StudentWorkController < ApplicationController
end
def retry_work
if @work.destroy
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
pros = @work.student_work_projects.where("is_leader = 0")
pros.each do |pro|
pro.destroy
end
project = @work.student_work_projects.where("is_leader = 1").first
project.update_attributes(:student_work_id => nil)
elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
@work.student_work_projects.each do |pro2|
pro2.destroy
if @homework.homework_type == 3
if @work.destroy
if @homework.homework_detail_group.base_on_project == 1
pros = @work.student_work_projects.where("is_leader = 0")
pros.each do |pro|
pro.destroy
end
project = @work.student_work_projects.where("is_leader = 1").first
project.update_attributes(:student_work_id => nil)
elsif @homework.homework_detail_group.base_on_project == 0
@work.student_work_projects.each do |pro2|
pro2.destroy
end
end
end
@student_work = StudentWork.new
respond_to do |format|
format.js
end
elsif @homework.homework_type == 1
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil)
@work.attachments.destroy_all
@work.course_messages.destroy_all
end
@student_work = StudentWork.new
respond_to do |format|
format.js
end
end
#添加评分,已评分则为修改评分
def add_score
@is_last = params[:is_last] == "true"
render_403 and return if User.current == @work.user #不可以匿评自己的作品
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
@ -823,12 +838,12 @@ class StudentWorkController < ApplicationController
@new_score.user_id = User.current.id
@new_score.student_work_id = @work.id
if @is_teacher && @work.work_status == 0
@work.update_column('work_status', 1)
@work.update_attributes(:work_status => 1, :commit_time => Time.now)
end
if User.current.admin?
@new_score.reviewer_role = 1
else
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
role = User.current.members.where("course_id = ?",@course.id).first.roles.where("is_current = 1").first.name
@new_score.reviewer_role = get_role_by_name(role)
end
if @score
@ -864,6 +879,7 @@ class StudentWorkController < ApplicationController
update_org_activity(@homework.class,@homework.id)
if @work.save
@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|
format.js
end

View File

@ -41,7 +41,8 @@ class UsersController < ApplicationController
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
: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_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,
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -352,14 +353,14 @@ class UsersController < ApplicationController
def dealwith_apply_request
@msg = CourseMessage.find(params[:msg_id])
#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]
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))
#将角色改为老师或者教辅
member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0]
@ -382,11 +383,32 @@ class UsersController < ApplicationController
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)
@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
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)
@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
respond_to do |format|
format.js
@ -592,23 +614,25 @@ class UsersController < ApplicationController
#用户作业列表
def user_homeworks
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
@user = User.current
@r_sort = @b_sort == "desc" ? "asc" : "desc"
if(params[:type].blank? || params[:type] == "1") #我的题库
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #题库
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #公共题库
visible_course = Course.where("is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
end
@type = params[:type]
@limit = 25
@limit = 10
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,25
@homeworks = paginateHelper @homeworks,10
respond_to do |format|
format.js
format.html {render :layout => 'static_base'}
@ -641,15 +665,15 @@ class UsersController < ApplicationController
end
def choose_user_course
homework = HomeworkCommon.find params[:send_id].to_i
if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course)
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i)
if ah.empty?
@status = 2
elsif ah.first.status != 2
@status = ah.first.status
end
end
homework = HomeworkCommon.find params[:homework].to_i
# if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course)
# ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i)
# if ah.empty?
# @status = 2
# elsif ah.first.status != 2
# @status = ah.first.status
# end
# end
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
@ -658,7 +682,7 @@ class UsersController < ApplicationController
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_id = params[:homework]
respond_to do |format|
format.js
end
@ -737,7 +761,7 @@ class UsersController < ApplicationController
#@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
courses = @user.courses.where("is_delete = 1")
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}")
@type = params[:type]
@limit = 15
@is_remote = true
@ -751,30 +775,26 @@ class UsersController < ApplicationController
end
def user_homework_type
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
@r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
if(params[:type].blank? || params[:type] == "1") #我的题库
courses = @user.courses.where("is_delete = 1")
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}")
elsif params[:type] == "2" #题库
if params[:is_import].to_i == 1
visible_course = Course.where("is_public = 1 && is_delete = 0")
elsif params[:is_import].to_i == 0
visible_course = Course.where("is_delete = 0")
end
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #公共题库
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
elsif params[:type] == "3" #申请题库
none_visible_course = Course.where("is_delete = 1")
none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
#apply_homeworks = ApplyHomework.where("user_id = ?",@user.id).order('created_at desc')
#homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")"
#@homeworks = HomeworkCommon.where("id in #{homework_ids} and course_id not in #{none_visible_course_ids}")
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN apply_homeworks as ah ON homework_commons.id = ah.homework_common_id where ah.user_id = #{@user.id} and homework_commons.course_id not in #{none_visible_course_ids} order by ah.created_at desc"
@homeworks = HomeworkCommon.find_by_sql(sql)
# elsif params[:type] == "3" #申请题库
# none_visible_course = Course.where("is_delete = 1")
# none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
# #apply_homeworks = ApplyHomework.where("user_id = ?",@user.id).order('created_at desc')
# #homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")"
# #@homeworks = HomeworkCommon.where("id in #{homework_ids} and course_id not in #{none_visible_course_ids}")
#
# sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN apply_homeworks as ah ON homework_commons.id = ah.homework_common_id where ah.user_id = #{@user.id} and homework_commons.course_id not in #{none_visible_course_ids} order by ah.created_at desc"
# @homeworks = HomeworkCommon.find_by_sql(sql)
end
if params[:property]
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
@ -792,7 +812,7 @@ class UsersController < ApplicationController
@type = params[:type]
@property = params[:property]
@is_import = params[:is_import]
@limit = params[:is_import].to_i == 1 ? 15 : 25
@limit = params[:is_import].to_i == 1 ? 15 : 10
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@ -827,28 +847,24 @@ class UsersController < ApplicationController
#用户主页过滤作业
def user_search_homeworks
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@order,@b_sort = params[:order] || "publish_time",params[:sort] || "desc"
@r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
search = params[:name].to_s.strip.downcase
type_ids = params[:property]=="" || params[:property].nil? ? "(1, 2, 3)" : "(" + params[:property] + ")"
type_ids = (params[:property]=="" || params[:property].nil? || params[:property]=="0") ? "(1, 2, 3)" : "(" + params[:property] + ")"
if(params[:type].blank? || params[:type] == "1") #我的题库
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
end
elsif params[:type] == "2" #题库
if params[:is_import].to_i == 1
visible_course = Course.where("is_public = 1 && is_delete = 0")
elsif params[:is_import].to_i == 0
visible_course = Course.where("is_delete = 0")
end
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
all_user_ids = all_homeworks.map{|hw| hw.user_id}
@ -886,7 +902,7 @@ class UsersController < ApplicationController
end
=end
@type = params[:type]
@limit = params[:is_import].to_i == 1 ? 15 : 25
@limit = params[:is_import].to_i == 1 ? 15 : 10
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@ -900,6 +916,19 @@ class UsersController < ApplicationController
end
end
#检查改作业是否可以选用
def check_homework
homework = HomeworkCommon.find_by_id params[:homework]
student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',')
resultObj = {status: 2}
if student_ids.include?(User.current.id.to_s)
resultObj[:status] = 1
else
resultObj[:status] = 0
end
render :json => resultObj
end
#导入作业,确定按钮
def user_select_homework
homework = HomeworkCommon.find_by_id params[:checkMenu]
@ -996,6 +1025,7 @@ class UsersController < ApplicationController
student_work.work_status = 1
end
student_work.commit_time = Time.now
student_work.save
send_message_to_teacher(student_work)
homework.update_column(:updated_at, Time.now)
@ -1085,23 +1115,8 @@ class UsersController < ApplicationController
homework_detail_programing.save if homework_detail_programing
homework_detail_group.save if homework_detail_group
if homework.homework_type != 3
students = homework.course.student
if !homework.course.nil? && !students.empty?
name = homework.name
name_str = name + "的作品提交"
str = ""
students.each do |student|
if str != ""
str += ","
end
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
end
#('#{name}的作品提交',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
#StudentWork.create(:name => "#{name}的作品提交", :homework_common_id => homework.id, :user_id => student.student_id)
ActiveRecord::Base.connection.execute sql
end
if homework.homework_type != 3 && homework_detail_manual.comment_status == 1
create_works_list homework
end
if params[:quotes] && !params[:quotes].blank?
@ -1444,26 +1459,15 @@ class UsersController < ApplicationController
#显示更多用户课程
def user_courses4show
@page = params[:page].to_i + 1
@type = params[:type]
if @type == 'User'
@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
@all_count = @user.courses.visible.where("is_delete =?", 0).count
elsif @type == 'Syllabus'
@syllabus = Syllabus.where("id = #{params[:syllabus]}").first
if User.current == @syllabus.user || User.current.admin?
all_courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
else
all_courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
end
@courses = all_courses.limit(5).offset(@page * 5)
@all_count = all_courses.count
end
@courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10).offset(@page * 10)
@all_count = @user.favorite_courses.visible.where("is_delete =?", 0).count
end
#显示更多用户项目
def user_projects4show
@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(5).offset(@page * 5)
@projects = @user.favorite_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.favorite_projects.visible.count
end
def user_course_activities
@ -1529,6 +1533,107 @@ class UsersController < ApplicationController
render :action=>'user_course_activities',:layout=>nil
end
#首页-》我的作业
def my_homeworks
tea_courses = @user.courses.visible.not_deleted.select{|course| @user.has_teacher_role(course)}
tea_course_ids = tea_courses.empty? ? "(-1)" : "(" + tea_courses.map{|course| course.id}.join(',') + ")"
@manage_homeworks = HomeworkCommon.where("course_id in #{tea_course_ids}").order("created_at desc").limit(5)
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(',') + ")"
@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.created_at > @receive_homeworks.first.created_at)
@manage_pre = true
else
@manage_pre = false
end
respond_to do |format|
format.js
format.html {render :layout => 'static_base'}
end
end
#我管理/收到的作业
def manage_or_receive_homeworks
@order,@b_sort,@type = params[:order] || "created_at",params[:sort] || "desc",params[:type] || 1
@r_sort = @b_sort == "desc" ? "asc" : "desc"
@type = @type.to_i
if @type == 1
tea_courses = @user.courses.visible.not_deleted.select{|course| @user.has_teacher_role(course)}
tea_course_ids = tea_courses.empty? ? "(-1)" : "(" + tea_courses.map{|course| course.id}.join(',') + ")"
@homeworks = HomeworkCommon.where("course_id in #{tea_course_ids}").order("#{@order} #{@b_sort}")
else
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(',') + ")"
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
end
if params[:property]
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
if params[:property] == "1"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
elsif params[:property] == "2"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
elsif params[:property] == "3"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
end
end
@limit = 10
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,@limit
@search = ""
@property = params[:property]
respond_to do |format|
format.js
format.html {render :layout => 'static_base'}
end
end
#搜索作业
def search_m_r_homeworks
@order,@b_sort,@type = params[:order] || "created_at",params[:sort] || "desc",params[:type].to_i || 1
@r_sort = @b_sort == "desc" ? "asc" : "desc"
search = params[:name].to_s.strip.downcase
type_ids = (params[:property]=="" || params[:property].nil? || params[:property]=="0") ? "(1, 2, 3)" : "(" + params[:property] + ")"
if @type == 1
tea_courses = @user.courses.visible.not_deleted.select{|course| @user.has_teacher_role(course)}
tea_course_ids = tea_courses.empty? ? "(-1)" : "(" + tea_courses.map{|course| course.id}.join(',') + ")"
#user_ids = hw_publisher_user_ids search, tea_course_ids
@homeworks = HomeworkCommon.where("course_id in #{tea_course_ids} and homework_type in #{type_ids} and name like '%#{search}%'").order("#{@order} #{@b_sort}")
else
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(',') + ")"
#user_ids = hw_publisher_user_ids search, stu_course_ids
@homeworks = HomeworkCommon.where("course_id in #{stu_course_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and name like '%#{search}%'")
if @order == "status"
@homeworks.each do |homework|
work = cur_user_works_for_homework homework
if work.blank?
homework[:infocount] = 0
else
homework[:infocount] = 1
end
end
@b_sort == "asc" ? (@homeworks = @homeworks.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@homeworks = @homeworks.sort{|x,y| y[:infocount] <=> x[:infocount]})
@homeworks = sortby_time_countcommon_nosticky @homeworks,"created_at"
else
@homeworks = @homeworks.order("#{@order} #{@b_sort}")
end
end
@limit = 10
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,@limit
@search = search
@property = params[:property]
respond_to do |format|
format.js
end
end
def user_feedback4show
query = @user.journals_for_messages
if params[:lastid]!=nil && !params[:lastid].empty?
@ -3247,6 +3352,7 @@ class UsersController < ApplicationController
@join_syllabuses = syllabus_course_list_sort @join_syllabuses
@my_syllabuses = @my_syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]}
@join_syllabuses = @join_syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]}
@is_course = 1
#分页
# @limit = 10
@ -3318,8 +3424,45 @@ class UsersController < ApplicationController
end
end
#收藏班级/项目
def cancel_or_collect
if params[:project]
@project = Project.find params[:project]
member = Member.where("user_id = #{@user.id} and project_id = #{@project.id}")
elsif params[:course]
@course = Course.find params[:course]
member = Member.where("user_id = #{@user.id} and course_id = #{@course.id}")
end
unless member.empty?
member.first.update_attribute(:is_collect, member.first.is_collect == 0 ? 1 : 0)
end
if @project
@projects = @user.favorite_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)
elsif @course
@courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10)
end
respond_to do |format|
format.js
end
end
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
if @order.to_i == @type.to_i
@ -3328,11 +3471,16 @@ class UsersController < ApplicationController
@c_sort = 2
end
sort_name = "updated_at"
sort_name = "updatetime"
sort_type = @c_sort == 1 ? "asc" : "desc"
#@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
if @order.to_i == 2
@ -3349,17 +3497,8 @@ class UsersController < ApplicationController
@type = 1
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
respond_to do |format|
format.js
format.html {render :layout => 'new_base_user'}
end
end

View File

@ -10,8 +10,8 @@ class WechatsController < ActionController::Base
#邀请码
if join_class_request(request)
sendBindClass(request, {invite_code: content})
# elsif join_project_request(request)
# sendBindProject(request, {invite_code: content})
elsif join_project_request(request)
sendBindProject(request, {invite_code: content})
else
request.reply.text "您的意见已收到,非常感谢~ \n更多问题可以通过以下方式联系我们:\n官方QQ群173184401\n我们会认真聆听您的意见和建议。"
end
@ -49,7 +49,7 @@ class WechatsController < ActionController::Base
# When no any on :scan responder can match subscribe user scaned scene_id
on :event, with: 'scan' do |request|
if request[:EventKey].present?
sendBindClass(request, {ticket: request[:Ticket]})
checkTicket(request, {ticket: request[:Ticket]})
end
end
@ -137,7 +137,7 @@ class WechatsController < ActionController::Base
on :fallback, respond: 'fallback message'
on :click, with: 'FEEDBACK' do |request, key|
request.reply.text "如有反馈问题,请直接切换至输入框,发微信给我们即可"
request.reply.text "如有问题反馈,请您:\n1、直接切换至输入框发微信给我们。\n2、加入QQ群173184401我们直接互动。\n欢迎大家积极反馈,谢谢啦!"
end
on :click, with: 'MY_NEWS' do |request, key|
@ -149,13 +149,13 @@ class WechatsController < ActionController::Base
end
on :click, with: 'JOIN_PROJECT' do |request, key|
request.reply.text "该功能将在近日开放,敬请期待!"
# uw = user_binded?(request[:FromUserName])
# unless uw
# sendBind(request)
# else
# request.reply.text "请直接回复6位项目邀请码\n(不区分大小写):"
# end
# request.reply.text "该功能将在近日开放,敬请期待!"
uw = user_binded?(request[:FromUserName])
unless uw
sendBind(request)
else
request.reply.text "请直接回复6位项目邀请码\n(不区分大小写):"
end
end
on :click, with: 'JOIN_CLASS' do |request, key|
@ -209,6 +209,39 @@ class WechatsController < ActionController::Base
end
end
def checkTicket(request,params)
begin
uw = user_binded?(request[:FromUserName])
if !uw
return sendBind(request)
end
course = nil
course = Course.where(qrcode: params[:ticket]).first if params[:ticket]
course = Course.where(invite_code: params[:invite_code]).first if params[:invite_code]
if course
return join_class(params, uw.user, request)
else
project = nil
project = Project.where(qrcode: params[:ticket]).first if params[:ticket]
project = Project.where(invite_code: params[:invite_code]).first if params[:invite_code]
if project
return join_project(params, uw.user, request)
end
end
raise "该二维码已失效"
rescue => e
logger.error e.inspect
logger.error e.backtrace.join("\n")
return request.reply.text e
end
end
def default_msg(request)
uw = user_binded?(request[:FromUserName])
if uw && uw.user
@ -219,13 +252,16 @@ class WechatsController < ActionController::Base
end
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创新实践服务平台
" } }
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"
article.item title: "#{n[:title]}",
description: n[:content],
@ -251,7 +287,7 @@ class WechatsController < ActionController::Base
end
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
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"
@ -273,18 +309,18 @@ class WechatsController < ActionController::Base
role = 5
ps = ProjectsService.new
status = ps.join_project({invite_code: project.invite_code}, user)
if status[:state] != 0
raise ProjectService::JoinProjectError.message(status)
status = ps.join_project({role:5, invite_code: project.invite_code}, user)
if status != 0
raise ProjectsService::JoinProjectError.message(status)
end
creator = User.find(project.user_id)
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
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/class.jpg"
pic_url = "#{ROOT_URL}/images/wechat/project.jpg"
article.item title: "#{n[:title]}",
description: n[:content],
pic_url: pic_url,
@ -300,10 +336,12 @@ class WechatsController < ActionController::Base
code = params[:code] || session[:wechat_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
raise "还未绑定trustie帐户" unless uw
raise "还未绑定trustie帐户" unless (uw && uw.bindtype == 0)
logger.debug "get_bind ============= #{uw}"
user = uw.user
@ -316,13 +354,25 @@ class WechatsController < ActionController::Base
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
begin
code = params[:code] || session[:wechat_code]
openid = get_openid_from_code(code)
raise "无法获取到openid请在微信中打开本页面" unless openid
# raise "无法获取到openid请在微信中打开本页面" unless openid
raise "请在微信中关注Trustie创新实践平台后再打开本页面" unless openid
raise "此微信号已绑定用户,不能重复绑定" if user_binded?(openid)
user, last_login_on = User.try_to_login(params[:username], params[:password])
@ -336,7 +386,7 @@ class WechatsController < ActionController::Base
user: user
)
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: "绑定成功"}
rescue Exception=>e
render :json => {status: -1, msg: e.message}
@ -350,15 +400,31 @@ class WechatsController < ActionController::Base
render 'wechats/user_activities', layout: nil
end
def user_activities
@appid = Wechat.config.appid
## sign
@sign_params = wechat.jsapi_ticket.signature(current_url)
session[:wechat_code] = params[:code] if params[:code]
@path = '/'+(params[:state] || '')
open_id = get_openid_from_code(params[:code]) rescue
unless open_id
render 'wechats/open_wechat', layout: nil and return
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'
else
if params[:state] == 'myclass'
@ -369,7 +435,18 @@ class WechatsController < ActionController::Base
session[:wechat_openid] = open_id
if params[:code]
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
# if params[:state].match("review_class_member") || params[:state].match("review_project_member")
@path = params[:state].split('/')[0]
useridstr = params[:state].split('/')[1]
# end
if useridstr
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&#{useridstr}" 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
render 'wechats/user_activities', layout: nil
@ -380,10 +457,19 @@ class WechatsController < ActionController::Base
def get_openid_from_code(code)
return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test'
openid = session[:wechat_openid]
unless openid
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
@ -396,8 +482,16 @@ class WechatsController < ActionController::Base
def user_binded?(openid)
uw = UserWechat.where(openid: openid).first
if uw && uw.bindtype == 0
uw
else
nil
end
end
def current_url
"#{request.protocol}#{request.host_with_port}#{request.fullpath}"
end
end

View File

@ -37,12 +37,25 @@ module ApplicationHelper
# super
# end
# 隐藏项目以外的信息
# return: true 显示false 不显示
def hidden_unproject_infos
hidden_info = Setting.find_by_name("hidden_non_project")
(hidden_info && hidden_info.value == "1") ? true : false
end
# 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换
def get_user_by_mail mail
user = User.find_by_mail(mail)
user.nil? ? User.find(2) : user
end
# 通过系统外部用户名查找用户,如果用户不存在则用邮箱替换
def get_user_by_login_and login
user = User.find_by_login(login)
user.nil? ? User.find(2) : user
end
# 历史数据(老版本库数据)处理完则可以修改该放放
def get_rep_identifier_by_project project
identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier)
@ -814,6 +827,23 @@ module ApplicationHelper
return @result
end
def show_attachment_tip container_id, container_type
atts = Attachment.where(:container_id => container_id, :container_type => container_type, :is_public => 0)
atts.count > 0 ? true :false
end
# 必须是项目成,项目必须提交过代码
def allow_pull_request project
return false if project.gpid.nil?
g = Gitlab.client
count = g.user_static(project.gpid, :rev => "master").count
if User.current.member_of?(project) && count > 0
true
else
false
end
end
# 判断版本库是否初始为gitlab
def rep_is_gitlab?(project)
rep = project.repositories.where("type =?", "Repository::Gitlab")
@ -2151,10 +2181,10 @@ module ApplicationHelper
candown= User.current.member_of_course?(course) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
elsif attachment.container.is_a?(OrgSubfield)
org = attachment.container.organization
candown = User.current.member_of_org?(org) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
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)
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 &&
attachment.container.board.course
course = attachment.container.board.course
@ -2501,7 +2531,7 @@ module ApplicationHelper
def footer_logo(ul_class=nil, li_class=nil)
logos = []
logos.push(link_to image_tag('/images/footer_logo/nudt.png',:alt=>"nudt"),"http://www.nudt.edu.cn/special.asp?classid=12" )
logos.push(link_to image_tag('/images/footer_logo/peking_eecs.png', :alt=>"peking_eecs"), "http://eecs.pku.edu.cn" )
logos.push(link_to image_tag('/images/footer_logo/peking_eecs.png', :alt=>"peking_eecs"), "http://www.sei.pku.edu.cn/" )
logos.push(link_to image_tag('/images/footer_logo/buaa_scse.png', :alt=>"buaa_scse"), "http://scse.buaa.edu.cn/" )
logos.push(link_to image_tag('/images/footer_logo/iscas.png', :alt=>"iscas"), "http://www.iscas.ac.cn" )
logos.push(link_to image_tag('/images/footer_logo/inforbus.png', :alt=>"inforbus"), "http://www.inforbus.com" )
@ -2720,7 +2750,7 @@ module ApplicationHelper
link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
end
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 => "开启匿评后不可修改作品"
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 => "匿评已结束"
@ -2736,7 +2766,39 @@ module ApplicationHelper
else
link_to "作品(#{count})",student_work_index_url_in_org(homework.id),:class => "c_blue"
end
end
#根据传入作业确定显示为提交作品、补交作品、查看作品等
def student_for_homework_common homework
if User.current.member_of_course?(homework.course)
work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework
if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "查看详情", homework_common_index_path(:course_id => homework.course_id), :class => 'hw_btn_green2 fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
link_to "提交作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green2 fr mt5', :target => '_blank'
end
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "查看详情", homework_common_index_path(:course_id => homework.course_id), :class => 'hw_btn_green2 fr mt5',:title => '查看分组作业详情', :target => '_blank'
else
link_to "补交作品", new_student_work_url_without_domain(homework.id),:class => 'btn_orange_big fr mt5', :target => '_blank'
end
else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
link_to "作品匿评", student_work_index_url_in_org(homework.id), :class => 'hw_btn_green2 fr mt5', :title => "开启匿评后不可修改作品", :target => '_blank'
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品",student_work_index_url_in_org(homework.id), :class => 'hw_btn_green2 fr mt5', :title => "匿评已结束", :target => '_blank'
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
link_to "修改作品", new_student_work_url_without_domain(homework.id),:class => 'hw_btn_green2 fr mt5', :target => '_blank'
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
link_to "修改作品", edit_student_work_url_without_domain(work.id),:class => 'hw_btn_green2 fr mt5', :target => '_blank'
else
link_to "查看作品", student_work_index_url_in_org(homework.id), :class => 'hw_btn_green2 fr mt5', :title => "作业截止后不可修改作品", :target => '_blank'
end
end
end
end
def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity
@ -2788,6 +2850,17 @@ module ApplicationHelper
homework.student_work_projects.where("user_id = ?",User.current).first
end
#获取当前作业的提交截止时间/互评截止时间
def cur_homework_end_time homework
str = ""
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}"
else
str = "提交截止:#{homework.end_time ? (format_date homework.end_time) : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}"
end
str
end
def file_preview_tag(file, html_options={})
if %w(pdf pptx doc docx xls xlsx).any?{|x| file.filename.downcase.end_with?(x)}
link_to '预览', download_named_attachment_path(file.id, file.filename, preview: true),html_options
@ -3375,3 +3448,27 @@ def course_syllabus_option user = User.current
end
type
end
def create_works_list homework
students = homework.course.student
if !homework.course.nil? && !students.empty?
name = homework.name
name_str = name + "的作品提交"
str = ""
students.each do |student|
if str != ""
str += ","
end
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
end
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
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

View File

@ -7,7 +7,7 @@ module OrgMemberHelper
scope = []
end
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
link_to text, host_with_protocol + "/org_member/org_member_autocomplete?" + parameters.merge(:q => params[:q],:flag => true,:org=> org, :format => 'js').to_query, :remote => true
}

View File

@ -0,0 +1,50 @@
module PullRequestsHelper
# 获取diff内容行号
def diff_line_num content
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.nil? ? "" : content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i
end
# 处理内容
def diff_content content
content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'')
end
def get_user_name user_id
User.find(user_id).try(:login)
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

View File

@ -1,23 +1,33 @@
# encoding: utf-8
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
arr = []
if val <= 5
arr << "很好"
arr << "b_green2"
arr << "A"
elsif val. > 5 && val <= 10
arr << "较好"
arr << "b_slow_yellow"
arr << "B"
elsif val > 10 && val <= 20
arr << "中等"
arr << "b_yellow"
arr << "C"
elsif val > 20 && val <= 50
arr << "较差"
arr << "b_slow_red"
arr << "D"
elsif val > 20
arr << "很差"
arr << "b_red"
arr << "E"
end
end

View File

@ -47,9 +47,9 @@ module RepositoriesHelper
end
# 获取文件目录的最新动态
def get_trees_last_changes(project_id, rev, ent_name, g)
def get_trees_last_changes(gpid, rev, ent_name, g)
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
puts e
end

View File

@ -80,6 +80,19 @@ module UsersHelper
# end
end
def applied_project_status applied_message
case applied_message.status
when 4
"被拒绝"
when 5
"您已拒绝"
when 6
"已通过"
when 7
"您已同意"
end
end
# 项目申请消息通过状态判断tip描述
def applied_project_tip applied_message
case applied_message.status
@ -92,6 +105,35 @@ module UsersHelper
end
end
# 单位申请消息:通过用户的状态判断
# status(0申请消息1,2,3系统消息)
def applied_school_users applied_message
user = User.find(applied_message.applied_user_id)
end
# 单位申请消息通过状态判断tip描述
def applied_school_tip applied_message
case applied_message.status
when 1,2,3
"您添加新的单位:"
when 0
"申请了单位:"
end
end
def applied_project_tip_header applied_message
case applied_message.status
when 4
"婉拒您"
when 5,3,2,1,7
"申请:"
when 6
"同意您"
end
end
def get_resource_origin attach
type = attach.container_type
content = attach.container
@ -742,4 +784,17 @@ module UsersHelper
end
syllabuses
end
#获取按作业的发布者排序的用户ID
def hw_publisher_user_ids search, course_ids
if search && search != ""
all_homeworks = HomeworkCommon.where("course_id in #{course_ids}")
all_user_ids = all_homeworks.map{|hw| hw.user_id}
user_str_ids = search_user_by_name all_user_ids, search
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
else
user_ids = "(-1)"
end
return user_ids
end
end

View File

@ -1,3 +1,4 @@
#coding=utf-8
class AppliedProject < ActiveRecord::Base
attr_accessible :project_id, :user_id, :role
@ -11,6 +12,14 @@ class AppliedProject < ActiveRecord::Base
def send_appliled_message
self.project.managers.each do |member|
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id, :role => self.role, :project_id => self.project_id)
#----------------微信通知----------------------
count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
if count == 0
ws = WechatService.new
ws.project_review_notice member.user_id, "review_project_member", self.project_id, "项目成员审批通知。", self.project.name, self.user.show_name, format_time(Time.now),"点击查看申请详情。",self.user.id
end
#--------------------------------------------
end
# end
end

View File

@ -4,13 +4,5 @@ class ApplyAddSchools < ActiveRecord::Base
has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied
belongs_to :school
after_create :send_massage
#给系统所有管理发送消息
def send_massage
users = User.where(:admin => 1)
users.each do |user|
self.applied_messages << AppliedMessage.new(:user_id => user.id, :viewed => false, :status => false)
end
end
#after_create :send_massage
end

View File

@ -80,6 +80,7 @@ class Course < ActiveRecord::Base
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
before_destroy :delete_all_members,:delete_course_ealasticsearch_index
after_save :log_infor
safe_attributes 'extra',
'time',
@ -504,6 +505,10 @@ class Course < ActiveRecord::Base
ticket
end
def log_infor
Rails.logger.info "##########################################################course's syllabus_id is #{self.syllabus_id}."
end
end

View File

@ -34,6 +34,20 @@ class HomeworkCommon < ActiveRecord::Base
after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets
#作业类型
def homework_type_ch
type = self.homework_type
case type
when 1
type = "普通"
when 2
type = "编程"
when 3
type = "分组"
end
type
end
def act_as_activity
self.acts << Activity.new(:user_id => self.user_id)
end
@ -63,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
if count == 0
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

View File

@ -52,6 +52,9 @@ class Member < ActiveRecord::Base
ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
new_role_ids = ids - role_ids
if (new_role_ids.include?(7) || new_role_ids.include?(9)) && role_ids.include?(10)
member_roles.where("role_id = 10").first.update_column('is_current', 0)
end
# Add new roles
if new_role_ids.include?(7) && new_role_ids.include?(10)
member_roles << MemberRole.new(:role_id => 7)

View File

@ -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
if count == 0
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, "点击查看通知详情"
end
end

View File

@ -131,6 +131,22 @@ class Principal < ActiveRecord::Base
columns.uniq.map {|field| "#{table}.#{field}"}
end
#收藏的课程
def favorite_courses
members = Member.where("user_id = #{self.id} and course_id != -1 and is_collect = 1")
course_ids = members.empty? ? "(-1)" : "(" + members.map{|member| member.course_id}.join(",") + ")"
courses = Course.where("id in #{course_ids}")
return courses
end
#收藏的项目
def favorite_projects
members = Member.where("user_id = #{self.id} and project_id != -1 and project_id != 0 and is_collect = 1")
project_ids = members.empty? ? "(-1)" : "(" + members.map{|member| member.project_id}.join(",") + ")"
projects = Project.where("id in #{project_ids}")
return projects
end
protected
# Make sure we don't try to insert NULL values (see #4632)

View File

@ -928,6 +928,18 @@ class Project < ActiveRecord::Base
code
end
def generate_qrcode
ticket = self.qrcode
if !ticket || ticket.size < 10
response = Wechat.api.qrcode_create_scene(invite_code, 2592000)
logger.debug "response = #{response}"
self.qrcode = response['ticket']
save!
ticket = qrcode
end
ticket
end
private
def after_parent_changed(parent_was)
@ -1224,8 +1236,7 @@ class Project < ActiveRecord::Base
# 创建项目后在项目下同步创建一个讨论区
def create_board_sync
@board = self.boards.build
self.name=" #{l(:label_borad_project) }"
@board.name = self.name
@board.name = " #{l(:label_borad_project) }"
@board.description = self.name.to_s
if @board.save
logger.debug "[Project Model] ===> #{@board.to_json}"
@ -1243,12 +1254,14 @@ class Project < ActiveRecord::Base
def create_project_ealasticsearch_index
return if Rails.env.development?
if self.is_public
self.__elasticsearch__.index_document
end
end
def update_project_ealasticsearch_index
return if Rails.env.development?
if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
begin
self.__elasticsearch__.update_document
@ -1265,6 +1278,7 @@ class Project < ActiveRecord::Base
end
def delete_project_ealasticsearch_index
return if Rails.env.development?
begin
self.__elasticsearch__.delete_document
rescue => e

View File

@ -0,0 +1,4 @@
class PullRequest < ActiveRecord::Base
attr_accessible :gpid, :pull_request_id, :user_id
validates_uniqueness_of :pull_request_id
end

View File

@ -1,6 +1,6 @@
#学生提交作品表
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
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time
belongs_to :homework_common
belongs_to :user

View File

@ -34,7 +34,7 @@ class Tracker < ActiveRecord::Base
end
has_and_belongs_to_many :projects
has_and_belongs_to_many :courses
# has_and_belongs_to_many :courses
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
acts_as_list

View File

@ -228,7 +228,7 @@ class User < Principal
# Prevents unauthorized assignments
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
LOGIN_LENGTH_LIMIT = 25
LOGIN_LENGTH_LIMIT = 30
MAIL_LENGTH_LIMIT = 60
validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
@ -926,6 +926,13 @@ class User < Principal
!role.blank?
end
#是否具有学生角色
def has_student_role(course)
member = course.members.where("user_id = #{self.id}").first
role = MemberRole.where("member_id = #{member.id} and role_id = 10")
!role.blank?
end
# Return true if the user is allowed to do the specified action on a specific context
# Action can be:
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')

View File

@ -1,6 +1,27 @@
class UserWechat < ActiveRecord::Base
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
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

View File

@ -97,20 +97,159 @@ class CoursesService
end
users = []
@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
work_unit = get_user_work_unit m.user
location = get_user_location m.user
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,
role_name: m.roles.first.name,
name: m.user.show_name,
roles_id: m.roles[0].id,
:brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname}
role_ids = []
m.roles.each do |r|
role_ids << r.id
end
#双重身份 学生列表中不显示
# unless (params[:role] == '2' && role_ids.length >= 2)
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,
role_name: m.roles.first.name,
name: m.user.show_name,
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}
# end
end
users
end
def reviewers_list course_id
reviewers = []
c = Course.find(course_id)
if c
messages = CourseMessage.where("course_id=? and course_message_type = 'JoinCourseRequest' and status = 0 ",course_id)
messages.each do |m|
user = User.find(m.course_message_id)
if user
img_url = url_to_avatar(user)
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
work_unit = get_user_work_unit user
location = get_user_location user
roles_ids = m.content.split(",")
reviewers << {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender,
:work_unit => work_unit, :mail => user.mail, :location => location,
role_name: "",
name: user.show_name,
roles_id: roles_ids.include?("7") ? 7 : 9,
:brief_introduction => user.user_extensions.brief_introduction,:realname=>user.realname}
end
end
end
reviewers
end
def get_reviewer_info params
status = -1
info = nil
c = Course.find(params[:course_id])
if c
messages = CourseMessage.where("course_id=? and course_message_id = ? and course_message_type = 'JoinCourseRequest' ",params[:course_id],params[:user_id]).last
if messages
#status 0未处理 1同意 2 通过
status = messages.status
user = User.find(params[:user_id])
if user
img_url = url_to_avatar(user)
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
work_unit = get_user_work_unit user
location = get_user_location user
roles_ids = messages.content.split(",")
info = {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender,
:work_unit => work_unit, :mail => user.mail, :location => location,
role_name: "",
name: user.show_name,
roles_id: roles_ids.include?("7") ? 7 : 9,
:brief_introduction => user.user_extensions.brief_introduction,:realname=>user.realname}
end
end
end
{status:status,reviewer:info}
end
def deal_join_apply params,current_user
status = -1
message = ""
c = Course.find(params[:course_id])
if c
messages = CourseMessage.where("course_id=? and course_message_id = ? and course_message_type = 'JoinCourseRequest' and status = 0 ",params[:course_id],params[:user_id]).first
if messages
apply_user = User.find(params[:user_id])
ids = messages.content.split(",") # content保存的是申请的职位角色
integer_ids = []
ids.each do |role_id|
integer_ids << role_id.to_i
end
if params[:type] == 0
if apply_user.member_of_course?(c)
#将角色改为老师或者教辅
member = c.members.where(:user_id=>apply_user.id).all[0]
member.role_ids = integer_ids
#删除为学生的记录
unless member.role_ids.include?(10)
joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,c.id)
joined.each do |join|
join.delete
end
end
member.course_group_id = 0
member.save
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=>1)
messages.update_attributes(:status=>1,:viewed=>1)
else
members = []
members << Member.new(:role_ids => integer_ids, :user_id => apply_user.id)
c.members << members
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=>1)
messages.update_attributes(:status=>1,:viewed=>1)
end
if integer_ids.include?(9)
message = "您已同意教师"+apply_user.show_name+",加入班级"
send_wechat_join_class_notice apply_user,c,9,0
else
message = "您已同意助教"+apply_user.show_name+",加入班级"
send_wechat_join_class_notice apply_user,c,7,0
end
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)
messages.update_attributes(:status=>2,:viewed=>1)
if integer_ids.include?(9)
message = "您已拒绝教师"+apply_user.show_name+",加入班级"
send_wechat_join_class_notice apply_user,c,9,1
else
message = "您已拒绝助教"+apply_user.show_name+",加入班级"
send_wechat_join_class_notice apply_user,c,7,1
end
end
status = 0
else
message = "该申请不存在或已被处理"
end
else
message = "该班级不存在或已被删除"
end
{:status => status,:message => message}
end
#获取用户的工作单位
def get_user_work_unit user
work_unit = ""
@ -329,15 +468,17 @@ class CoursesService
0, '加入成功',
1, '密码错误',
2, '班级已过期 请联系班级管理员重启班级。',
3, '您已经加入了班级',
3, '您已经是该班级的成员了',
4, '您的邀请码不正确',
5, '您还未登录',
6, '申请成功,请等待审核完毕',
6, '您的申请已提交,请等待管理员审批',
7, '您已经发送过申请了,请耐心等待',
8, '您已经是该班级的教师了',
9, '您已经是该班级的教辅了',
10, '您已经是该班级的管理员了',
11, '该班级不存在或已被删除啦',
12, '您已经发送过申请了,请耐心等待',
13, '您的申请已提交,请等待管理员审批',
'未知错误,请稍后再试'
]
end
@ -391,6 +532,33 @@ class CoursesService
{:state => @state,:course => course}
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
course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code]
@ -450,6 +618,7 @@ class CoursesService
course.members << members
StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id)
@state = 0
send_wechat_join_class_notice current_user,course,10,0
else
is_stu = false
if role_ids.include?("10")
@ -458,17 +627,34 @@ class CoursesService
course.members << members
StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id)
is_stu = true
send_wechat_join_class_notice current_user,course,10,0
end
#如果已经发送过消息了,那么就要给个提示
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = '#{role_str}' and course_message_id = #{User.current.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
if is_stu
@state = 12
else
@state = 7
end
else
Mailer.run.join_course_request(course, User.current, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
Mailer.run.join_course_request(course, current_user, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>current_user.id,:course_message_type=>'JoinCourseRequest',:status=>0)
#----------------微信通知----------------------
if role_ids.include?("7") || role_ids.include?("9")
tea_user = User.find(course.tea_id)
count = ShieldWechatMessage.where("container_type='User' and container_id=#{tea_user.id} and shield_type='Course' and shield_id=#{course.id}").count
if count == 0
rolename = role_ids.include?("7") ? "助教" : "教师"
content = current_user.show_name + "申请以"+rolename+"身份加入班级,等待您的审批。"
ws = WechatService.new
ws.class_notice tea_user.id, "review_class_member", course.id, "班级成员审批通知。", course.name, tea_user.show_name, format_time(Time.now), content, "点击查看申请详情。",current_user.id
end
end
#--------------------------------------------
if is_stu
@state = 13
else
@ -1054,20 +1240,21 @@ class CoursesService
# end
#修改班级成员角色
def modify_user_course_role params
def modify_user_course_role params,roles_id
status = -1
c = Course.find("#{params[:id]}")
member = c.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
# member = c.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
member = c.members.where("user_id=?",params[:user_id]).first
if member
role = Role.find(params[:role_id])
member.role_ids = roles_id
member.member_roles[0].role_id = params[:role_id]
role = Role.find(roles_id[0])
# 这里的判断只能通过角色名,可以弄成常量
if params[:role_id] == 10
if roles_id && roles_id.include?(10)
StudentsForCourse.create(:student_id => params[:user_id], :course_id =>params[:id])
else
joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:id])
@ -1090,7 +1277,7 @@ class CoursesService
Role.givable.all[3..5]
if member.member_roles[0].save
if member.save
status = 0
end
end

View File

@ -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.each do |jour|
user = jour.user
img_url = url_to_avatar(jour.user)
img_url = "/images/"+url_to_avatar(jour.user)
datetime = jour.created_on
content = jour.notes
end

View File

@ -3,6 +3,9 @@
class ProjectsService
include ApplicationHelper
include ApiHelper
include ActionView::Helpers::DateHelper
include ProjectsHelper
#获取指定用户的项目列表
def user_projects(user)
@ -13,8 +16,8 @@ class ProjectsService
#显示项目
def show_project(params,current_user)
project = Project.find(params[:id])
# project.generate_invite_code
# project.generate_qrcode
project.generate_invite_code
project.generate_qrcode
project
end
@ -101,20 +104,43 @@ class ProjectsService
class JoinProjectError < Errors
define_error [
0, '加入成功',
0, '您已成功加入项目',
1, '您的邀请码不正确',
2, '您还未登录',
3, '您已经是该项目的管理人员',
4, '您已经是该项目的开发人员',
5, '您已经是该项目的报告人员',
6, '该项目不存在或已被删除啦',
7, '您的申请已提交,请等待管理员审批',
8, '您已经发送过申请了,请耐心等待',
'未知错误,请稍后再试'
]
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
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]
if project
if project[:is_delete] == 1
@ -123,23 +149,210 @@ class ProjectsService
if current_user.member_of?(project) #如果已经是成员
member = project.member_principals.includes(:roles, :principal).where("user_id=?",current_user.id).first
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
if params[:invite_code].present?
members = []
members << Member.new(:role_ids => [5], :user_id => current_user.id)
project.members << members
projectInfo = ProjectInfo.new(:user_id => current_user.id, :project_id => project.id)
projectInfo.save
status = 0
if params[:role] == 5
members = []
user_grades = []
project_info = []
user_grades << UserGrade.new(:user_id => current_user.id, :project_id => project.id)
project.user_grades << user_grades unless user_grades.first.user_id.nil?
members << Member.new(:role_ids => ["5"], :user_id => current_user.id)
project.members << members
project_info << ProjectInfo.new(:user_id => current_user.id, :project_id => project.id)
project.project_infos << project_info
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
if !AppliedProject.where(:project_id => project.id, :user_id => current_user.id).first.nil?
status = 8
else
AppliedProject.create(:user_id => current_user.id, :project_id => project.id, :role => params[:role])
status = 7
end
end
else
status = 4
end
end
end
else
status = 4
status = 1
end
status
end
def get_project_review_members(project,role_id,current_user)
review_members = []
if role_id == 3 || role_id == 4
#AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1,
#:applied_type => "AppliedProject")
apply_messages = AppliedMessage.where(:user_id => current_user.id, :project_id => project.id, :status => 1, :role=>role_id)
apply_messages.each do |m|
user = User.find(m.applied_user_id)
if user
img_url = "/images/"+url_to_avatar(user)
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
work_unit = get_user_work_unit user
location = get_user_location user
review_members << {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender,
:work_unit => work_unit, :mail => user.mail, :location => location,
role_name: "",
name: user.show_name,
roles_id: role_id,
:brief_introduction => user.user_extensions.brief_introduction,:realname=>user.realname,:real_name=>user.realname}
end
end
end
review_members
end
def get_reviewer_info params,current_user
status = -1
info = nil
project = Project.find(params[:project_id])
if project
# messages = AppliedProject.where(:project_id=> project.id, :user_id=>params[:user_id]).first
#status 1未处理 5拒绝 7同意
applied_message = AppliedMessage.where(:user_id => current_user.id, :project_id => project.id, :applied_user_id=>params[:user_id],:applied_type => "AppliedProject").last
if applied_message
status = applied_message.status
user = User.find(params[:user_id])
if user
img_url = "/images/"+url_to_avatar(user)
gender = user.user_extensions.gender.nil? ? 0 : user.user_extensions.gender
work_unit = get_user_work_unit user
location = get_user_location user
info = {:id => user.id, :img_url => img_url, :nickname => user.login, :gender => gender,
:work_unit => work_unit, :mail => user.mail, :location => location,
role_name: "",
name: user.show_name,
roles_id: applied_message.role,
:brief_introduction => user.user_extensions.brief_introduction,:realname=>user.realname}
end
end
end
{status:status,reviewer:info}
end
def deal_join_apply params,current_user
status = -1
message = ""
project = Project.find(params[:project_id])
user = User.find(params[:user_id])
if project
applied_messages = AppliedMessage.where(:user_id => current_user.id, :project_id => project.id, :status => 1, :applied_user_id=>user.id,:applied_type => "AppliedProject")
apply_message = applied_messages.first
if apply_message
if user.member_of?(project)
message = "已经是该项目的成员了"
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
applied_project = apply_message.applied
ap_role = applied_project.try(:role)
if ap_role
rolename = ap_role == 3 ? "管理人员" : "开发人员"
if params[:type] == 0
#同意
members = []
user_grades = []
project_info = []
members << Member.new(:role_ids => ["#{ap_role}"], :user_id => user.id)
user_grades << UserGrade.new(:user_id => user.id, :project_id => project.id)
role = Role.find(ap_role)
project_info << ProjectInfo.new(:project_id => project.id, :user_id => user.id) if role.allowed_to?(:is_manager)
project.members << members
project.project_infos << project_info
project.user_grades << user_grades unless user_grades.first.user_id.nil?
# 添加成功后所有管理员收到的消息状态都要更新
applied_messages.update_all(:status => 7, :viewed => true)
# 添加成功后,申请人收到消息
AppliedMessage.create(:user_id => user.id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
:status => 6, :viewed => false, :applied_user_id => current_user.id, :role => applied_project.role, :project_id => applied_project.project_id)
message = "您已同意"+rolename+user.show_name+",加入项目"
send_wechat_join_project_notice user,project,ap_role,0
else
#拒绝
AppliedMessage.create(:user_id => user.id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4,
:viewed => false, :applied_user_id => current_user.id, :role => applied_project.role, :project_id => applied_project.project_id)
applied_messages.update_all(:status => 5, :viewed => true)
applied_project.delete
message = "您已拒绝"+rolename+user.show_name+",加入项目"
send_wechat_join_project_notice user,project,ap_role,1
end
status = 0
else
message = "该申请不存在或已被处理"
end
end
else
message = "该申请不存在或已被处理"
end
else
message = "该项目不存在或已被删除"
end
{:status => status,:message => message}
end
def send_wechat_project_issue_notice user,project,issue_id,issue_title,priority_id
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count
if count == 0
title = "您有新的issue需要解决。"
remark = "点击详情查看issue。"
case priority_id
when "1"
priority = ""
when "2"
priority = "正常"
when "3"
priority = ""
when "4"
priority = "紧急"
when "5"
priority = "立刻"
end
ws = WechatService.new
ws.project_issue_notice user.id, "issues", issue_id,title, issue_title,priority, remark
end
end
end

View File

@ -36,24 +36,21 @@ class SyllabusesService
# courses.each do |c|
# other.courses << c[:course] unless c[:course].syllabus
# end
result = []
i = 0
courses = user.courses.not_deleted
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.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
# syllabuses.to_a << other
syllabuses.to_a
#管理权限 can_setting
# syllabuses.each do |s|
# s = judge_can_setting(s,user)
# end
syllabuses
# syllabuses.to_a
# syllabuses
result
end
def after_create_course(course, user)
@ -72,7 +69,7 @@ class SyllabusesService
if count == 0
ws = WechatService.new
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

View File

@ -80,7 +80,7 @@ class UsersService
#id用户id
def show_user(params)
@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
work_unit = get_user_work_unit @user
location = get_user_location @user
@ -224,7 +224,7 @@ class UsersService
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
course_list = []
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
course_list
end

View File

@ -111,11 +111,17 @@ class WechatService
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+Wechat.config.auto_openid_url_2+type+"/user_id="+uid.to_s+Wechat.config.auto_openid_url_3
end
data = {
touser:openid,
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",
data:{
first: {
@ -139,11 +145,18 @@ class WechatService
data
end
def three_keys_template(openid, template_id, type, id, first, key1, key2, key3, remark="")
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=#{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+Wechat.config.auto_openid_url_2+type+"/user_id="+uid.to_s+Wechat.config.auto_openid_url_3
end
data = {
touser:openid,
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",
data:{
first: {
@ -171,11 +184,18 @@ class WechatService
data
end
def four_keys_template(openid, template_id, type, id, first, key1, key2, key3, key4, remark="")
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=#{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+Wechat.config.auto_openid_url_2+type+"/user_id="+uid.to_s+Wechat.config.auto_openid_url_3
end
data = {
touser:openid,
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",
data:{
first: {
@ -213,7 +233,7 @@ class WechatService
data = {
touser:uw.openid,
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",
data:{
first: {
@ -269,10 +289,10 @@ class WechatService
end
end
def class_notice(user_id, type, id, first, key1, key2, key3, key4, remark="")
def class_notice(user_id, type, id, first, key1, key2, key3, key4, remark="",uid=0)
uw = UserWechat.where(user_id: user_id).first
unless uw.nil?
data = four_keys_template uw.openid,Wechat.config.class_notice, type, id, first, key1, key2, key3, key4, remark
data = four_keys_template uw.openid,Wechat.config.class_notice, type, id, first, key1, key2, key3, key4, remark, uid
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
rescue Exception => e
@ -282,13 +302,26 @@ class WechatService
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="")
uw = UserWechat.where(user_id: user_id).first
unless uw.nil?
data = {
touser:uw.openid,
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",
data:{
first: {
@ -329,7 +362,7 @@ class WechatService
data = {
touser:uw.openid,
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",
data:{
first: {
@ -360,4 +393,43 @@ class WechatService
end
end
def project_review_notice(user_id, type, id, first, key1, key2,key3,remark="",uid=0)
uw = UserWechat.where(user_id: user_id).first
unless uw.nil?
data = three_keys_template uw.openid,Wechat.config.project_review_notice, type, id, first, key1, key2, key3, remark,uid
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
rescue Exception => e
Rails.logger.error "[project_review_notice] ===> #{e}"
end
Rails.logger.info "send over. #{req}"
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
def project_issue_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.project_issue_notice, type, id, first, key1, key2,remark,0
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
rescue Exception => e
Rails.logger.error "[project_issue_notice] ===> #{e}"
end
Rails.logger.info "send over. #{req}"
end
end
end

View File

@ -2,7 +2,7 @@
<div>
<%#= hidden_field_tag(:send_id, edit_id) %>
<div class="courseReferContainer">
<% if !schools.empty? %>
<% if !schools.empty? && !@search.nil? %>
<% schools.each do |school| %>
<ul class="courseSend">
<li class="" style="display:inline-block">

View File

@ -1,11 +1,11 @@
<% if params[:search].nil? %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'admin/all_schools', :locals => {:schools => @schools, :edit_id => @edit_id}) %>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","50%").css("left","50%");
$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'admin/all_schools', :locals => {:schools => @schools, :edit_id => @edit_id}) %>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","50%").css("left","50%");
$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
<% else %>
$("#schools_list").html("<%= escape_javascript(render :partial => 'admin/update_school_form', :locals => {:schools => @schools, :edit_id => @edit_id}) %>");
$("#schools_list").html("<%= escape_javascript(render :partial => 'admin/update_school_form', :locals => {:schools => @schools, :edit_id => @edit_id}) %>");
<% end %>

View File

@ -11,7 +11,7 @@
</label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %>
<%= submit_tag l(:button_apply ), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_schools'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
@ -29,7 +29,7 @@
<th style="width: 30px;">
申请者
</th>
<th style="width: 75px;">
<th style="width: 85px;">
地区
</th>
<th style="width: 75px;">
@ -55,19 +55,19 @@
</td>
<td class="name" title='<%=apply.name%>' >
<span id="apply_title_<%= apply.id %>"><%= apply.name %></span>
<textarea style="display: none; width:100px; height:16px; border:1px solid #ddd; outline:none; padding:0 0 0 5px; resize:none; overflow:hidden;" placeholder="请编辑单位名称" id="school_name_edit_<%=apply.id%>" onblur="edit_school_name('<%= edit_apply_name_school_path(apply.id)%>','<%= apply.id %>');"><%= apply.name %></textarea>
<textarea style="display: none; width:100px; height:16px; border:1px solid #ddd; outline:none; padding:0 0 0 5px; resize:none; overflow:hidden;" placeholder="请编辑单位名称" id="school_name_edit_<%=apply.id%>" onblur="edit_school_name('<%= edit_apply_name_school_path(apply.id)%>','<%= apply.id %>');"></textarea>
</td>
<td class="center">
<% user = User.where("id=?", apply.user_id).first %>
<% unless user.nil? %>
<%=link_to user.show_name, user_path(user),:target => '_blank' %>
<%=link_to user.show_name, user_path(user),:target => '_blank', :class => "application-default-link" %>
<% end %>
</td>
<td class="center">
<span ondblclick = "show_edit_school_province('<%= apply.id %>');" id="apply_province_<%= apply.id %>">
<%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %>
</span>
<select onchange="showcity(this.value, document.getElementById('schoolCity_<%=apply.id%>'));edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="province" id="school_province_edit_<%=apply.id%>" class="fl" style="width:50px; height:18px; display: none">
<select onchange="showcity(this.value, document.getElementById('schoolCity_<%=apply.id%>'));edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="province" id="school_province_edit_<%=apply.id%>" class="fl" style="width:55px; height:18px; display: none">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
@ -104,7 +104,7 @@
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select>
<select onchange="edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="city" id="schoolCity_<%=apply.id%>" class="fl ml5" style="width:50px; height:18px; display: none"></select>
<select onchange="edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="city" id="schoolCity_<%=apply.id%>" class="fl ml5" style="width:55px; height:18px; display: none"></select>
</td>
<td class="center">
<span title="双击可编辑" ondblclick = "show_edit_school_address('<%= apply.id %>');" id="apply_address_<%= apply.id %>"><%= apply.address %></span>
@ -132,7 +132,7 @@
<td>
</td>
<td style="text-align: left;" colspan="6">
<td style="text-align: left;" colspan="7">
<%= apply.remarks %>
</td>
</tr>

View File

@ -11,7 +11,7 @@
</label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %>
<%= submit_tag l(:button_apply ), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'has_applied_schools'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
@ -20,13 +20,13 @@
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 20px;">
<th style="width: 25px;">
序号
</th>
<th style="width: 80px;">
单位名称
</th>
<th style="width: 30px;">
<th style="width: 35px;">
申请者
</th>
<th style="width: 95px;">
@ -59,8 +59,8 @@
<td class="name" title='<%=apply.name%>' >
<% unless apply.school_id.nil? %>
<% school_name = School.where("id=?", apply.school_id).first %>
<span title="双击可编辑" ondblclick = "show_edit_school_name('<%= apply.id %>');" id="apply_title_<%= apply.id %>"><%= school_name %></span>
<textarea style="display: none; width:100px; height:16px; border:1px solid #ddd; outline:none; padding:0 0 0 5px; resize:none; overflow:hidden;" placeholder="请编辑单位名称" id="school_name_edit_<%=apply.id%>" onblur="edit_school_name('<%= edit_apply_name_school_path(apply.id)%>','<%= apply.id %>');"><%= school_name %></textarea>
<span title="双击可编辑" ondblclick = "show_edit_school_name('<%= apply.id %>');" id="apply_title_<%= apply.id %>"><%= school_name.name %></span>
<textarea style="display: none; width:100px; height:16px; border:1px solid #ddd; outline:none; padding:0 0 0 5px; resize:none; overflow:hidden;" placeholder="请编辑单位名称" id="school_name_edit_<%=apply.id%>" onblur="edit_school_name('<%= edit_apply_name_school_path(apply.id)%>','<%= apply.id %>');"></textarea>
<% end %>
</td>
<td class="center">
@ -73,7 +73,7 @@
<span ondblclick = "show_edit_school_province('<%= apply.id %>');" id="apply_province_<%= apply.id %>">
<%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %>
</span>
<select onchange="showcity(this.value, document.getElementById('schoolCity_<%=apply.id%>'));edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="province" id="school_province_edit_<%=apply.id%>" class="fl" style="width:50px; height:18px; display: none">
<select onchange="showcity(this.value, document.getElementById('schoolCity_<%=apply.id%>'));edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="province" id="school_province_edit_<%=apply.id%>" class="fl" style="width:55px; height:18px; display: none">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
@ -110,7 +110,7 @@
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select>
<select onchange="edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="city" id="schoolCity_<%=apply.id%>" class="fl ml5" style="width:50px; height:18px; display: none"></select>
<select onchange="edit_school_province('<%= edit_apply_province_school_path(apply.id)%>','<%= apply.id %>');" name="city" id="schoolCity_<%=apply.id%>" class="fl ml5" style="width:55px; height:18px; display: none"></select>
</td>
<td class="center">
<span title="双击可编辑" ondblclick = "show_edit_school_address('<%= apply.id %>');" id="apply_address_<%= apply.id %>"><%= apply.address %></span>

View File

@ -17,10 +17,16 @@
<p>您的申请已提交,请等待项目管理员审批</p>
<% elsif @flag == 5 %>
<p>您已经申请加入该项目了,请耐心等待</p>
<% elsif @flag == 6 %>
<p>您已成功加入项目</p>
<% end %>
</li>
<li>
<% if @flag == 6 %>
<%= link_to "知道了", project_path(@project), :class => "sy_btn_blue" %>
<% else %>
<a href="javascript:void(0);" class="sy_btn_blue " onclick="hideModal()">知道了</a>
<% end %>
</li>
</ul>
</div>

View File

@ -1,11 +1,11 @@
[
<% @users && @users.each_with_index do |person,index| %>
<% if index == 0 %>
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% else %>
{"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% end %>
<% end %>
<% @users && @users.each_with_index do |person,index| %>
<% if index == 0 %>
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% else %>
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% end %>
<% end %>
]

View File

@ -3,7 +3,7 @@
<div class="break_word">
<span class="fl">
<span title="<%= attachment.filename %>" id="attachment_<%=attachment.id %>">
<%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw380', :download => true -%>
<%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw380', :download => true %>
</span>
</span>
<span class="postAttSize">(

View File

@ -17,7 +17,8 @@
:upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s,
:source_id => source.id.to_s
:source_id => source.id.to_s,
:is_direct => 0
} %>
<!--</span>-->
<% content_for :header_tags do %>

View File

@ -1,4 +1,4 @@
<% if @source_type=='User' %>
<% if @is_direct == '1' && (@source_type=='User'|| @source_type == 'Course' || @source_type == 'Project') %>
var imgSpan = $("img[nhname='avatar_image']");
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
<% else %>

View File

@ -126,7 +126,7 @@
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">

View File

@ -22,7 +22,7 @@
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
班级问答
班级讨论
</div>
</div>
<div nhname="topic_form">

View File

@ -7,7 +7,7 @@
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">

View File

@ -7,7 +7,7 @@
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">

View File

@ -7,7 +7,7 @@
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">

View File

@ -2,7 +2,7 @@
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
<li>
<a href="<%=course_boards_path(@course) %>">问答区</a>
<a href="<%=course_boards_path(@course) %>">讨论区</a>
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") %>
</li>
<% end %>

View File

@ -17,7 +17,7 @@
<div class="cl"></div>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="new_course_name" class="courses_input" maxlength="100" placeholder="例如计算机系A班" onkeyup="regex_course_name('new');">
<input type="text" name="course[name]" id="new_course_name" class="courses_input" maxlength="100" placeholder="例如:软件工程计算机系A班" onkeyup="regex_course_name('new');">
<span class="c_red" id="new_course_name_notice" style="display: none;">班级名称不能为空且至少有两个字符</span>
</li>
<div class="cl"></div>

View File

@ -7,6 +7,9 @@
$("#course_is_public").attr("checked",true);
<% end %>
}
if(document.getElementById("course_list")) {
window.location.href = "<%=course_files_path(@course) %>";
}
<% else %>
<% if @course.is_public? %>
$("#show_course_<%= @course.id %>").attr("title","公开班级:<%= @course.name %><%= @course.time.to_s+ @course.term %>");

View File

@ -27,9 +27,8 @@
<div class="hwork_dis" id="tbc_01" style="padding-top: 10px;">
<ul>
<%= labelled_form_for @course do |f| %>
<li class="ml45 mb10">
<li class="ml45 mb10" id="course_avatar_form">
<%= render :partial => "avatar/new_avatar_form", :locals => {source: @course} %>
<div class="cl"></div>
</li>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_syllabus_name)%>&nbsp;&nbsp;</label>

View File

@ -11,6 +11,8 @@
<span>测验时长:<%= exercise.time %>分钟</span>
<% end %>
</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>

View File

@ -94,7 +94,7 @@
</p>
</div>
<% end %>
<div class="resources mt10" style="padding-bottom:5px;">
<div class="resources mt10 pr" style="padding-bottom:5px;">
<div class="reTop mb5">
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%>
@ -115,13 +115,22 @@
</div>
<div class="cl"></div>
<div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080" id="course_filter_order">
<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
</p>
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">-->
<!--<%#= render :partial => "files/tip_attachment_count" %>-->
<!--</p>-->
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080" id="course_filter_order">
<%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
</p>
</div>
</div>
<div class="cl"></div>
<!--<div class="resource_tip_box fontGrey2">-->
<!--<em></em>-->
<!--<span></span>-->
<!--<p class="mb5">私有资源:<br/>仅对本班级成员可见</p>-->
<!--<p>公共资源:<br/>对所有用户可见</p>-->
<!--</div>-->
</div>
<div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>

View File

@ -1,19 +1,14 @@
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div id="resource_detail_<%=file.id %>">
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
<%=render :partial=>'files/resource_detail',:locals => {:file => file} %>
</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 %>
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
<%=link_to "点击展开更多", course_files_path(:course_id => course.id, :page => @page), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%end%>
<% end%>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
<ul class="wlist">
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
</ul>

View File

@ -11,9 +11,9 @@
<div class="homepagePostTitle break_word">
<%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
<%= link_to file.is_public? ? truncate(file.filename, length: 45) : truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<%= link_to file.is_public? ? truncate(file.filename, length: 45) : truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,

View File

@ -65,7 +65,7 @@
</p>
</div>
<% end %>
<div class="resources mt10" style="padding-bottom:5px;">
<div class="resources mt10 pr" style="padding-bottom:5px;">
<div class="reTop mb5">
<%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
@ -85,6 +85,9 @@
</div>
<div class="cl"></div>
<div class="re_con_top">
<!--<p class="f_l fontBlue f_b f_14" id="tip_attachment_count">-->
<!--<%#= render :partial => "files/tip_attachment_count" %>-->
<!--</p>-->
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080">
<% if @order == "asc" %>
@ -100,6 +103,14 @@
</div>
</div>
<div class="cl"></div>
<%# if !User.current.member_of?(@project) && show_attachment_tip(@project.id, "Project") %>
<!--<div class="resource_tip_box fontGrey2">-->
<!--<em></em>-->
<!--<span></span>-->
<!--<p class="mb5">私有资源:<br/>仅对本项目成员可见</p>-->
<!--<p>公共资源:<br/>对所有用户可见</p>-->
<!--</div>-->
<%# end %>
</div>
<div id="course_list">
<%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>

View File

@ -66,17 +66,10 @@
<% end %>
<% end %>
<% if project_attachments.count == 10%>
<% if params[:action] == 'search_project' %>
<!--<ul class="wlist">-->
<!--<%#= 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%>
<ul class="wlist">
<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%>
</ul>

View File

@ -0,0 +1,15 @@
共有&nbsp;<span id="attachment_count"><%= @tip_all_attachments %></span>&nbsp;个资源
<span id="attachment_count_public" class="fontGrey2 ml10" style="font-weight: normal;">公共资源:<%= @tip_all_public_attachments %>个</span>
<% if @project %>
<% if !User.current.member_of?(@project) && params[:tag_name] %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源0个</span>
<% else %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源:<%= @tip_all_private_attachments %>个</span>
<% end %>
<% elsif @course %>
<% if !User.current.member_of_course?(@course) && params[:tag_name] %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源0个</span>
<% else %>
<span id="attachment_count_private" class="fontGrey2 ml10" style="font-weight: normal;">私有资源:<%= @tip_all_private_attachments %>个</span>
<% end %>
<% end %>

View File

@ -1,7 +1,9 @@
<% 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 %>
$("#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 %>
$("#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 %>

View File

@ -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} )%>");
<% else %>
$("#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 %>
$("#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 %>');

View File

@ -1,7 +1,2 @@
<% 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/project_list',
: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 %>
$("#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 %>');

View File

@ -1,8 +1,8 @@
<% 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})%>");
$("#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})%>");
$("#attachment_count").html("<%= @result.count%>")
$("#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 %>');
<% 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}) %>");
$("#attachment_count").html("<%= @result_search_project.count%>")
$("#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}) %>");
// $("#tip_attachment_count").html("<%#= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
$("#pages").html('<%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true %>');
<% end %>

View File

@ -2,5 +2,5 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_su
showModal('ajax-modal', '513px');
$('#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').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");

Some files were not shown because too many files have changed in this diff Show More