Merge branch 'szzh' into develop
This commit is contained in:
commit
0536af6625
|
@ -134,7 +134,7 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activerecord-jdbc-adapter (= 1.2.5)
|
activerecord-jdbc-adapter (= 1.2.5)
|
||||||
activerecord-jdbcmysql-adapter
|
activerecord-jdbcmysql-adapter
|
||||||
acts-as-taggable-on
|
acts-as-taggable-on (= 2.4.1)
|
||||||
better_errors!
|
better_errors!
|
||||||
builder (= 3.0.0)
|
builder (= 3.0.0)
|
||||||
coderay (~> 1.0.6)
|
coderay (~> 1.0.6)
|
||||||
|
|
|
@ -44,4 +44,10 @@ app\controller\welcome_controller.rb
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
0606:新坑
|
||||||
|
user_scores表结构有问题,需要运行
|
||||||
|
bundle exec rake db:migrate:down VERSION=20140410021724
|
||||||
|
bundle exec rake db:migrate:up VERSION=20140410021724
|
|
@ -264,6 +264,14 @@ class ApplicationController < ActionController::Base
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#根据course_id找project
|
||||||
|
def find_project_by_course_id
|
||||||
|
@bid = Bid.find params[:course_id]
|
||||||
|
@project = @bid.courses[0]
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
# Find a project based on params[:project_id]
|
# Find a project based on params[:project_id]
|
||||||
# TODO: some subclasses override this, see about merging their logic
|
# TODO: some subclasses override this, see about merging their logic
|
||||||
def find_optional_project
|
def find_optional_project
|
||||||
|
|
|
@ -25,7 +25,14 @@ class BidsController < ApplicationController
|
||||||
helper :projects
|
helper :projects
|
||||||
helper :words
|
helper :words
|
||||||
helper :welcome
|
helper :welcome
|
||||||
|
|
||||||
|
def find_project_by_bid_id
|
||||||
|
@bid = Bid.find(params[:id])
|
||||||
|
@project = @bid.courses[0]
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
def homework_ajax_modal
|
def homework_ajax_modal
|
||||||
@bid = Bid.find_by_id(params[:id])
|
@bid = Bid.find_by_id(params[:id])
|
||||||
# find_bid
|
# find_bid
|
||||||
|
@ -410,7 +417,7 @@ class BidsController < ApplicationController
|
||||||
@homework = HomeworkAttach.new
|
@homework = HomeworkAttach.new
|
||||||
#@homework_list = @bid.homeworks
|
#@homework_list = @bid.homeworks
|
||||||
#增加作业按评分排序,
|
#增加作业按评分排序,
|
||||||
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC')
|
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
||||||
if params[:student_id].present?
|
if params[:student_id].present?
|
||||||
@temp = []
|
@temp = []
|
||||||
@homework_list.each do |pro|
|
@homework_list.each do |pro|
|
||||||
|
@ -526,6 +533,7 @@ class BidsController < ApplicationController
|
||||||
message = params[:bid_message][:message] + "\n" + params[:reference_content]
|
message = params[:bid_message][:message] + "\n" + params[:reference_content]
|
||||||
else
|
else
|
||||||
message = params[:bid_message][:message]
|
message = params[:bid_message][:message]
|
||||||
|
@m = message
|
||||||
end
|
end
|
||||||
refer_user_id = params[:bid_message][:reference_user_id].to_i
|
refer_user_id = params[:bid_message][:reference_user_id].to_i
|
||||||
@bid.add_jour(User.current, message, refer_user_id)
|
@bid.add_jour(User.current, message, refer_user_id)
|
||||||
|
|
|
@ -210,11 +210,14 @@ class ContestsController < ApplicationController
|
||||||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||||
@membership.each do |membership|
|
@membership.each do |membership|
|
||||||
unless(membership.project.project_type==1)
|
unless(membership.project.project_type==1)
|
||||||
membership.member_roles.each{|role|
|
#membership.member_roles.each{|role|
|
||||||
if(role.role_id == 3)
|
# if(role.role_id == 3)
|
||||||
@option << membership.project
|
# @option << membership.project
|
||||||
end
|
# end
|
||||||
}
|
#}
|
||||||
|
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||||
|
@option << membership.project
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@user = @contest.author
|
@user = @contest.author
|
||||||
|
@ -301,11 +304,15 @@ class ContestsController < ApplicationController
|
||||||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||||
@membership.each do |membership|
|
@membership.each do |membership|
|
||||||
unless(membership.project.project_type==1)
|
unless(membership.project.project_type==1)
|
||||||
membership.member_roles.each{|role|
|
#membership.member_roles.each{|role|
|
||||||
if(role.role_id == 3)
|
#if(role.role_id == 3)
|
||||||
|
#@option << membership.project
|
||||||
|
#end
|
||||||
|
#}
|
||||||
|
#拥有编辑项目权限的可将该项目参赛
|
||||||
|
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||||
@option << membership.project
|
@option << membership.project
|
||||||
end
|
end
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@user = @contest.author
|
@user = @contest.author
|
||||||
|
|
|
@ -62,6 +62,7 @@ class DocumentsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@document = @project.documents.build
|
@document = @project.documents.build
|
||||||
@document.safe_attributes = params[:document]
|
@document.safe_attributes = params[:document]
|
||||||
|
@document.user = User.current
|
||||||
@document.save_attachments(params[:attachments])
|
@document.save_attachments(params[:attachments])
|
||||||
if @document.save
|
if @document.save
|
||||||
render_attachment_warning_if_needed(@document)
|
render_attachment_warning_if_needed(@document)
|
||||||
|
|
|
@ -1,5 +1,30 @@
|
||||||
class HomeworkAttachController < ApplicationController
|
class HomeworkAttachController < ApplicationController
|
||||||
###############################
|
###############################
|
||||||
|
#判断当前角色权限时需先找到当前操作的project
|
||||||
|
before_filter :find_project_by_bid_id, :only => [:new]
|
||||||
|
before_filter :find_project_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
|
||||||
|
#判断当前角色是否有操作权限
|
||||||
|
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
|
||||||
|
|
||||||
|
def find_project_by_bid_id
|
||||||
|
@bid = Bid.find(params[:id])
|
||||||
|
@project = @bid.courses[0]
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_project_by_hoemwork_id
|
||||||
|
@homework = HomeworkAttach.find(params[:id])
|
||||||
|
@project = @homework.bid.courses[0]
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取作业的成员
|
||||||
|
def get_homework_member homework
|
||||||
|
@hoemwork_users = users_for_homework(@homework)
|
||||||
|
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
||||||
|
@members = paginateHelper @members,10
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@homeworks = HomeworkAttach.all
|
@homeworks = HomeworkAttach.all
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -8,55 +33,98 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_users users
|
#作业添加成员(参与人员)
|
||||||
if users != nil && users.count > 0
|
def add_homework_users
|
||||||
users.each do |user|
|
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||||
@homework.homework_users.build(:user_id => user.id)
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
@homework.save
|
if params[:membership]
|
||||||
|
if params[:membership][:user_ids]
|
||||||
|
attrs = params[:membership].dup
|
||||||
|
user_ids = attrs.delete(:user_ids)
|
||||||
|
user_ids.each do |user_id|
|
||||||
|
@homework.homework_users.build(:user_id => user_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@homework.save
|
||||||
|
get_homework_member @homework
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render_403 :message => :notice_not_authorized
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#作业删除成员(参与人员)
|
||||||
|
def destory_homework_users
|
||||||
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
|
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||||
|
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
|
||||||
|
homework_user.destroy
|
||||||
|
get_homework_member @homework
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
bid = Bid.find params[:bid_id]
|
bid = Bid.find params[:bid_id]
|
||||||
if User.current.admin? || User.current.member_of?(bid.courses.first)
|
if User.current.admin? || User.current.member_of?(bid.courses.first)
|
||||||
user_id = params[:user_id]
|
if bid.homeworks.where("user_id = ?",User.current).count == 0
|
||||||
bid_id = params[:bid_id]
|
user_id = params[:user_id]
|
||||||
sta = 0
|
bid_id = params[:bid_id]
|
||||||
name = params[:new_form][:name]
|
sta = 0
|
||||||
description = params[:new_form][:description]
|
name = params[:new_form][:name]
|
||||||
options = {
|
description = params[:new_form][:description]
|
||||||
:user_id => user_id,
|
options = {
|
||||||
:state => sta,
|
:user_id => user_id,
|
||||||
:name => name,
|
:state => sta,
|
||||||
:description => description,
|
:name => name,
|
||||||
:bid_id => bid_id
|
:description => description,
|
||||||
}
|
:bid_id => bid_id
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#@homework_list = @bid.homeworks
|
#@homework_list = @bid.homeworks
|
||||||
|
|
||||||
@homework = HomeworkAttach.new(options)
|
@homework = HomeworkAttach.new(options)
|
||||||
@homework.save_attachments(params[:attachments])
|
@homework.save_attachments(params[:attachments])
|
||||||
render_attachment_warning_if_needed(@homework)
|
render_attachment_warning_if_needed(@homework)
|
||||||
|
|
||||||
if @homework.save
|
if @homework.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to project_for_bid_path @homework.bid }
|
format.html { redirect_to project_for_bid_path @homework.bid }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_has_homework
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@bid = Bid.find(params[:id])
|
@bid = Bid.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@bid.courses.first)
|
if User.current.admin? || User.current.member_of?(@bid.courses.first)
|
||||||
|
#该课程的学生的集合(新建不实现功能:添加成员)
|
||||||
|
#@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
|
||||||
|
|
||||||
|
#@members = paginateHelper @members,10
|
||||||
|
#@all_user = []
|
||||||
|
#@bid.courses.first.members.each do |member|
|
||||||
|
# @all_user << member.user
|
||||||
|
#end
|
||||||
@homework = HomeworkAttach.new
|
@homework = HomeworkAttach.new
|
||||||
|
#@homework_user = members_for_homework(@homework) + User.current
|
||||||
|
#@members = @all_user - @homework_user
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # new.html.erb
|
format.html # new.html.erb
|
||||||
format.json { render json: @homework }
|
format.json { render json: @homework }
|
||||||
|
@ -66,17 +134,47 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取作业成员的集合
|
||||||
|
def get_homework_member_list
|
||||||
|
@homework = HomeworkAttach.find(params[:bid_id])
|
||||||
|
course = @homework.bid.courses.first
|
||||||
|
if User.current.admin? || User.current.member_of?(course)
|
||||||
|
get_homework_member @homework
|
||||||
|
else
|
||||||
|
raise "error"
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取指定作业的所有成员
|
||||||
|
def users_for_homework homework
|
||||||
|
homework.nil? ? [] : (homework.users + [homework.user])
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取可选成员列表
|
||||||
|
#homework:作业
|
||||||
|
#users:该作业所有成员
|
||||||
|
#q:模糊匹配的用户的昵称
|
||||||
|
def members_for_homework homework,users,q
|
||||||
|
homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'")
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||||
|
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
|
||||||
|
get_homework_member @homework
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
course = @homework.bid.courses.first
|
||||||
|
if User.current.admin? || User.current.member_of?(course)
|
||||||
name = params[:homework_name]
|
name = params[:homework_name]
|
||||||
description = params[:homework_description]
|
description = params[:homework_description]
|
||||||
@homework.name = name
|
@homework.name = name
|
||||||
|
@ -97,8 +195,8 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current == @homework
|
||||||
if @homework.destroy
|
if @homework.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to project_for_bid_path @homework.bid }
|
format.html { redirect_to project_for_bid_path @homework.bid }
|
||||||
|
@ -113,7 +211,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
#显示作业信息
|
#显示作业信息
|
||||||
def show
|
def show
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||||
# 打分统计
|
# 打分统计
|
||||||
stars_reates = @homework.
|
stars_reates = @homework.
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
class HomeworkUsersController < ApplicationController
|
class HomeworkUsersController < ApplicationController
|
||||||
|
#新增数据
|
||||||
|
def create option
|
||||||
|
user = HomeworkUser.new option
|
||||||
|
user.save
|
||||||
|
user
|
||||||
|
end
|
||||||
|
#删除数据
|
||||||
|
def destory homework_user
|
||||||
|
user = HomeworkUser.find homework_user
|
||||||
|
user.destroy
|
||||||
|
user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,6 +71,10 @@ class PraiseTreadController < ApplicationController
|
||||||
@obj = Bid.find_by_id(id)
|
@obj = Bid.find_by_id(id)
|
||||||
when 'Contest'
|
when 'Contest'
|
||||||
@obj = Contest.find_by_id(id)
|
@obj = Contest.find_by_id(id)
|
||||||
|
when 'Memo'
|
||||||
|
@obj = Memo.find_by_id(id)
|
||||||
|
when 'Message'
|
||||||
|
@obj = Message.find_by_id(id)
|
||||||
end
|
end
|
||||||
return @obj
|
return @obj
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,7 @@ class ProjectsController < ApplicationController
|
||||||
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
|
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
|
||||||
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
|
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
|
||||||
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
|
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
|
||||||
|
#此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member
|
||||||
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
|
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
|
||||||
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
||||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
||||||
|
@ -721,6 +722,9 @@ class ProjectsController < ApplicationController
|
||||||
@teachers= searchTeacherAndAssistant(@project)
|
@teachers= searchTeacherAndAssistant(@project)
|
||||||
@canShowRealName = isCourseTeacher(User.current.id)
|
@canShowRealName = isCourseTeacher(User.current.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#勿删 real_name action为虚拟的该方法并不存在,用来辅助判断真名权限
|
||||||
|
#勿删 @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
||||||
format.api
|
format.api
|
||||||
|
|
|
@ -108,11 +108,16 @@ class SoftapplicationsController < ApplicationController
|
||||||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||||
@membership.each do |membership|
|
@membership.each do |membership|
|
||||||
unless(membership.project.project_type==1)
|
unless(membership.project.project_type==1)
|
||||||
membership.member_roles.each{|role|
|
#membership.member_roles.each{|role|
|
||||||
if(role.role_id == 3)
|
# if(role.role_id == 3)
|
||||||
|
# @option << membership.project
|
||||||
|
# end
|
||||||
|
#}
|
||||||
|
|
||||||
|
#拥有编辑项目权限的可操作该项目
|
||||||
|
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||||
@option << membership.project
|
@option << membership.project
|
||||||
end
|
end
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,9 @@ class WatchersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_watchables
|
def find_watchables
|
||||||
|
#根据参数获取关注对象的类型(user、project)
|
||||||
klass = Object.const_get(params[:object_type].camelcase) rescue nil
|
klass = Object.const_get(params[:object_type].camelcase) rescue nil
|
||||||
|
#判断获取的对象类型能否响应‘watched_by’方法
|
||||||
if klass && klass.respond_to?('watched_by')
|
if klass && klass.respond_to?('watched_by')
|
||||||
@watchables = klass.find_all_by_id(Array.wrap(params[:object_id]))
|
@watchables = klass.find_all_by_id(Array.wrap(params[:object_id]))
|
||||||
raise Unauthorized if @watchables.any? {|w| w.respond_to?(:visible?) && !w.visible?}
|
raise Unauthorized if @watchables.any? {|w| w.respond_to?(:visible?) && !w.visible?}
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
class ZipdownController < ApplicationController
|
class ZipdownController < ApplicationController
|
||||||
|
#查找项目(课程)
|
||||||
|
before_filter :find_project_by_bid_id, :only => [:assort]
|
||||||
|
#检查权限
|
||||||
|
#勿删 before_filter :authorize, :only => [:assort,:download_user_homework]
|
||||||
SAVE_FOLDER = "#{Rails.root}/files"
|
SAVE_FOLDER = "#{Rails.root}/files"
|
||||||
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
|
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
|
||||||
|
|
||||||
|
#通过作业Id找到项目(课程)
|
||||||
|
def find_project_by_bid_id
|
||||||
|
obj_class = params[:obj_class]
|
||||||
|
obj_id = params[:obj_id]
|
||||||
|
obj = obj_class.constantize.find(obj_id)
|
||||||
|
case obj.class.to_s.to_sym
|
||||||
|
when :Bid
|
||||||
|
@project = obj.courses[0]
|
||||||
|
end
|
||||||
|
end
|
||||||
def assort
|
def assort
|
||||||
obj_class = params[:obj_class]
|
obj_class = params[:obj_class]
|
||||||
obj_id = params[:obj_id]
|
obj_id = params[:obj_id]
|
||||||
|
@ -22,20 +36,10 @@ class ZipdownController < ApplicationController
|
||||||
|
|
||||||
#下载某一学生的作业的所有文件
|
#下载某一学生的作业的所有文件
|
||||||
def download_user_homework
|
def download_user_homework
|
||||||
obj_class = params[:obj_class]
|
homework = HomeworkAttach.find params[:homework]
|
||||||
obj_id = params[:obj_id]
|
if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first))
|
||||||
user_id = params[:user_id]
|
zipfile = zip_homework_by_user homework
|
||||||
obj = obj_class.constantize.find(obj_id)
|
send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile
|
||||||
|
|
||||||
if User.current.admin? || User.current.member_of?(obj.courses.first)
|
|
||||||
zipfile = nil
|
|
||||||
case obj.class.to_s.to_sym
|
|
||||||
when :Bid
|
|
||||||
zipfile = zip_user_bid obj,user_id
|
|
||||||
else
|
|
||||||
logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!"
|
|
||||||
end
|
|
||||||
send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile
|
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
|
@ -52,7 +56,8 @@ class ZipdownController < ApplicationController
|
||||||
user_zip_paths = homeattaches.map do |homeattach|
|
user_zip_paths = homeattaches.map do |homeattach|
|
||||||
zip_homework_by_user homeattach
|
zip_homework_by_user homeattach
|
||||||
end
|
end
|
||||||
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
|
#zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
|
||||||
|
user_zip_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
def zip_bid(bid)
|
def zip_bid(bid)
|
||||||
|
@ -83,7 +88,8 @@ class ZipdownController < ApplicationController
|
||||||
#length = attach.storage_path.length
|
#length = attach.storage_path.length
|
||||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||||
end
|
end
|
||||||
zipping "#{Time.now.to_i}_#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
zipping "#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
||||||
|
#user_attaches_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -155,16 +155,6 @@ module BidsHelper
|
||||||
end
|
end
|
||||||
people.include?(User.current)
|
people.include?(User.current)
|
||||||
end
|
end
|
||||||
#当前用户是不是指定课程的学生
|
|
||||||
def is_cur_course_student? course
|
|
||||||
people = []
|
|
||||||
course.members.includes(:user, :roles).each do |member|
|
|
||||||
if [5,10].include? member.roles.first.id
|
|
||||||
people << member.user
|
|
||||||
end
|
|
||||||
end
|
|
||||||
people.include?(User.current)
|
|
||||||
end
|
|
||||||
|
|
||||||
# def select_option_helper option
|
# def select_option_helper option
|
||||||
# tmp = Hash.new
|
# tmp = Hash.new
|
||||||
|
|
|
@ -137,25 +137,34 @@ module CoursesHelper
|
||||||
Course.find_by_extra(try(extra))
|
Course.find_by_extra(try(extra))
|
||||||
end
|
end
|
||||||
#判断制定用户是不是当前课程的老师
|
#判断制定用户是不是当前课程的老师
|
||||||
def is_course_teacher user,course
|
def is_course_teacher (user,course)
|
||||||
people = []
|
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{user.id}", {:role_id => TeacherRoles}).count != 0
|
||||||
course.members.includes(:roles, :user).each do |member|
|
#修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师
|
||||||
role_id = member.roles.first.id
|
#is_teacher = false
|
||||||
if TeacherRoles.include? role_id
|
#@membership = user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||||
people << member.user
|
#@membership.each do |membership|
|
||||||
end
|
# unless(membership.project.project_type==0)
|
||||||
end
|
# if user.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false)
|
||||||
people.include?(user)
|
# is_teacher = true
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
#end
|
||||||
|
#is_teacher
|
||||||
end
|
end
|
||||||
#当前用户是不是指定课程的学生
|
#当前用户是不是指定课程的学生
|
||||||
def is_cur_course_student? course
|
def is_cur_course_student course
|
||||||
people = []
|
course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0
|
||||||
course.members.includes(:roles, :user).each do |member|
|
#修改:能新建占位且不能新建任务的角色判定为学生
|
||||||
if StudentRoles.include? member.roles.first.id
|
#is_student = false
|
||||||
people << member.user
|
#@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||||
end
|
#@membership.each do |membership|
|
||||||
end
|
# unless(membership.project.project_type==0)
|
||||||
people.include?(User.current)
|
# if !User.current.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) && User.current.allowed_to?({:controller => "homework_attach", :action => "new"}, membership.project, :global => false)
|
||||||
|
# is_student = true
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
#end
|
||||||
|
#is_student
|
||||||
end
|
end
|
||||||
#获取当前用户在指定作业下提交的作业的集合
|
#获取当前用户在指定作业下提交的作业的集合
|
||||||
def cur_user_homework_for_bid bid
|
def cur_user_homework_for_bid bid
|
||||||
|
@ -168,4 +177,9 @@ module CoursesHelper
|
||||||
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
|
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
|
||||||
seem_count > 0
|
seem_count > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取指定作业的所有成员
|
||||||
|
def users_for_homework homework
|
||||||
|
homework.nil? ? [] : (homework.users + [homework.user])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,57 @@
|
||||||
module HomeworkAttachHelper
|
module HomeworkAttachHelper
|
||||||
|
#判断是否具有删除的权限
|
||||||
def attach_delete(project)
|
def attach_delete(project)
|
||||||
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
#作业添加、编辑界面的tab页
|
||||||
|
def homework_settings_tabs f
|
||||||
|
@f = f
|
||||||
|
tabs = [{:name => 'info', :partial => 'homework_attach/edit_homework', :label => :label_information_plural},
|
||||||
|
{:name => 'members', :partial => 'homework_attach/homework_member', :label => :label_member_plural}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
#作业可选成员列表分页
|
||||||
|
def render_new_members_for_homework members
|
||||||
|
#scope = Principal.active.sorted.not_member_of(project).like(params[:q])
|
||||||
|
#scope = project.members
|
||||||
|
#principals = paginateHelper members,10
|
||||||
|
#principals = members
|
||||||
|
#principal_count = members.count
|
||||||
|
#limit = 10
|
||||||
|
#principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young
|
||||||
|
#offset ||= principal_pages.offset
|
||||||
|
#principals = members[offset, limit]
|
||||||
|
users = members.map(&:user)
|
||||||
|
s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', users), :id => 'principals')
|
||||||
|
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
|
||||||
|
link_to text, get_homework_member_list_homework_attach_index_path( parameters.merge(:q => params[:q], bid_id: params[:id]||@homework)), :remote => true }
|
||||||
|
return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||||
|
end
|
||||||
|
|
||||||
|
#扩展的checkbox生成
|
||||||
|
def member_check_box_tags_ex(name, principals)
|
||||||
|
s = ''
|
||||||
|
principals.each do |member|
|
||||||
|
s << "<label>#{ check_box_tag name, member.id, false, :id => nil } #{h member.name }</label><br/>"
|
||||||
|
end
|
||||||
|
s.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
def paginateHelper obj, pre_size=20
|
||||||
|
@obj_count = obj.count
|
||||||
|
@obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page']
|
||||||
|
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
||||||
|
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
|
||||||
|
elsif obj.kind_of? Array
|
||||||
|
obj[@obj_pages.offset, @obj_pages.per_page]
|
||||||
|
else
|
||||||
|
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
|
||||||
|
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -36,7 +36,7 @@ module MembersHelper
|
||||||
# 当前申请加入的成员名单
|
# 当前申请加入的成员名单
|
||||||
def render_principals_for_applied_members(project)
|
def render_principals_for_applied_members(project)
|
||||||
scope = Principal.active.sorted.applied_members(project).like(params[:q])
|
scope = Principal.active.sorted.applied_members(project).like(params[:q])
|
||||||
principal_count = scope.count
|
principal_count = scope.count
|
||||||
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']
|
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']
|
||||||
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,6 @@ module ProjectsHelper
|
||||||
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}
|
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}
|
||||||
]
|
]
|
||||||
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
||||||
|
|
||||||
end
|
end
|
||||||
#Ended by young
|
#Ended by young
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,15 @@ def options_from_select_project(user)
|
||||||
@option = []
|
@option = []
|
||||||
@membership.each do |membership|
|
@membership.each do |membership|
|
||||||
unless(membership.project.project_type==1)
|
unless(membership.project.project_type==1)
|
||||||
membership.member_roles.each{|role|
|
#membership.member_roles.each{|role|
|
||||||
if(role.role_id == 3)
|
# if(role.role_id == 3)
|
||||||
|
# @option << membership.project
|
||||||
|
# end
|
||||||
|
#}
|
||||||
|
#拥有编辑项目权限的可操作该项目
|
||||||
|
if user.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||||
@option << membership.project
|
@option << membership.project
|
||||||
end
|
end
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
options_for_select(@option)
|
options_for_select(@option)
|
||||||
|
|
|
@ -228,12 +228,21 @@ module UserScoreHelper
|
||||||
isManager = 0
|
isManager = 0
|
||||||
members = Member.where('user_id = ?', user.id)
|
members = Member.where('user_id = ?', user.id)
|
||||||
members.each do |m|
|
members.each do |m|
|
||||||
roles = m.member_roles
|
#roles = m.member_roles
|
||||||
roles.each do |r|
|
#roles.each do |r|
|
||||||
if r.role_id == 3
|
# if r.role_id == 3
|
||||||
|
# isManager = 1
|
||||||
|
# end
|
||||||
|
#end
|
||||||
|
@membership = m.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||||
|
@membership.each do |membership|
|
||||||
|
#拥有编辑项目权限的可操作该项目
|
||||||
|
if m.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||||
isManager = 1
|
isManager = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
level = 0
|
level = 0
|
||||||
|
|
|
@ -56,6 +56,7 @@ class Attachment < ActiveRecord::Base
|
||||||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||||
|
|
||||||
before_save :files_to_final_location
|
before_save :files_to_final_location
|
||||||
|
before_save :be_user_score # user_score
|
||||||
after_destroy :delete_from_disk
|
after_destroy :delete_from_disk
|
||||||
|
|
||||||
# Returns an unsaved copy of the attachment
|
# Returns an unsaved copy of the attachment
|
||||||
|
@ -361,4 +362,17 @@ class Attachment < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
"#{timestamp}_#{ascii}"
|
"#{timestamp}_#{ascii}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# update user score
|
||||||
|
def be_user_score
|
||||||
|
if self.container_id_changed?
|
||||||
|
type = self.container_type
|
||||||
|
types = %w|Document News Version Project Issue Message WikiPage|
|
||||||
|
if types.include?(type)
|
||||||
|
UserScore.project(:push_file, User.current, { attachment_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
class Changeset < ActiveRecord::Base
|
class Changeset < ActiveRecord::Base
|
||||||
belongs_to :repository
|
belongs_to :repository
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
after_save :be_user_score # user_score
|
||||||
|
|
||||||
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
|
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
|
||||||
# fq
|
# fq
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
|
@ -292,4 +295,14 @@ class Changeset < ActiveRecord::Base
|
||||||
def self.to_utf8(str, encoding)
|
def self.to_utf8(str, encoding)
|
||||||
Redmine::CodesetUtil.to_utf8(str, encoding)
|
Redmine::CodesetUtil.to_utf8(str, encoding)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# update user score
|
||||||
|
def be_user_score
|
||||||
|
if self.new_record?
|
||||||
|
UserScore.project(:push_code, self.user, { changeset_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,12 @@
|
||||||
class Document < ActiveRecord::Base
|
class Document < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :user
|
||||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||||
|
|
||||||
|
before_save :be_user_score # user_score
|
||||||
|
|
||||||
|
|
||||||
acts_as_attachable :delete_permission => :delete_documents
|
acts_as_attachable :delete_permission => :delete_documents
|
||||||
|
|
||||||
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||||||
|
@ -54,4 +59,11 @@ class Document < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
@updated_on
|
@updated_on
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# update user score
|
||||||
|
def be_user_score
|
||||||
|
if self.new_record?
|
||||||
|
UserScore.project(:push_document, self.user, { document_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,14 +7,15 @@ class HomeworkAttach < ActiveRecord::Base
|
||||||
belongs_to :bid
|
belongs_to :bid
|
||||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
has_many :homework_users, :dependent => :destroy
|
has_many :homework_users, :dependent => :destroy
|
||||||
|
has_many :users, :through => :homework_users
|
||||||
seems_rateable :allow_update => true, :dimensions => :quality
|
seems_rateable :allow_update => true, :dimensions => :quality
|
||||||
|
|
||||||
safe_attributes "bid_id",
|
safe_attributes "bid_id",
|
||||||
"user_id"
|
"user_id"
|
||||||
acts_as_attachable
|
acts_as_attachable
|
||||||
|
|
||||||
def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0
|
def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0,reply_id = 0
|
||||||
jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation)
|
jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation,:reply_id => reply_id)
|
||||||
jfm.save
|
jfm.save
|
||||||
jfm
|
jfm
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class HomeworkUser < ActiveRecord::Base
|
class HomeworkUser < ActiveRecord::Base
|
||||||
attr_accessible :homework_attach_id, :user_id
|
attr_accessible :homework_attach_id, :user_id
|
||||||
|
|
||||||
belongs_to :homework_attach
|
belongs_to :homework_attach, :foreign_key => :homework_attach_id
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,6 +77,8 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
# fq
|
# fq
|
||||||
after_create :act_as_activity
|
after_create :act_as_activity
|
||||||
|
before_save :be_user_score
|
||||||
|
# after_create :be_user_score
|
||||||
# end
|
# end
|
||||||
|
|
||||||
delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
|
delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
|
||||||
|
@ -1484,4 +1486,17 @@ class Issue < ActiveRecord::Base
|
||||||
and #{visible_condition(User.current, :project => project)}
|
and #{visible_condition(User.current, :project => project)}
|
||||||
group by s.id, s.is_closed, j.id")
|
group by s.id, s.is_closed, j.id")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# update user score
|
||||||
|
def be_user_score
|
||||||
|
if self.new_record?
|
||||||
|
UserScore.project(:post_issue, User.current, { issue_id: self.id })
|
||||||
|
elsif self.done_ratio_changed?
|
||||||
|
UserScore.project(:update_issue_ratio, User.current, { issue_id: self.id })
|
||||||
|
#缺陷状态更改
|
||||||
|
elsif self.status_id_changed?
|
||||||
|
#协同得分
|
||||||
|
UserScore.joint(:change_issue_status, User.current,nil, {issue_id: self.id})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,6 +48,9 @@ class Journal < ActiveRecord::Base
|
||||||
after_create :act_as_activity
|
after_create :act_as_activity
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
before_save :be_user_score
|
||||||
|
#before_destroy :down_user_score
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
user = args.shift || User.current
|
user = args.shift || User.current
|
||||||
|
|
||||||
|
@ -151,4 +154,21 @@ class Journal < ActiveRecord::Base
|
||||||
self.acts << Activity.new(:user_id => self.user_id)
|
self.acts << Activity.new(:user_id => self.user_id)
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
# 更新用户分数 -by zjc
|
||||||
|
def be_user_score
|
||||||
|
#新建了缺陷留言且留言不为空,不为空白
|
||||||
|
if self.new_record? && !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||||
|
#协同得分加分
|
||||||
|
UserScore.joint(:post_issue, User.current,self.issue.author, { message_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# 减少用户分数 -by zjc
|
||||||
|
def down_user_score
|
||||||
|
#删除有效缺陷留言
|
||||||
|
if !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||||
|
#协同得分减分
|
||||||
|
UserScore.joint(:delete_issue, User.current,self.issue.author, { message_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,6 +42,8 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
after_create :act_as_activity #huang
|
after_create :act_as_activity #huang
|
||||||
after_create :reset_counters!
|
after_create :reset_counters!
|
||||||
after_destroy :reset_counters!
|
after_destroy :reset_counters!
|
||||||
|
before_save :be_user_score
|
||||||
|
#before_destroy :down_user_score
|
||||||
|
|
||||||
# default_scope { where('m_parent_id IS NULL') }
|
# default_scope { where('m_parent_id IS NULL') }
|
||||||
|
|
||||||
|
@ -99,4 +101,21 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
count = find_all_by_m_parent_id(journals_for_messages.m_parent_id).count #(SELECT COUNT(*) FROM #{JournalsForMessage.table_name} WHERE m_parent_id = #{jfm_id} )
|
count = find_all_by_m_parent_id(journals_for_messages.m_parent_id).count #(SELECT COUNT(*) FROM #{JournalsForMessage.table_name} WHERE m_parent_id = #{jfm_id} )
|
||||||
update_all("m_reply_count = #{count.to_i}", ["id = ?", journals_for_messages.m_parent_id])
|
update_all("m_reply_count = #{count.to_i}", ["id = ?", journals_for_messages.m_parent_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 更新用户分数 -by zjc
|
||||||
|
def be_user_score
|
||||||
|
#新建了留言回复
|
||||||
|
if self.new_record? && self.reply_id != 0
|
||||||
|
#协同得分加分
|
||||||
|
UserScore.joint(:reply_message, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# 更新用户分数 -by zjc
|
||||||
|
def down_user_score
|
||||||
|
#删除了留言回复
|
||||||
|
if self.reply_id != 0
|
||||||
|
#协同得分减分
|
||||||
|
UserScore.joint(:reply_message_delete, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Memo < ActiveRecord::Base
|
||||||
# after_create :send_notification
|
# after_create :send_notification
|
||||||
# after_save :plusParentAndForum
|
# after_save :plusParentAndForum
|
||||||
# after_destroy :minusParentAndForum
|
# after_destroy :minusParentAndForum
|
||||||
|
before_save :be_user_score
|
||||||
# scope :visible, lambda { |*args|
|
# scope :visible, lambda { |*args|
|
||||||
# includes(:forum => ).where()
|
# includes(:forum => ).where()
|
||||||
# }
|
# }
|
||||||
|
@ -140,5 +140,17 @@ class Memo < ActiveRecord::Base
|
||||||
@forum.topic_count = 0 if @forum.topic_count.to_int < 0
|
@forum.topic_count = 0 if @forum.topic_count.to_int < 0
|
||||||
end
|
end
|
||||||
@forum.save
|
@forum.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新用户分数 -by zjc
|
||||||
|
def be_user_score
|
||||||
|
#新建memo且无parent的为发帖
|
||||||
|
if self.new_record? && self.parent_id.nil?
|
||||||
|
UserScore.joint(:post_message, User.current,nil, { memo_id: self.id })
|
||||||
|
#新建memo且有parent的为回帖
|
||||||
|
elsif self.new_record? && !self.parent_id.nil?
|
||||||
|
UserScore.joint(:reply_posting, User.current,self.parent.author, { memo_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,6 +54,8 @@ class Message < ActiveRecord::Base
|
||||||
|
|
||||||
# fq
|
# fq
|
||||||
after_create :act_as_activity
|
after_create :act_as_activity
|
||||||
|
before_save :be_user_score
|
||||||
|
#before_destroy :down_user_score
|
||||||
# end
|
# end
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
|
@ -121,4 +123,25 @@ class Message < ActiveRecord::Base
|
||||||
self.acts << Activity.new(:user_id => self.author_id)
|
self.acts << Activity.new(:user_id => self.author_id)
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
#更新用户分数 -by zjc
|
||||||
|
def be_user_score
|
||||||
|
#新建message且无parent的为发帖
|
||||||
|
if self.new_record? && self.parent_id.nil?
|
||||||
|
UserScore.joint(:post_message, User.current,nil, { message_id: self.id })
|
||||||
|
#新建message且有parent的为回帖
|
||||||
|
elsif self.new_record? && !self.parent_id.nil?
|
||||||
|
UserScore.joint(:reply_posting, User.current,self.parent.author, { message_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#减少用户分数
|
||||||
|
def down_user_score
|
||||||
|
#删除发帖
|
||||||
|
if self.parent_id.nil?
|
||||||
|
UserScore.joint(:delete_message, User.current,nil, { message_id: self.id })
|
||||||
|
#删除留言
|
||||||
|
else
|
||||||
|
UserScore.joint(:reply_deleting, User.current,self.parent.author, { message_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,5 +2,41 @@ class PraiseTread < ActiveRecord::Base
|
||||||
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
|
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :praise_tread_object, polymorphic: true
|
belongs_to :praise_tread_object, polymorphic: true
|
||||||
|
before_save :be_user_score
|
||||||
|
|
||||||
|
def find_object_by_type_and_id(type,id)
|
||||||
|
@obj = nil
|
||||||
|
case type
|
||||||
|
when 'User'
|
||||||
|
@obj = User.find_by_id(id)
|
||||||
|
when 'Issue'
|
||||||
|
@obj = Issue.find_by_id(id)
|
||||||
|
when 'Project'
|
||||||
|
@obj = Project.find_by_id(id)
|
||||||
|
when 'Bid'
|
||||||
|
@obj = Bid.find_by_id(id)
|
||||||
|
when 'Contest'
|
||||||
|
@obj = Contest.find_by_id(id)
|
||||||
|
when 'Memo'
|
||||||
|
@obj = Memo.find_by_id(id)
|
||||||
|
when 'Message'
|
||||||
|
@obj = Message.find_by_id(id)
|
||||||
|
end
|
||||||
|
return @obj
|
||||||
|
end
|
||||||
|
|
||||||
|
#更新用户分数 - by zjc
|
||||||
|
def be_user_score
|
||||||
|
#踩贴吧或讨论区帖子
|
||||||
|
if self.new_record? && self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||||
|
obj = find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||||
|
target_user = obj.author
|
||||||
|
UserScore.skill(:treaded_by_user, User.current,target_user, { praise_tread_id: self.id })
|
||||||
|
#顶贴吧或讨论区帖子
|
||||||
|
elsif self.new_record? && self.praise_or_tread == 1 && (self.praise_tread_object_id == 'Memo' || self.praise_tread_object_type == 'Message')
|
||||||
|
obj = find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
|
||||||
|
target_user = obj.author
|
||||||
|
UserScore.skill(:praised_by_user, User.current,target_user,{ praise_tread_id: self.id })
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,7 +73,8 @@ class User < Principal
|
||||||
['none', :label_user_mail_option_none]
|
['none', :label_user_mail_option_none]
|
||||||
]
|
]
|
||||||
|
|
||||||
belongs_to :homework_user
|
has_many :homework_users
|
||||||
|
has_many :homework_attaches, :through => :homework_users
|
||||||
|
|
||||||
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
|
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
|
||||||
:after_remove => Proc.new {|user, group| group.user_removed(user)}
|
:after_remove => Proc.new {|user, group| group.user_removed(user)}
|
||||||
|
@ -112,6 +113,7 @@ class User < Principal
|
||||||
has_many :journals
|
has_many :journals
|
||||||
has_many :messages, :foreign_key => 'author_id'
|
has_many :messages, :foreign_key => 'author_id'
|
||||||
has_one :user_score, :dependent => :destroy
|
has_one :user_score, :dependent => :destroy
|
||||||
|
has_many :documents # 项目中关联的文档再次与人关联
|
||||||
# end
|
# end
|
||||||
|
|
||||||
######added by nie
|
######added by nie
|
||||||
|
@ -120,6 +122,10 @@ class User < Principal
|
||||||
#####
|
#####
|
||||||
has_many :shares ,:dependent => :destroy
|
has_many :shares ,:dependent => :destroy
|
||||||
|
|
||||||
|
# add by zjc
|
||||||
|
has_one :level, :class_name => 'UserLevels', :dependent => :destroy
|
||||||
|
has_many :memos , :foreign_key => 'author_id'
|
||||||
|
#####
|
||||||
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
|
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
|
||||||
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
|
@ -137,7 +143,7 @@ class User < Principal
|
||||||
has_one :user_extensions,:dependent => :destroy
|
has_one :user_extensions,:dependent => :destroy
|
||||||
## end
|
## end
|
||||||
|
|
||||||
default_scope -> { includes(:user_extensions, :user_score) }
|
# default_scope -> { includes(:user_extensions, :user_score) }
|
||||||
scope :teacher, -> {
|
scope :teacher, -> {
|
||||||
joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER)
|
joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER)
|
||||||
}
|
}
|
||||||
|
@ -201,6 +207,7 @@ class User < Principal
|
||||||
|
|
||||||
# ======================================================================
|
# ======================================================================
|
||||||
# 集中处理 User 扩展表为空的问题
|
# 集中处理 User 扩展表为空的问题
|
||||||
|
# 合并 user_score 属性
|
||||||
validate :valid_user_extensions
|
validate :valid_user_extensions
|
||||||
after_save :save_user_extensions
|
after_save :save_user_extensions
|
||||||
|
|
||||||
|
@ -208,21 +215,32 @@ class User < Principal
|
||||||
self.user_extensions ||= UserExtensions.new
|
self.user_extensions ||= UserExtensions.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_score_attr
|
||||||
|
self.user_score ||= UserScore.new
|
||||||
|
end
|
||||||
|
|
||||||
|
alias_method :ori_respond_to?, :respond_to?
|
||||||
def respond_to?(m, include_private = false)
|
def respond_to?(m, include_private = false)
|
||||||
flag = UserExtensions.instance_methods.include? m.to_sym
|
flag = false
|
||||||
if flag
|
flag = ori_respond_to? m.to_sym unless flag
|
||||||
flag
|
flag = UserExtensions.new.respond_to? m.to_sym unless flag
|
||||||
else
|
flag = UserScore.new.respond_to? m.to_sym unless flag
|
||||||
super
|
|
||||||
end
|
flag
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing m, *args, &block
|
def method_missing m, *args, &block
|
||||||
if extensions.respond_to? m.to_sym
|
if extensions.respond_to? m.to_sym
|
||||||
self.class.send :define_method, m.to_sym, *args do
|
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
|
||||||
self.extensions.__send__ m.to_sym, *args
|
self.extensions.__send__ m.to_sym, *args
|
||||||
end
|
end
|
||||||
__send__ m.to_sym, *args, &block
|
__send__ "_meta_#{m}".to_sym, *args, &block
|
||||||
|
|
||||||
|
elsif user_score_attr.respond_to? m.to_sym
|
||||||
|
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
|
||||||
|
self.user_score_attr.__send__ m.to_sym, *args
|
||||||
|
end
|
||||||
|
__send__ "_meta_#{m}".to_sym, *args, &block
|
||||||
|
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
@ -241,6 +259,7 @@ class User < Principal
|
||||||
|
|
||||||
def save_user_extensions
|
def save_user_extensions
|
||||||
self.extensions.save
|
self.extensions.save
|
||||||
|
self.user_score_attr.save
|
||||||
end
|
end
|
||||||
# 集中处理 User 扩展表为空的问题 < end
|
# 集中处理 User 扩展表为空的问题 < end
|
||||||
# ======================================================================
|
# ======================================================================
|
||||||
|
@ -861,6 +880,63 @@ class User < Principal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取user的等级 -by zjc
|
||||||
|
def get_level
|
||||||
|
if self.level.nil?
|
||||||
|
update_user_level
|
||||||
|
end
|
||||||
|
self.level.level
|
||||||
|
end
|
||||||
|
|
||||||
|
#更新用户等级 - by zjc
|
||||||
|
def update_user_level
|
||||||
|
user_level = UserLevels.new
|
||||||
|
user_level.user = self
|
||||||
|
|
||||||
|
#判断user的等级
|
||||||
|
pis = self.project_infos #ProjectInfo.find_all_by_user_id(self.id)
|
||||||
|
isManager = false;
|
||||||
|
pis.each do |pi|
|
||||||
|
#判断是否为项目管理员
|
||||||
|
if self.allowed_to?({:controller => "projects", :action => "edit"}, pi.project)
|
||||||
|
isManager = true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
has_effective_praise_count = false;
|
||||||
|
self.messages.each do |message|
|
||||||
|
if message.parent_id.nil?
|
||||||
|
ptcs = PraiseTreadCache.find_all_by_object_id(message.id)
|
||||||
|
ptcs.each do |ptc|
|
||||||
|
if ptc.object_type == 'Message' && ptc.praise_num.to_i > 5
|
||||||
|
has_effective_praise_count = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if !has_effective_praise_count
|
||||||
|
self.memos do |memo|
|
||||||
|
if memo.parent_id.nil?
|
||||||
|
ptcs = PraiseTreadCache.find_all_by_object_id(memo.id)
|
||||||
|
ptcs.each do |ptc|
|
||||||
|
if ptc.object_type == 'Memo' && ptc.praise_num > 5
|
||||||
|
has_effective_praise_count = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if isManager || self.changesets.count > 100
|
||||||
|
user_level.level = 3
|
||||||
|
elsif (self.changesets.count > 1 && self.changesets.count <= 100) || has_effective_praise_count
|
||||||
|
user_level.level = 2
|
||||||
|
else
|
||||||
|
user_level.level = 1
|
||||||
|
end
|
||||||
|
user_level.save
|
||||||
|
self.reload
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def validate_password_length
|
def validate_password_length
|
||||||
|
@ -869,7 +945,6 @@ class User < Principal
|
||||||
errors.add(:password, :too_short, :count => Setting.password_min_length.to_i)
|
errors.add(:password, :too_short, :count => Setting.password_min_length.to_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def act_as_activity
|
def act_as_activity
|
||||||
|
@ -911,6 +986,8 @@ class User < Principal
|
||||||
Redmine::Utils.random_hex(16)
|
Redmine::Utils.random_hex(16)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class AnonymousUser < User
|
class AnonymousUser < User
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#用户等级类 - by zjc
|
||||||
|
class UserLevels < ActiveRecord::Base
|
||||||
|
attr_accessible :user_id, :level
|
||||||
|
belongs_to :user
|
||||||
|
end
|
|
@ -18,6 +18,8 @@
|
||||||
class UserScore < ActiveRecord::Base
|
class UserScore < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
before_save :correct_score
|
||||||
|
|
||||||
def self.find_max_file
|
def self.find_max_file
|
||||||
self.maximum(:file)
|
self.maximum(:file)
|
||||||
end
|
end
|
||||||
|
@ -33,4 +35,223 @@ class UserScore < ActiveRecord::Base
|
||||||
def self.find_min_issue
|
def self.find_min_issue
|
||||||
self.minimum(:file)
|
self.minimum(:file)
|
||||||
end
|
end
|
||||||
|
# 以上类方法目测没用,反正也报错
|
||||||
|
# ===============================================================================
|
||||||
|
|
||||||
|
# 前略·协同得分
|
||||||
|
# operate - 更新操作 类型 symbol
|
||||||
|
# user - 计分用户
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# UserScore.joint(:post_message, User.current, nil)
|
||||||
|
# # => true #当前用户发帖计分操作成功
|
||||||
|
#
|
||||||
|
# Returns boolean. 返回积分保存结果
|
||||||
|
def self.joint(operate, current_user, target_user, options={})
|
||||||
|
current_user, target_user = get_users(current_user, target_user)
|
||||||
|
user_score = current_user.user_score_attr
|
||||||
|
case operate
|
||||||
|
when :post_message # current_user 发帖了 Add Message
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i + 2
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
|
||||||
|
when :delete_message # current_user 发帖了 Delete Message
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i - 2
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
|
||||||
|
when :post_issue # current_user 对 target_user 的缺陷留言了 Add Journal
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
|
||||||
|
when :delete_issue # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i - 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
|
||||||
|
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
|
||||||
|
when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
|
||||||
|
when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i - 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
|
||||||
|
when :reply_posting # current_user 对 target_user 帖子的回复 Add Message
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
|
||||||
|
when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
|
||||||
|
user_score.collaboration = user_score.collaboration.to_i - 1
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
|
||||||
|
else
|
||||||
|
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "[UserScore#joint] ===> Exception: #{e}."
|
||||||
|
end
|
||||||
|
|
||||||
|
# 前略·影响力得分
|
||||||
|
# operate - 更新操作 类型 symbol
|
||||||
|
# user - 计分用户
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# UserScore.influence(:followed_by, user)
|
||||||
|
# # => true #当前被关注用户记分成功
|
||||||
|
#
|
||||||
|
# Returns boolean. 返回积分保存结果
|
||||||
|
def self.influence(operate, current_user, target_user, options={})
|
||||||
|
current_user, target_user = get_users(current_user, target_user)
|
||||||
|
user_score = target_user.user_score_attr
|
||||||
|
case operate
|
||||||
|
when :followed_by # current_user 关注了target_user
|
||||||
|
user_score.influence = user_score.influence.to_i + 2
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
|
||||||
|
when :cancel_followed # current_uer 取消了对 target_user的关注
|
||||||
|
user_score.influence = user_score.influence.to_i - 2
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} canceled followed. options => (#{options.to_s})"
|
||||||
|
else
|
||||||
|
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
|
||||||
|
end
|
||||||
|
|
||||||
|
# 前略·技术得分
|
||||||
|
# operate - 更新操作 类型 symbol
|
||||||
|
# user - 计分用户
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# UserScore.skill(:followed_by, current_user, target_user)
|
||||||
|
# # => true #当前current_user对target_user用户帖子的记分成功
|
||||||
|
#
|
||||||
|
# Returns boolean. 返回积分保存结果
|
||||||
|
def self.skill(operate, current_user, target_user, options={})
|
||||||
|
current_user, target_user = get_users(current_user, target_user)
|
||||||
|
current_user_score = current_user.user_score_attr
|
||||||
|
target_user_score = target_user.user_score_attr
|
||||||
|
case operate
|
||||||
|
# when :treading # current_user 踩了 target_user 的帖子
|
||||||
|
# Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treading #{target_user}'s posting. options => (#{options.to_s})"
|
||||||
|
when :treaded_by_user # current_user 踩了 target_user 的帖子
|
||||||
|
current_user_score.skill = current_user_score.skill.to_i - 2 #踩别人的帖子减2分
|
||||||
|
current_user_score.save
|
||||||
|
if current_user.id == target_user.id
|
||||||
|
target_user.reload
|
||||||
|
target_user_score = target_user.user_score_attr
|
||||||
|
end
|
||||||
|
level = current_user.get_level
|
||||||
|
if level == 1
|
||||||
|
target_user_score.skill = target_user_score.skill.to_i - 2 #帖子被一级会员踩-2分
|
||||||
|
target_user_score.save
|
||||||
|
elsif level == 2
|
||||||
|
target_user_score.skill = target_user_score.skill.to_i - 4 #帖子被二级会员踩-4分
|
||||||
|
target_user_score.save
|
||||||
|
elsif level == 3
|
||||||
|
target_user_score.skill = target_user_score.skill.to_i - 6 #帖子被三级会员踩-6分
|
||||||
|
target_user_score.save
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})"
|
||||||
|
when :praised_by_user # current_user 顶了 target_user 的帖子
|
||||||
|
level = current_user.get_level
|
||||||
|
if level == 1
|
||||||
|
target_user_score.skill = target_user_score.skill.to_i + 4 #帖子被一级会员顶+4分
|
||||||
|
target_user_score.save
|
||||||
|
elsif level == 2
|
||||||
|
target_user_score.skill = target_user_score.skill.to_i + 6 #帖子被二级会员顶+6分
|
||||||
|
target_user_score.save
|
||||||
|
elsif level == 3
|
||||||
|
target_user_score.skill = target_user_score.skill.to_i + 8 #帖子被三级会员顶+8分
|
||||||
|
target_user_score.save
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} praised_by #{target_user}. options => (#{options.to_s})"
|
||||||
|
else
|
||||||
|
Rails.logger.error "[UserScore#skill] ===> #{operate} is not define."
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "[UserScore#skill] ===> Exception: #{e}."
|
||||||
|
end
|
||||||
|
|
||||||
|
# 前略·项目得分
|
||||||
|
# operate - 更新操作 类型 symbol
|
||||||
|
# user - 计分用户
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# UserScore.project(:pull_code, current_user)
|
||||||
|
# # => true #当前current_user对项目贡献积分成功
|
||||||
|
#
|
||||||
|
# Returns boolean. 返回积分保存结果
|
||||||
|
def self.project(operate, current_user, options={})
|
||||||
|
current_user, target_user = get_users(current_user, nil)
|
||||||
|
user_score = current_user.try(:user_score_attr)
|
||||||
|
return false if current_user.nil?
|
||||||
|
case operate
|
||||||
|
when :push_code # current_user 提交了代码
|
||||||
|
user_score = user_score.active.to_i + 4
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed code one time. options => (#{options.to_s})"
|
||||||
|
when :push_document # current_user
|
||||||
|
user_score.active = user_score.active.to_i + 4
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a document. options => (#{options.to_s})"
|
||||||
|
when :push_file # current_user
|
||||||
|
user_score.active = user_score.active.to_i + 4
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a file. options => (#{options.to_s})"
|
||||||
|
when :update_issue_ratio # current_user
|
||||||
|
user_score.active = user_score.active.to_i + 2
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})"
|
||||||
|
when :post_issue # current_user
|
||||||
|
user_score.active = user_score.active.to_i + 4
|
||||||
|
user_score.save
|
||||||
|
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] posting issue. options => (#{options.to_s})"
|
||||||
|
else
|
||||||
|
Rails.logger.error "[UserScore#project] ===> #{operate} is not define."
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "[UserScore#project] ===> Exception: #{e}."
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.get_users(current_user, target_user)
|
||||||
|
cUser = (current_user.kind_of?User) ? current_user : User.find_by_id(current_user)
|
||||||
|
tUser = (target_user.kind_of?User) ? target_user : User.find_by_id(target_user)
|
||||||
|
|
||||||
|
[cUser, tUser]
|
||||||
|
end
|
||||||
|
|
||||||
|
#修正分数
|
||||||
|
#分数小于0时修正为0
|
||||||
|
#分数大于等于0时不修正 -by zjc
|
||||||
|
def correct_score
|
||||||
|
if !self.collaboration.nil? && self.collaboration < 0
|
||||||
|
self.collaboration = 0
|
||||||
|
end
|
||||||
|
if !self.influence.nil? && self.influence < 0
|
||||||
|
self.influence = 0
|
||||||
|
end
|
||||||
|
if !self.skill.nil? && self.skill < 0
|
||||||
|
self.skill = 0
|
||||||
|
end
|
||||||
|
if !self.active.nil? && self.active < 0
|
||||||
|
self.active = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,8 @@ class Watcher < ActiveRecord::Base
|
||||||
has_one :project_status
|
has_one :project_status
|
||||||
has_one :users_status
|
has_one :users_status
|
||||||
#end
|
#end
|
||||||
|
before_save :be_user_score
|
||||||
|
before_destroy :down_user_score
|
||||||
|
|
||||||
validates_presence_of :user
|
validates_presence_of :user
|
||||||
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
|
||||||
|
@ -70,4 +72,22 @@ class Watcher < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
pruned
|
pruned
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 更新用户分数 -by zjc
|
||||||
|
def be_user_score
|
||||||
|
#添加了关注
|
||||||
|
if self.new_record? && self.watchable_type == 'Principal'
|
||||||
|
#影响力得分
|
||||||
|
UserScore.influence(:followed_by, self.user,self.watchable, { watcher_id: self.id })
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
#减分操作 -by zjc
|
||||||
|
def down_user_score
|
||||||
|
#取消关注
|
||||||
|
if self.watchable_type == 'Principal'
|
||||||
|
UserScore.influence(:cancel_followed, self.user,self.watchable, { watcher_id: self.id })
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<!-- fq -->
|
<!-- fq -->
|
||||||
<% is_student = is_cur_course_student? @bid.courses.first %>
|
<% is_student = is_cur_course_student(@bid.courses.first) %>
|
||||||
<% is_teacher = is_course_teacher User.current,@bid.courses.first %>
|
<% is_teacher = is_course_teacher User.current,@bid.courses.first %>
|
||||||
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能,2表示未启用 -->
|
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能,2表示未启用 -->
|
||||||
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
|
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
|
||||||
|
|
||||||
<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
|
<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
|
||||||
<div class="project-search-block">
|
<div class="project-search-block">
|
||||||
<table width="100%" valign="center">
|
<table width="100%" valign="center">
|
||||||
|
@ -43,21 +42,13 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<% homework_filename = attachment.filename %>
|
<% homework_filename = attachment.filename %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!--
|
|
||||||
<% if attachments.count > 1 && attachment != attachments.first %>
|
|
||||||
<br/>
|
|
||||||
<% for item in 1..7 %>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
-->
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% homework_filename = homework.name %>
|
<% homework_filename = homework.name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<strong>
|
<strong>
|
||||||
<% if is_evaluation || is_teacher%>
|
<% if is_evaluation || is_teacher%>
|
||||||
<%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:obj_class => @bid.class,:obj_id => @bid, :user_id =>homework.user%>
|
<%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= homework_filename %>
|
<%= homework_filename %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -84,7 +75,7 @@
|
||||||
<td>
|
<td>
|
||||||
<strong>作业评分:</strong>
|
<strong>作业评分:</strong>
|
||||||
|
|
||||||
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_i ) %>
|
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" align="right">
|
<td valign="top" align="right">
|
||||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||||
|
@ -99,11 +90,12 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? &&
|
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
|
||||||
(Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
|
|
||||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
<% if homework.user == User.current || is_teacher %>
|
||||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||||
|
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -112,4 +104,4 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="line_under"></div>
|
<div class="line_under"></div>
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,8 +1,9 @@
|
||||||
<% if @bid.homework_type == Bid::HomeworkFile %>
|
<% if @bid.homework_type == Bid::HomeworkFile %>
|
||||||
|
<!-- 提交文件类型 -->
|
||||||
<%= render :partial => 'homework' %>
|
<%= render :partial => 'homework' %>
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<!-- 提交引用项目 -->
|
||||||
<script type="text/javascript" language="javascript">
|
<script type="text/javascript" language="javascript">
|
||||||
function clearInfo(id, content) {
|
function clearInfo(id, content) {
|
||||||
var text = $('#' + id);
|
var text = $('#' + id);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<div class="frame-wiki">
|
||||||
|
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<% if User.current.allowed_to?(:edit_documents, @project) %>
|
<% if User.current.allowed_to?(:edit_documents, @project) %>
|
||||||
<%= link_to l(:button_edit), edit_document_path(@document), :class => 'icon icon-edit', :accesskey => accesskey(:edit) %>
|
<%= link_to l(:button_edit), edit_document_path(@document), :class => 'icon icon-edit', :accesskey => accesskey(:edit) %>
|
||||||
|
@ -7,26 +9,15 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <h3><%=h @document.title %></h3>
|
<h2><%=h @document.title %></h2>
|
||||||
|
|
||||||
<p><em><%=h @document.category.name %><br />
|
<p><em><%=h @document.category.name %><br />
|
||||||
<%= format_date @document.created_on %></em></p>
|
<%= format_date @document.created_on %></em></p>
|
||||||
<div class="wiki">
|
<div class="wiki">
|
||||||
<%= textilizable @document.description, :attachments => @document.attachments %>
|
<%= textilizable @document, :description, :attachments => @document.attachments %>
|
||||||
</div> -->
|
</div>
|
||||||
<!--add by huang-->
|
|
||||||
<table width="660px" align="center">
|
|
||||||
<tr><td><h3><strong><%=h @document.title %></strong></h3></td></tr>
|
|
||||||
<tr><td>
|
|
||||||
<div class="font_description">
|
|
||||||
<%= textilizable @document.description, :attachments => @document.attachments %>
|
|
||||||
</div>
|
|
||||||
</td></tr>
|
|
||||||
<tr><td align="right"><p class="font_lighter"><%= format_date @document.created_on %></p></td></tr>
|
|
||||||
<tr><td class="line_under"></td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
<div style="border-top:solid 1px #C6E9F1;"></div>
|
||||||
<h3><%= l(:label_attachment_plural) %></h3>
|
<h3><%= l(:label_attachment_plural) %></h3>
|
||||||
<%= link_to_attachments @document %>
|
<%= link_to_attachments @document %>
|
||||||
|
|
||||||
|
@ -42,3 +33,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% html_title @document.title -%>
|
<% html_title @document.title -%>
|
||||||
|
</div>
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<%= error_messages_for 'member' %>
|
||||||
|
<div style="float:left; width:60%;padding-left: 10px;padding-right: 10px"
|
||||||
|
xmlns="http://www.w3.org/1999/html" id = "homework_of_users">
|
||||||
|
<table class="list members" style="width: 100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= l(:label_user) %></th>
|
||||||
|
<th><%= l(:label_role_plural) %></th>
|
||||||
|
<th style="width:10%"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<!-- 发布人员不能被删除,将发布人员放在第一位 -->
|
||||||
|
<tr id="member-<%= homework.user.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
|
||||||
|
<td style="width: 40%"><%= link_to_user homework.user %></td>
|
||||||
|
<td style="text-align: center;width: 50%"> 发布人员 </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% hoemwork_users.each do |user| %>
|
||||||
|
<tr id="member-<%= user.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
|
||||||
|
<% if homework.user != user %>
|
||||||
|
<td style="width: 40%"><%= link_to_user user %></td>
|
||||||
|
<td style="text-align: center;width: 50%"> 参与人员 </td>
|
||||||
|
<td><%= link_to l(:button_delete),destory_homework_users_homework_attach_path(:user_id=>user),:remote => true, :method => :post %></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="splitcontentright" style="width: 37%">
|
||||||
|
<%= form_for(hoemwork_users, {:url => add_homework_users_homework_attach_path(homework), :remote => true, :method => :post}) do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<legend><%= l(:label_member_new) %></legend>
|
||||||
|
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
|
||||||
|
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript get_homework_member_list_homework_attach_index_path(:q => params[:q], :bid_id => params[:id]||homework, :format => 'js') }')" %>
|
||||||
|
<div id="principals_for_new_member">
|
||||||
|
<%= render_new_members_for_homework(members) %>
|
||||||
|
</div>
|
||||||
|
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div id="principals_for_new_member">
|
||||||
|
<%= render_new_members_for_homework(members) %>
|
||||||
|
</div>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<div class="box">
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<strong>标 题:</strong>
|
||||||
|
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
||||||
|
</p>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
|
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p style="padding-left: 60px">
|
||||||
|
<fieldset style="text-align: left;">
|
||||||
|
<legend>
|
||||||
|
<%= l(:label_attachment_plural) %>
|
||||||
|
</legend>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<%= render :partial => 'attachments/form' %>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</p>
|
||||||
|
</div>
|
|
@ -0,0 +1 @@
|
||||||
|
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');
|
|
@ -0,0 +1 @@
|
||||||
|
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');
|
|
@ -1,35 +1,79 @@
|
||||||
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
|
<script type="text/javascript">
|
||||||
<div class="box">
|
function switchTab(ProTag) {
|
||||||
|
var display_index = 3 - ProTag;
|
||||||
|
document.getElementById("tab" + ProTag).className = "selected";
|
||||||
|
document.getElementById("tab" + display_index).className = "";
|
||||||
|
document.getElementById("content" + ProTag).style.display = "";
|
||||||
|
document.getElementById("content" + display_index).style.display = "none";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="top-content">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||||
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||||
|
<span><%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%></span> >
|
||||||
|
<%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <span><%= link_to "修改作业",edit_homework_attach_path(@homework)%></span></p></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_edit_homework)%> </p>
|
||||||
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a id = "tab1" href="#" class = "selected" onclick="switchTab(1);this.blur();return false;">
|
||||||
|
<%= l(:label_information_plural) %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a id="tab2" href="#" onclick="switchTab(2); this.blur(); return false;">
|
||||||
|
<%= l(:label_member_plural) %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="box" id="content1">
|
||||||
<%= form_for(@homework) do |f|%>
|
<%= form_for(@homework) do |f|%>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong>标 题:</strong>
|
<strong>标 题:</strong>
|
||||||
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
|
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
|
||||||
</p>
|
</p>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong style="vertical-align: top">描 述:</strong>
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
<span style="margin-left:-10px;padding-right: 20px;">
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p style="padding-left: 60px">
|
<p style="padding-left: 60px">
|
||||||
<fieldset style="text-align: left;">
|
<fieldset style="text-align: left;">
|
||||||
<p style="padding-left: 60px">
|
<p style="padding-left: 60px">
|
||||||
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
|
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
|
||||||
<%= render :partial => 'attachments/links',
|
<%= render :partial => 'attachments/links',
|
||||||
:locals => {:attachments => @homework.attachments, :options => options} %>
|
:locals => {:attachments => @homework.attachments, :options => options} %>
|
||||||
</p>
|
</p>
|
||||||
<legend>
|
<legend>
|
||||||
<%= l(:label_attachment_plural) %>
|
<%= l(:label_attachment_plural) %>
|
||||||
</legend>
|
</legend>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<%= render :partial => 'attachments/form' %>
|
<%= render :partial => 'attachments/form' %>
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</p>
|
</p>
|
||||||
<p style="padding-left: 60px;padding-top: 10px;">
|
<p style="padding-left: 60px;padding-top: 10px;">
|
||||||
<span >
|
<span >
|
||||||
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="content2" style="display: none" >
|
||||||
|
<%= render :partial => "homework_member",:locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} %>
|
||||||
|
</div>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
$('#principals_for_new_member').replaceWith('<%= j(render :partial => "member_list_partial", locals:{members: @members})%>');
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
<div class="top-content">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||||
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||||
|
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
||||||
|
<%=link_to(@bid.name, respond_path(@bid)) %> > <span><%= link_to "创建作业", new_homework_attach_path(@bid)%></span></p></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=h l(:label_new_homework)%> </p>
|
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=h l(:label_new_homework)%> </p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<%= form_for('new_form', :method => :post,
|
<%= form_for('new_form', :method => :post,
|
||||||
|
@ -26,10 +42,11 @@
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</p>
|
</p>
|
||||||
<p style="padding-left: 60px;padding-top: 10px;">
|
|
||||||
|
<p style="padding-left: 60px;padding-top: 5px;">
|
||||||
<span >
|
<span >
|
||||||
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
<%= render :partial => 'layouts/base_homework_attach', :locals => {:homework_attach => @homework} %>
|
||||||
<style>
|
<style>
|
||||||
.softapplication-img .soft-application {
|
.softapplication-img .soft-application {
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
height: 200px;
|
height: 200px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<% is_student = is_cur_course_student? @homework.bid.courses.first %>
|
<% is_student = is_cur_course_student @homework.bid.courses.first %>
|
||||||
<% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %>
|
<% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %>
|
||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
<!-- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> -->
|
<!-- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> -->
|
||||||
|
@ -23,7 +23,9 @@
|
||||||
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
|
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
|
||||||
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
|
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
|
||||||
</td>
|
</td>
|
||||||
<td>发布时间:<%=format_time @homework.created_at %></td>
|
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
|
||||||
|
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 40px">
|
<td style="padding-left: 40px">
|
||||||
|
@ -35,15 +37,21 @@
|
||||||
<%= l(:label_cant_download) %>
|
<%= l(:label_cant_download) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
|
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
|
||||||
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
|
参与人员:
|
||||||
|
<% @homework.users.each do |homework_user| %>
|
||||||
|
<%= link_to homework_user, user_path(homework_user)%>
|
||||||
|
<% if @homework.users.count > 1 && homework_user != @homework.users.last %>
|
||||||
|
<br/>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 40px" colspan="2">平均评分:
|
<td style=" padding-left: 40px">平均评分:
|
||||||
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
|
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
|
||||||
</td>
|
</td>
|
||||||
|
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
|
@ -133,32 +141,37 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="underline-contests_one"></div>
|
<div class="underline-contests_one"></div>
|
||||||
<div style="height: 50px">
|
|
||||||
<div style="font-size: 15px"><strong>作业评论:</strong></div>
|
<!-- 作业成员(发布人员和参与人员)不能对作业进行评分 -->
|
||||||
<% if is_student %>
|
<% if !users_for_homework(@homework).include?(User.current) %>
|
||||||
<% if @is_evaluation %>
|
<div style="height: 50px">
|
||||||
<% if @has_evaluation %>
|
<div style="font-size: 15px"><strong>作业评论:</strong></div>
|
||||||
<div style="text-align: center;">
|
<% if is_student %>
|
||||||
<%= l(:lable_has_evaluation)%>
|
<% if @is_evaluation %>
|
||||||
</div>
|
<% if @has_evaluation %>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<%= l(:lable_has_evaluation)%>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<%= render :partial => 'evaluation', :locals => {:homework => @homework} %>
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= render :partial => 'evaluation', :locals => {:homework => @homework} %>
|
<div style="text-align: center;">
|
||||||
|
<%= l(:lable_close_evaluation)%>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
|
||||||
<div style="text-align: center;">
|
|
||||||
<%= l(:lable_close_evaluation)%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
|
|
||||||
<% if !is_teacher %>
|
<% if !is_teacher %>
|
||||||
<!--提示登录后对应用进行评价-->
|
<!--提示登录后对应用进行评价-->
|
||||||
<div id="leave-message">
|
<div id="leave-message">
|
||||||
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
|
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<!-- 留言列表区 -->
|
<!-- 留言列表区 -->
|
||||||
<div id="message" style="font-size: 14px;">
|
<div id="message" style="font-size: 14px;">
|
||||||
<%= render :partial => 'showjour', :locals => {:jour => @jour,:homework => @homework} %>
|
<%= render :partial => 'showjour', :locals => {:jour => @jour,:homework => @homework} %>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<!--add by huang-->
|
<!--add by huang-->
|
||||||
|
<% cache "footer" do %>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
<div id="footer" style="margin-left:-5px;padding-top: 20px;clear: both;font-size: 12px;">
|
<div id="footer" style="margin-left:-5px;padding-top: 20px;clear: both;font-size: 12px;">
|
||||||
<div style="border-top:solid 1px #C6E9F1;"></div>
|
<div style="border-top:solid 1px #C6E9F1;"></div>
|
||||||
|
@ -31,7 +32,9 @@
|
||||||
<div class="debug">
|
<div class="debug">
|
||||||
<%= debug(params) if Rails.env.development? %>
|
<%= debug(params) if Rails.env.development? %>
|
||||||
|
|
||||||
|
<script src="http://s4.cnzz.com/z_stat.php?id=1000482288&web_id=1000482288" language="JavaScript"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
@ -42,3 +45,5 @@
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<div class="top-content">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||||
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||||
|
<span><%= link_to(homework_attach.bid.courses.first.name.to_s, homework_project_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%></span> >
|
||||||
|
<%=link_to(homework_attach.bid.name, respond_path(homework_attach.bid)) %> > <span><%= link_to homework_attach.name.nil? ? homework_attach.attachments.first.filename : homework_attach.name,homework_attach_path(homework_attach)%></span></p></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
|
@ -22,27 +22,27 @@
|
||||||
<% course = project.course_extra %>
|
<% course = project.course_extra %>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<div id="wrapper2">
|
<div id="wrapper2">
|
||||||
<div id="wrapper3">
|
<div id="wrapper3">
|
||||||
<%= render :partial => 'layouts/base_header'%>
|
<%= render :partial => 'layouts/base_header'%>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<!--added by huang-->
|
<!--added by huang-->
|
||||||
<div class="top-content">
|
<div class="top-content">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||||
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
||||||
<%=link_to(@bid.name, respond_path(@bid)) %></p></td>
|
<%=link_to(@bid.name, respond_path(@bid)) %></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<!--end-->
|
<!--end-->
|
||||||
|
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div class="main_context">
|
<div class="main_context">
|
||||||
<div class="spaceleft">
|
<div class="spaceleft">
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
|
|
||||||
<div class="memo-title <%= @memo.sticky ? 'sticky' : '' %> <%= @memo.locked? ? 'locked' : '' %>"><%= label_tag l(:field_subject) %>: <%=h @memo.subject %></div>
|
<div class="memo-title <%= @memo.sticky ? 'sticky' : '' %> <%= @memo.locked? ? 'locked' : '' %>"><%= label_tag l(:field_subject) %>: <%=h @memo.subject %></div>
|
||||||
<div class="memo-content">
|
<div class="memo-content">
|
||||||
<!-- < %= textilizable(@memo, :content) %> -->
|
|
||||||
<%= raw @memo.content %>
|
<%= raw @memo.content %>
|
||||||
<p>
|
<p>
|
||||||
<% if @memo.attachments.any?%>
|
<% if @memo.attachments.any?%>
|
||||||
|
|
|
@ -60,6 +60,8 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="lz">
|
<div class="lz">
|
||||||
|
<!-- 在这里添加赞和踩-->
|
||||||
|
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id}%> </span>
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= watcher_link(@topic, User.current) %>
|
<%= watcher_link(@topic, User.current) %>
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
|
@ -82,6 +84,7 @@
|
||||||
:class => 'icon icon-del'
|
:class => 'icon icon-del'
|
||||||
) if @message.destroyable_by?(User.current) %>
|
) if @message.destroyable_by?(User.current) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="lz-left">
|
<div class="lz-left">
|
||||||
<div class="">
|
<div class="">
|
||||||
<%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %>
|
<%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<p class="font_description">
|
<p class="font_description">
|
||||||
|
|
||||||
<%= l(:label_project_cousre_studentun) %><%= link_to"#{l(:label_course_join_student)}",{:controller=>'projects',:action=>'course', :course => 1}, :class => 'icon icon-add' %>
|
<%= l(:label_project_cousre_studentun) %><%= link_to"#{l(:label_course_join_student)}",{:controller=>'projects',:action=>'course', :project_type => 1}, :class => 'icon icon-add' %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<!-- added by bai -->
|
<!-- added by bai -->
|
||||||
<% unless @user.id == 1%>
|
|
||||||
<% messages_count = @user.messages.count %>
|
<% messages_count = @user.messages.count %>
|
||||||
<% messages_score = messages_count * 0.05%>
|
<% messages_score = messages_count * 0.05%>
|
||||||
<% finall_messages_score = messages_score %>
|
<% finall_messages_score = messages_score %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% journals_count = @user.journals.count %>
|
<% journals_count = @user.journals.count %>
|
||||||
<% journals_score = journals_count * 0.1 %>
|
<% journals_score = journals_count * 0.1 %>
|
||||||
|
@ -28,7 +26,7 @@
|
||||||
|
|
||||||
<h3 class="title"><%= l(:label_user_score) %></h3>
|
<h3 class="title"><%= l(:label_user_score) %></h3>
|
||||||
<div class="inf_user_image">
|
<div class="inf_user_image">
|
||||||
<table style="border-bottom: solid 1px #80a6d2;", width="100%">
|
<table style="border-bottom: solid 1px #80a6d2;" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left" valign="middle" ><%= image_tag(url_to_avatar(@user), :class => 'avatar2') %></td>
|
<td align="left" valign="middle" ><%= image_tag(url_to_avatar(@user), :class => 'avatar2') %></td>
|
||||||
<td width="35%">
|
<td width="35%">
|
||||||
|
@ -48,7 +46,7 @@
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table style="border-bottom: solid 0px #80a6d2;", width="100%">
|
<table style="border-bottom: solid 0px #80a6d2;" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> :
|
<%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> :
|
||||||
<%= format("%.2f" , finall_user_score).to_f %>
|
<%= format("%.2f" , finall_user_score).to_f %>
|
||||||
|
@ -73,31 +71,6 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="inf_user_image">
|
<div id="show_score_detail" style="padding-left: 6px">
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> :
|
|
||||||
<%= format("%.2f" , finall_user_score).to_f %>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<%= link_to l(:label_user_score_of_topic), {:controller => 'users', :action => 'topic_score_index', :remote => true} %> :
|
|
||||||
<%= format("%.2f" , finall_messages_score).to_f %>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<%= link_to l(:label_user_score_of_project), {:controller => 'users', :action => 'project_score_index', :remote => true} %> :
|
|
||||||
<%= format("%.2f" , finall_user_project_score).to_f %>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<%= link_to l(:label_user_score_of_activity), {:controller => 'users', :action => 'activity_score_index', :remote => true} %> :
|
|
||||||
<%= format("%.2f" , finall_activity_score).to_f %>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<%= link_to l(:label_user_score_of_influence), {:controller => 'users', :action => 'influence_score_index', :remote => true} %> :
|
|
||||||
<%= format("%.2f" , finall_influence_score).to_f %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div> -->
|
|
||||||
<div id="show_score_detail", style="padding-left: 6px">
|
|
||||||
<%= render :partial => 'users/score_index', :locals => {:index => 0 } %>
|
<%= render :partial => 'users/score_index', :locals => {:index => 0 } %>
|
||||||
</div>
|
</div>
|
||||||
<!-- end -->
|
|
|
@ -1,5 +1,3 @@
|
||||||
<!-- added by bai -->
|
|
||||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_score') %>');
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_score') %>');
|
||||||
showModal('ajax-modal', '400px');
|
showModal('ajax-modal', '400px');
|
||||||
$('#ajax-modal').addClass('new-watcher');
|
$('#ajax-modal').addClass('new-watcher');
|
||||||
<!-- end -->
|
|
|
@ -13,7 +13,7 @@
|
||||||
<tr> <!-- modified by bai 区别了“关注”里个人参与的项目与课程-->
|
<tr> <!-- modified by bai 区别了“关注”里个人参与的项目与课程-->
|
||||||
<td colspan="2" width="580px" ><p class="font_description">
|
<td colspan="2" width="580px" ><p class="font_description">
|
||||||
<% unless user.memberships.empty? %>
|
<% unless user.memberships.empty? %>
|
||||||
<% cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" %>
|
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>
|
||||||
<% memberships = user.memberships.all(:conditions => cond) %>
|
<% memberships = user.memberships.all(:conditions => cond) %>
|
||||||
<%= l(:label_x_contribute_to, :count => memberships.count) %>
|
<%= l(:label_x_contribute_to, :count => memberships.count) %>
|
||||||
<% for member in memberships %>
|
<% for member in memberships %>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p class="font_description">
|
<p class="font_description">
|
||||||
<% unless user.memberships.empty? %>
|
<% unless user.memberships.empty? %>
|
||||||
<% cond = Project.visible_condition(User.current) + "AND projects.project_type = 1" %>
|
<% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %>
|
||||||
<% memberships = user.memberships.all(:conditions => cond) %>
|
<% memberships = user.memberships.all(:conditions => cond) %>
|
||||||
<%= l(:label_x_course_contribute_to, :count => memberships.count) %>
|
<%= l(:label_x_course_contribute_to, :count => memberships.count) %>
|
||||||
<% for member in memberships %>
|
<% for member in memberships %>
|
||||||
|
|
|
@ -52,7 +52,9 @@
|
||||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
|
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
|
||||||
<div class="d-p-projectlist-box">
|
<div class="d-p-projectlist-box">
|
||||||
<ul class="d-p-projectlist">
|
<ul class="d-p-projectlist">
|
||||||
<% find_miracle_project(10, 3).map do |project| %>
|
<% projects = find_miracle_project(10, 3) %>
|
||||||
|
<% cache projects do %>
|
||||||
|
<% projects.map do |project| %>
|
||||||
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
||||||
<div style="float: left;">
|
<div style="float: left;">
|
||||||
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
|
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
|
||||||
|
@ -71,11 +73,11 @@
|
||||||
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
|
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
|
||||||
:class => "tooltip",
|
:class => "tooltip",
|
||||||
:id => "tooltip-#{project.id}" %>
|
:id => "tooltip-#{project.id}" %>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<% end; reset_cycle %>
|
<% end; reset_cycle %>
|
||||||
</ul>
|
</ul>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -84,7 +86,9 @@
|
||||||
<h3 style="color: rgb(21, 188, 207)"><strong>用户动态</strong></h3>
|
<h3 style="color: rgb(21, 188, 207)"><strong>用户动态</strong></h3>
|
||||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %></span>
|
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %></span>
|
||||||
<div class="user-message-box-list" style="margin-top: 10px;">
|
<div class="user-message-box-list" style="margin-top: 10px;">
|
||||||
<% find_all_activities.each do |event| %>
|
<%activities = find_all_activities%>
|
||||||
|
<% cache activities do %>
|
||||||
|
<% activities.each do |event| %>
|
||||||
<li style="display: block;height:60px; padding-bottom: 4px;">
|
<li style="display: block;height:60px; padding-bottom: 4px;">
|
||||||
<div class="inner-right" style="float: left; height: 100%; ">
|
<div class="inner-right" style="float: left; height: 100%; ">
|
||||||
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
|
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
|
||||||
|
@ -96,12 +100,14 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %><!-- cache -->
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right" style="float: right; width: 48%; ">
|
<div class="right" style="float: right; width: 48%; ">
|
||||||
<ul class="welcome-message-list">
|
<ul class="welcome-message-list">
|
||||||
|
<% cache 'forum_links' do %>
|
||||||
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
|
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
|
||||||
<h3 style="color: rgb(21, 188, 207);">
|
<h3 style="color: rgb(21, 188, 207);">
|
||||||
<strong>贴吧动态</strong>
|
<strong>贴吧动态</strong>
|
||||||
|
@ -109,8 +115,11 @@
|
||||||
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%></h3>
|
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%></h3>
|
||||||
<span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
|
<span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="welcome-box-list-new memo_activity">
|
<div class="welcome-box-list-new memo_activity">
|
||||||
<% find_new_forum_topics(7).each do |topic|%>
|
<% topics = find_new_forum_topics(7) %>
|
||||||
|
<% cache topics do %>
|
||||||
|
<% topics.each do |topic|%>
|
||||||
<li class="message-brief-intro">
|
<li class="message-brief-intro">
|
||||||
<div class='memo_title text_nowrap'>
|
<div class='memo_title text_nowrap'>
|
||||||
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
|
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
|
||||||
|
@ -131,6 +140,7 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %> <!-- cache -->
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -473,6 +473,27 @@ en:
|
||||||
permission_export_wiki_pages: Export wiki pages
|
permission_export_wiki_pages: Export wiki pages
|
||||||
permission_manage_subtasks: Manage subtasks
|
permission_manage_subtasks: Manage subtasks
|
||||||
permission_manage_related_issues: Manage related issues
|
permission_manage_related_issues: Manage related issues
|
||||||
|
permission_view_journals_for_messages: View journals messages
|
||||||
|
permission_view_courses: View courses
|
||||||
|
permission_new_course: Create course
|
||||||
|
permission_configure_course: Configure course
|
||||||
|
permission_close_course: Close/open course
|
||||||
|
permission_new_assignment: Create assignment
|
||||||
|
permission_edit_assignment: Edit assignment
|
||||||
|
permission_delete_assignment: Delete assignment
|
||||||
|
permission_new_placeholder: Create placeholder
|
||||||
|
permission_edit_placeholder: Edit placeholder
|
||||||
|
permission_delete_placeholder: Delete placeholder
|
||||||
|
permission_commit_content: Commit content
|
||||||
|
permission_new_course_notify: Create course notify
|
||||||
|
permission_edit_course_notify: Eidt course notify
|
||||||
|
permission_delete_course_notify: Delete course notify
|
||||||
|
permission_view_assignment: View assignment
|
||||||
|
permission_view_placeholder: View placeholder
|
||||||
|
permission_view_course_messages: View course messages
|
||||||
|
permission_view_real_name: View real name
|
||||||
|
permission_view_students: View students
|
||||||
|
permission_export_homeworks: Export homeworks
|
||||||
|
|
||||||
project_module_issue_tracking: Issue tracking
|
project_module_issue_tracking: Issue tracking
|
||||||
project_module_time_tracking: Time tracking
|
project_module_time_tracking: Time tracking
|
||||||
|
|
|
@ -176,6 +176,7 @@ zh:
|
||||||
notice_file_not_found: 您访问的页面不存在或已被删除。
|
notice_file_not_found: 您访问的页面不存在或已被删除。
|
||||||
notice_locking_conflict: 数据已被另一位用户更新
|
notice_locking_conflict: 数据已被另一位用户更新
|
||||||
notice_not_authorized: 对不起,您无权访问此页面。
|
notice_not_authorized: 对不起,您无权访问此页面。
|
||||||
|
notice_has_homework: 您已经提交过一份作业
|
||||||
notice_not_contest_setting_authorized: 对不起,您无权配置此竞赛。
|
notice_not_contest_setting_authorized: 对不起,您无权配置此竞赛。
|
||||||
notice_not_contest_delete_authorized: 对不起,您无权删除此竞赛。
|
notice_not_contest_delete_authorized: 对不起,您无权删除此竞赛。
|
||||||
notice_not_authorized_archived_project: 要访问的项目已经归档。
|
notice_not_authorized_archived_project: 要访问的项目已经归档。
|
||||||
|
@ -453,7 +454,27 @@ zh:
|
||||||
permission_export_wiki_pages: 导出 wiki 页面
|
permission_export_wiki_pages: 导出 wiki 页面
|
||||||
permission_manage_subtasks: 管理子任务
|
permission_manage_subtasks: 管理子任务
|
||||||
permission_view_journals_for_messages: 查看留言
|
permission_view_journals_for_messages: 查看留言
|
||||||
permission_view_courses: 查看课程列表
|
permission_view_courses: 查看课程
|
||||||
|
permission_new_course: 新建课程
|
||||||
|
permission_configure_course: 配置课程
|
||||||
|
permission_close_course: 关闭/重开课程
|
||||||
|
permission_new_assignment: 新建任务
|
||||||
|
permission_edit_assignment: 编辑任务
|
||||||
|
permission_delete_assignment: 删除任务
|
||||||
|
permission_new_placeholder: 新建占位
|
||||||
|
permission_edit_placeholder: 编辑占位
|
||||||
|
permission_delete_placeholder: 删除占位
|
||||||
|
permission_commit_content: 提交内容
|
||||||
|
permission_new_course_notify: 发布课程通知
|
||||||
|
permission_edit_course_notify: 编辑课程通知
|
||||||
|
permission_delete_course_notify: 删除课程通知
|
||||||
|
permission_view_assignment: 查看任务
|
||||||
|
permission_view_placeholder: 查看占位
|
||||||
|
permission_view_course_messages: 查看留言
|
||||||
|
permission_view_real_name: 查看真名
|
||||||
|
permission_view_students: 查看成员
|
||||||
|
permission_export_homeworks: 导出作业
|
||||||
|
|
||||||
|
|
||||||
project_module_issue_tracking: 问题跟踪
|
project_module_issue_tracking: 问题跟踪
|
||||||
project_module_time_tracking: 时间跟踪
|
project_module_time_tracking: 时间跟踪
|
||||||
|
|
|
@ -26,11 +26,18 @@ RedmineApp::Application.routes.draw do
|
||||||
|
|
||||||
resources :homework_attach do
|
resources :homework_attach do
|
||||||
collection do
|
collection do
|
||||||
|
get 'get_homework_member_list'
|
||||||
match 'addjours', via: [:get, :post]
|
match 'addjours', via: [:get, :post]
|
||||||
match 'add_jour_reply', via: [:get,:post]
|
match 'add_jour_reply', via: [:get,:post]
|
||||||
match 'destroy_jour', via: [:get,:post]
|
match 'destroy_jour', via: [:get,:post]
|
||||||
|
|
||||||
|
end
|
||||||
|
member do
|
||||||
|
match 'add_homework_users', via:[:get,:post]
|
||||||
|
match 'destory_homework_users',via:[:get,:post]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :open_source_projects do
|
resources :open_source_projects do
|
||||||
collection do
|
collection do
|
||||||
match 'search', via: [:get, :post]
|
match 'search', via: [:get, :post]
|
||||||
|
|
|
@ -172,6 +172,7 @@ default_projects_modules:
|
||||||
- boards
|
- boards
|
||||||
- calendar
|
- calendar
|
||||||
- gantt
|
- gantt
|
||||||
|
- course
|
||||||
default_projects_tracker_ids:
|
default_projects_tracker_ids:
|
||||||
serialized: true
|
serialized: true
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddUserIdToDocuments < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :documents, :user_id, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140605025247) do
|
ActiveRecord::Schema.define(:version => 20140609061903) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -288,6 +288,7 @@ ActiveRecord::Schema.define(:version => 20140605025247) do
|
||||||
t.string "title", :limit => 60, :default => "", :null => false
|
t.string "title", :limit => 60, :default => "", :null => false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.datetime "created_on"
|
t.datetime "created_on"
|
||||||
|
t.integer "user_id", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "documents", ["category_id"], :name => "index_documents_on_category_id"
|
add_index "documents", ["category_id"], :name => "index_documents_on_category_id"
|
||||||
|
|
|
@ -47,8 +47,13 @@ module Redmine
|
||||||
################### modified by liuping
|
################### modified by liuping
|
||||||
def remove_watcher(user)
|
def remove_watcher(user)
|
||||||
return nil unless user && user.is_a?(User)
|
return nil unless user && user.is_a?(User)
|
||||||
if self.instance_of?(User)
|
if self.instance_of?(User)
|
||||||
Watcher.delete_all "watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
#通过model层删除以触发before_destroy事件 -by zjc
|
||||||
|
watchers = Watcher.find_by_sql "select * from `watchers` where watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
||||||
|
watchers.each do |watcher|
|
||||||
|
watcher.destroy
|
||||||
|
end
|
||||||
|
#Watcher.delete_all "watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
||||||
else
|
else
|
||||||
Watcher.delete_all "watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
Watcher.delete_all "watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
||||||
end
|
end
|
||||||
|
|
1794
lib/redcloth3.rb
1794
lib/redcloth3.rb
File diff suppressed because it is too large
Load Diff
|
@ -179,13 +179,27 @@ Redmine::AccessControl.map do |map|
|
||||||
end
|
end
|
||||||
|
|
||||||
#课程权限模块
|
#课程权限模块
|
||||||
map.project_module :course do
|
map.project_module :course do |map|
|
||||||
map.permission :view_courses,{:projects => [:course]},:read => true
|
map.permission :view_courses,{:projects => [:course]},:read => true
|
||||||
end
|
#map.permission :new_course, {}, :read => true
|
||||||
|
#map.permission :configure_course,{},:read => true
|
||||||
#作业模块权限
|
#map.permission :close_course,{},:read => true
|
||||||
map.project_module :bids do |map|
|
map.permission :new_assignment,{:projects => [:new_homework]},:read => true
|
||||||
map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true
|
map.permission :edit_assignment,{:bids => [:edit]},:read => true
|
||||||
|
map.permission :delete_assignment,{:bids => [:homework_destroy]},:read => true
|
||||||
|
map.permission :new_placeholder,{:homework_attach => [:new]},:read => true
|
||||||
|
map.permission :edit_placeholder,{:homework_attach => [:edit,:update]},:read => true
|
||||||
|
map.permission :delete_placeholder,{:homework_attach => [:destroy]},:read => true
|
||||||
|
#map.permission :commit_content,{},:read => true
|
||||||
|
#map.permission :new_course_notify,{},:read => true
|
||||||
|
#map.permission :edit_course_notify,{},:read => true
|
||||||
|
#map.permission :delete_course_notify,{},:read => true
|
||||||
|
map.permission :view_assignment,{:projects => [:homework]},:read => true
|
||||||
|
map.permission :view_placeholder,{:bids => [:show_project]},:read => true
|
||||||
|
map.permission :view_course_messages,{:projects => [:feedback]},:read => true
|
||||||
|
map.permission :view_real_name,{:projects => [:real_name]},:read => true
|
||||||
|
map.permission :view_students,{:projects => [:member]}, :read=>true
|
||||||
|
map.permission :export_homeworks,{:zipdown => [:assort,:download_user_homework]},:read => true
|
||||||
end
|
end
|
||||||
|
|
||||||
map.project_module :boards do |map|
|
map.project_module :boards do |map|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
desc "User Score description"
|
||||||
|
task :user_score do
|
||||||
|
puts "user_score sync."
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :user_score do
|
||||||
|
desc "calculating user score"
|
||||||
|
# Rails.env = 'production'
|
||||||
|
task :calculate => :environment do
|
||||||
|
puts "loading..."
|
||||||
|
# collaboration 协同得分
|
||||||
|
users = {}
|
||||||
|
# 发帖
|
||||||
|
Message.includes(:author).where("parent_id IS NULL").all.each do |m|
|
||||||
|
users[m.author.id] = users[m.author.id].to_i + 2
|
||||||
|
end
|
||||||
|
puts ":post_message calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 对缺陷的留言
|
||||||
|
Journal.includes(:user).all.each do |j|
|
||||||
|
users[j.user.id] = users[j.user.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":post_issue calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 更改一次缺陷状态
|
||||||
|
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id'").each do |j|
|
||||||
|
users[j.user.id] = users[j.user.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":change_issue_status calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 对留言的回复
|
||||||
|
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL").each do |jfm|
|
||||||
|
users[jfm.user.id] = users[jfm.user.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":reply_message calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 对帖子的回复
|
||||||
|
Message.includes(:author).where("parent_id IS NOT NULL").each do |m|
|
||||||
|
users[m.author.id] = users[m.author.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":reply_posting calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
users.each do |user_id, score|
|
||||||
|
UserScore.find_or_create_by_user_id(user_id).update_attribute(:collaboration, score)
|
||||||
|
end
|
||||||
|
puts "=== UserScore#collaboration calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
users.clear
|
||||||
|
|
||||||
|
# influence 影响力得分
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# skill 技术得分
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# active 项目贡献得分
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "create tmp file, to test"
|
||||||
|
file 'tmp/test.yml' do
|
||||||
|
require 'yaml'
|
||||||
|
var = {
|
||||||
|
:name => "name",
|
||||||
|
:age => "age",
|
||||||
|
:agent => "agent"
|
||||||
|
}
|
||||||
|
File.open('tmp/test.yml', 'w') do |f|
|
||||||
|
f.write YAML.dump({'conf' => var })
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,9 @@
|
||||||
|
/* Temporary
|
||||||
|
*******************************************************************************/
|
||||||
|
.frame-wiki {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: base/common/page 准备封装一些基本样式组合调用 参考YUI
|
/* TODO: base/common/page 准备封装一些基本样式组合调用 参考YUI
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
* {
|
* {
|
||||||
|
|
|
@ -524,19 +524,8 @@ ul.projects li.root
|
||||||
margin:4px 20px 20px;
|
margin:4px 20px 20px;
|
||||||
padding-bottom:15px;
|
padding-bottom:15px;
|
||||||
text-align:left
|
text-align:left
|
||||||
/*font-size: 18px;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#footer a:hover
|
|
||||||
{
|
|
||||||
/*background:#666 none repeat scroll 0 0;*/
|
|
||||||
/*color:#FFF!important*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#footer a:link,#footer a:visited
|
|
||||||
{
|
|
||||||
/*color:#666*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#footer .bgr:after
|
#footer .bgr:after
|
||||||
{
|
{
|
||||||
|
@ -544,60 +533,6 @@ ul.projects li.root
|
||||||
float:right
|
float:right
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,h2,h3,h4
|
|
||||||
{
|
|
||||||
font-family:'微软雅黑',"PT Sans","Lucida Grande",arial,sans-serif /*modify by men*/
|
|
||||||
}
|
|
||||||
|
|
||||||
h1
|
|
||||||
{
|
|
||||||
font-size:24px; /*工作台界面框框大小*/
|
|
||||||
font-weight:400;
|
|
||||||
margin:0 0 0 .25em;
|
|
||||||
padding:0 0 10px;
|
|
||||||
text-align:left
|
|
||||||
}
|
|
||||||
|
|
||||||
h2,h3,h4,.wiki h1,.wiki h2,.wiki h3
|
|
||||||
{
|
|
||||||
border-bottom:0
|
|
||||||
}
|
|
||||||
|
|
||||||
h2,.wiki h1
|
|
||||||
{
|
|
||||||
background-color:#e0e0e0; /*第三层背景非导航条*/
|
|
||||||
margin:-6px -10px 10px;
|
|
||||||
padding:10px 20px;
|
|
||||||
font-size:14px;
|
|
||||||
color:#fff;
|
|
||||||
border-top:1px #ddd solid
|
|
||||||
}
|
|
||||||
|
|
||||||
.wiki h1
|
|
||||||
{
|
|
||||||
font-family:"PT Sans","Trebuchet MS",Helvetica,sans-serif;
|
|
||||||
font-weight:700
|
|
||||||
}
|
|
||||||
|
|
||||||
.wiki h2
|
|
||||||
{
|
|
||||||
background-color:transparent
|
|
||||||
}
|
|
||||||
|
|
||||||
div.issue div.wiki h3
|
|
||||||
{
|
|
||||||
text-decoration:underline
|
|
||||||
}
|
|
||||||
|
|
||||||
h3,h4
|
|
||||||
{
|
|
||||||
font-weight:400
|
|
||||||
}
|
|
||||||
|
|
||||||
div.wiki h3,div.wiki h4
|
|
||||||
{
|
|
||||||
font-weight:700
|
|
||||||
}
|
|
||||||
|
|
||||||
#sidebar h3
|
#sidebar h3
|
||||||
{
|
{
|
||||||
|
@ -2077,20 +2012,11 @@ div.avatar_user{
|
||||||
* *
|
* *
|
||||||
*Designed for message.
|
*Designed for message.
|
||||||
*/
|
*/
|
||||||
li {
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
.avatar-3{
|
.avatar-3{
|
||||||
width: 35px;
|
width: 35px;
|
||||||
height: 35px;
|
height: 35px;
|
||||||
}
|
}
|
||||||
.inner-right{
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
.messages-for-user-reply{
|
|
||||||
margin-top: 10px;
|
|
||||||
padding-left: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.message-for-user {
|
ul.message-for-user {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
|
Loading…
Reference in New Issue