Merge branch 'szzh' into develop

This commit is contained in:
sw 2014-08-21 15:45:14 +08:00
commit 6f30d4c739
70 changed files with 1481 additions and 333 deletions

View File

@ -81,3 +81,10 @@ kw:
默认支持如下格式:"bmp,jpeg,jpg,png,gif"
可在configuration.yml中修改格式pic_types: "bmp,jpeg,jpg,png,gif"(注意pic_types若前面有#号需去掉)
配置完成后重启服务
=================================[2014-08-16]====================================
kw:数据迁移project_scores表已存在
bundle exec rake db:migrate:down VERSION=20140811022947
bundle exec rake db:migrate:up VERSION=20140811022947
bundle exec rake db:migrate
bundle exec rake project_score:calculate

View File

@ -279,7 +279,7 @@ class ApplicationController < ActionController::Base
# Find project of id params[:id]
def find_project
@project = Project.find(params[:id])
@project = Project.find_by_id(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -79,7 +79,7 @@ class AttachmentsController < ApplicationController
else
candown = @attachment.is_public == 1
end
if candown || User.current.admin?
if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download
if stale?(:etag => @attachment.digest)

View File

@ -488,6 +488,11 @@ class BidsController < ApplicationController
if @bid.homework_type
@homework = HomeworkAttach.new
if @bid.proportion
teacher_proportion = @bid.proportion * 1.0 / 100
else
teacher_proportion = 1.0
end
#@homework_list = @bid.homeworks
#增加作业按评分排序,
#@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
@ -495,7 +500,7 @@ class BidsController < ApplicationController
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC")
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC")
if params[:student_id].present?
@temp = []
@homework_list.each do |pro|

View File

@ -38,6 +38,17 @@ class FilesController < ApplicationController
@isproject = true
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
all_attachments = []
@containers.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
render :layout => !request.xhr?
elsif params[:course_id]
@isproject = false
@ -67,6 +78,18 @@ class FilesController < ApplicationController
else
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)]
end
all_attachments = []
@containers.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
render :layout => 'base_courses'
end
end

View File

@ -103,7 +103,11 @@ class MessagesController < ApplicationController
# Edit a message
def edit
(render_403; return false) unless @message.editable_by?(User.current)
if @project
(render_403; return false) unless @message.editable_by?(User.current)
else
(render_403; return false) unless @message.course_editable_by?(User.current)
end
@message.safe_attributes = params[:message]
if request.post? && @message.save
attachments = Attachment.attach_files(@message, params[:attachments])
@ -124,7 +128,11 @@ class MessagesController < ApplicationController
# Delete a messages
def destroy
(render_403; return false) unless @message.destroyable_by?(User.current)
if @project
(render_403; return false) unless @message.destroyable_by?(User.current)
else
(render_403; return false) unless @message.course_destroyable_by?(User.current)
end
r = @message.to_param
@message.destroy
# modify by nwb

View File

@ -148,7 +148,8 @@ class NewsController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to news_path(@news)
else
render :action => 'edit'
#flash[:error] = l(:notice_successful_update)
redirect_to news_path(@news)
end
end

View File

@ -403,21 +403,35 @@ class ProjectsController < ApplicationController
#Ended by young
def feedback
page = params[:page]
@page = params[:page]
@page = @page.to_i
# Find the page of the requested reply
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@limit = 10
if params[:r] && page.nil?
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
page = 1 + offset / @limit
@limit = 3
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
page = 1 + offset / @limit
if params[:r] && @page.nil?
@page = page
end
puts @page
if @page < 0
@page = 1
end
if @page > page
@page = page
end
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, page
@feedback_pages = Paginator.new @feedback_count, @limit, @page
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@state = false
@base_courses_tag = @project.project_type
respond_to do |format|
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
format.api
@ -683,8 +697,8 @@ class ProjectsController < ApplicationController
else # @project.project_type == Project::ProjectType_project
roles = Role.find_all_givable
@subPage_title = l :label_member_list
@members = @project.member_principals.includes(:roles, :principal).all
@members = sort_project_members(@project, @members)
@members = @project.member_principals.includes(:roles, :principal).joins("LEFT JOIN #{OptionNumber.table_name} ON #{OptionNumber.table_name}.user_id = #{Member.table_name}.user_id and #{OptionNumber.table_name}.score_type = 2 AND #{Member.table_name}.project_id = #{OptionNumber.table_name}.project_id").order("#{OptionNumber.table_name}.total_score DESC").all
#@members = sort_project_members(@project, @members)
@applied_members = appied_project_members(@project, @members)
end
@members = paginateHelper @members

View File

@ -88,7 +88,44 @@ class WordsController < ApplicationController
#format.api { render_api_ok }
end
end
def destroyJournal
@journalP=JournalsForMessage.find(params[:object_id])
@journalP.destroy
@page = params[:page]
@page = @page.to_i
@project = Project.find params[:project_id]
# Find the page of the requested reply
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@limit = 3
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
page = 1 + offset / @limit
if params[:r] && @page.nil?
@page = page
end
if @page < 0
@page = 1
end
if @page > page
@page = page
end
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, @page
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@state = false
@base_courses_tag = @project.project_type
respond_to do |format|
format.js
end
end
def new
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
if @jour

View File

@ -1442,6 +1442,8 @@ module ApplicationHelper
email = $1
end
return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil
#options ={"class" => ["avatar2"],"width" =>["80px"],"height" =>["80px"]}
#return image_tag url_to_avatar(user), options
else
''
end

View File

@ -441,7 +441,7 @@ module CoursesHelper
def homework_user_of_homework homework,is_teacher
homework_users = ""
homework.users.each do |user|
homework_users = homework_users + (is_teacher ? user.realname : user.name)
homework_users = homework_users + (is_teacher ? (user.firstname + user.lastname) : user.login)
if user != homework.users.last
homework_users = homework_users + ""
end

View File

@ -16,7 +16,7 @@ module ProjectScoreHelper
end
#文档数量
def document_num project
def documents_num project
project.documents.count
end
@ -48,8 +48,8 @@ module ProjectScoreHelper
end
#文档得分
def document_score project
d_num = document_num project
def documents_score project
d_num = documents_num(project)
d_num * 4
end
@ -67,7 +67,7 @@ module ProjectScoreHelper
#计算项目得分
def project_scores project
result = (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project)
result = (issue_score project) + (news_score project) + (documents_score project) + (changesets_score project) + (board_message_score project)
pss = ProjectScore.where("project_id = '#{project.id}'")
if pss.nil? || pss.count == 0
ps = ProjectScore.new

View File

@ -381,9 +381,52 @@ module UserScoreHelper
result
end
def get_option_num_by_id(user_id,type,project_id=nil)
if project_id.nil?
option_number = OptionNumber.where("user_id = '#{user_id}' and score_type = '#{type}'");
else
option_number = OptionNumber.where("user_id = '#{user_id}' and score_type = '#{type}' and project_id = '#{project_id}'");
end
result = nil
if option_number.nil? || option_number.count == 0
result = OptionNumber.new
result.user_id = user_id
result.memo = 0
result.messages_for_issues = 0
result.issues_status = 0
result.replay_for_message = 0
result.replay_for_memo = 0
result.follow = 0
result.tread = 0
result.praise_by_one = 0
result.praise_by_two = 0
result.praise_by_three = 0
result.tread_by_one = 0
result.tread_by_two = 0
result.tread_by_three = 0
result.changeset = 0
result.document = 0
result.attachment = 0
result.issue_done_ratio = 0
result.post_issue = 0
result.total_score = 0
result.score_type =type
unless project_id.nil?
result.project_id = project_id
end
else
result = option_number.first
end
result
end
#更新分数
def update_score(option_number)
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number)
if option_number.total_score < 0
option_number.total_score = 0
end
option_number.save
option_number.total_score
end
@ -415,11 +458,24 @@ module UserScoreHelper
#发帖数
def memo_num(user,project=nil)
if project.nil?
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id
WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}")
result = 0
users.each do |user|
result = user.m_count
end
result
#user.messages.where("parent_id IS NULL").count
else
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id
WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}")
result = 0
users.each do |user|
result = user.m_count
end
result
end
end
@ -438,16 +494,28 @@ FROM `users` where id = #{user.id}")
#更新对缺陷留言数
def update_messges_for_issue(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.messages_for_issues = messges_for_issue_num(user,project)#Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
update_score(option_number)
end
def messges_for_issue_num(user,project=nil)
if project.nil?
Journal.includes(:user).where("user_id = '#{user.id}' and notes is not null and notes != ''").all.count
#Journal.includes(:user).where("user_id = '#{user.id}' and notes is not null and notes != ''").all.count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals WHERE journals.user_id = #{user.id} AND journals.notes IS NOT NULL AND journals.notes != ''")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
#Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals join issues on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.user_id = #{user.id} AND journals.notes IS NOT NULL AND journals.notes != ''and #{Issue.table_name}.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -461,16 +529,28 @@ FROM `users` where id = #{user.id}")
#更新更改缺陷状态状态次数
def update_issues_status(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.issues_status = issues_status_num(user,project)#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
update_score(option_number)
end
def issues_status_num(user,project=nil)
if project.nil?
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = #{user.id} and issues.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -478,25 +558,37 @@ FROM `users` where id = #{user.id}")
def issues_status_score(user,project=nil)
if project.nil?
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id) AS m_score FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id) AS m_count FROM users WHERE users.id = '#{user.id}'")
else
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id and issues.project_id = '#{project.id}') AS m_score FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id and issues.project_id = '#{project.id}') AS m_count FROM users WHERE users.id = '#{user.id}'")
end
end
#更新对留言的回复数量
def update_replay_for_message(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.replay_for_message = replay_for_message_num(user,project)#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
update_score(option_number)
end
def replay_for_message_num(user,project=nil)
if project.nil?
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'").count
#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'").count
users = JournalsForMessage.find_by_sql("SELECT COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'").count
#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'").count
users = JournalsForMessage.find_by_sql("SELECT COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -505,22 +597,34 @@ FROM `users` where id = #{user.id}")
if project.nil?
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project') as m_score FROM users WHERE users.id = '#{user.id}'")
else
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project' and jour_id = '#{project.id}') as m_score FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project' and jour_id = '#{project.id}') as m_score FROM users WHERE users.id = '#{user.id}'")
end
end
#更新对帖子的回复数量
def update_replay_for_memo(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.replay_for_memo = replay_for_memo_num(user,project)#Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
update_score(option_number)
end
def replay_for_memo_num(user,project=nil)
if project.nil?
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = #{user.id} AND boards.project_id != -1")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = #{user.id} AND boards.project_id = #{project.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -535,21 +639,27 @@ FROM `users` where id = #{user.id}")
#更新被关注的人数
def update_follow(user,type)
option_number = get_option_number(user,type)
option_number.follow = Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
option_number.follow = follow_num(user)#Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
update_score(option_number)
end
def follow_num(user)
Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
#Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
users = Watcher.find_by_sql("SELECT COUNT(*) as m_count FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
def follow_score(user)
User.find_by_sql("SELECT users.id, (SELECT COUNT(*) * 2 FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = '#{user.id}') FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id, (SELECT COUNT(*) * 2 FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = users.id) FROM users WHERE users.id = '#{user.id}'")
end
#更新帖子踩各项数量
def update_tread(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
tread_nums = tread_num(user,project)
option_number.tread = tread_nums[:tread]
option_number.tread_by_one = tread_nums[:tead_by_one]
@ -614,7 +724,7 @@ FROM `users` where id = #{user.id}")
#更新帖子顶数量
def update_praise(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
praise_nums = praise_num(user,project)
option_number.praise_by_one = praise_nums[:praise_by_one]
option_number.praise_by_two = praise_nums[:praise_by_two]
@ -679,82 +789,148 @@ FROM `users` where id = #{user.id}")
#更新提交代码次数
def update_changeset(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.changeset = changeset_num(user,project)#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
update_score(option_number)
end
def changeset_num(user,project=nil)
if project.nil?
Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
users = Changeset.find_by_sql("SELECT COUNT(*) as m_count FROM #{Changeset.table_name} WHERE user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
#Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
users = Changeset.find_by_sql("SELECT COUNT(*) as m_count FROM #{Changeset.table_name} JOIN #{Repository.table_name} ON #{Changeset.table_name}.repository_id = #{Repository.table_name}.id WHERE #{Changeset.table_name}.user_id = #{user.id} and #{Repository.table_name}.project_id = #{project.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
#更新文档提交次数
def update_document(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.document = document_num(user,project)#Document.includes(:user).where("user_id = '#{user.id}'").all.count
update_score(option_number)
end
def document_num(user,project=nil)
if project.nil?
Document.includes(:user).where("user_id = '#{user.id}'").all.count
#Document.includes(:user).where("user_id = '#{user.id}'").all.count
users = Document.find_by_sql("SELECT COUNT(*) as m_count FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
#Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
users = Document.find_by_sql("SELECT COUNT(*) as m_count FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{user.id} and #{Document.table_name}.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
#更新附件提交数量
def update_attachment(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.attachment = attachment_num(user,project)#Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number)
end
def attachment_num(user,project=nil)
if project.nil?
Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project'").all.count
#Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project'").all.count
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
#Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}")
result = 0
if users.count > 0
result = users.first.m_coumt
end
result
end
end
#更新缺陷完成度次数
def update_issue_done_ratio(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.issue_done_ratio = issue_done_ratio_num(user,project) #Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
update_score(option_number)
end
def issue_done_ratio_num(user,project=nil)
if project.nil?
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{Journal.table_name}.user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{Journal.table_name}.user_id = #{user.id} and #{Issue.table_name}.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
#更新发布缺陷次数
def update_post_issue(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.post_issue = post_issue_num(user,project) #Issue.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number)
end
def post_issue_num(user,project=nil)
if project.nil?
Issue.includes(:author).where("author_id = '#{user.id}'").all.count
#Issue.includes(:author).where("author_id = '#{user.id}'").all.count
users = Issue.find_by_sql("SELECT COUNT(*) as m_count FROM #{Issue.table_name} WHERE author_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count
#Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count
users = Issue.find_by_sql("SELECT COUNT(*) as m_count FROM #{Issue.table_name} WHERE author_id = #{user.id} and project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
#读取项目成员得分
def read_user_project_scores(user,project)
option_num = get_option_number(user,2,project)
option_num.total_score
end
def user_scores(user,type,project=nil)
ooption_num = get_option_number(user,type,project)
update_memo_number(user,type,project)
@ -769,6 +945,9 @@ FROM `users` where id = #{user.id}")
update_attachment(user,type,project)
update_issue_done_ratio(user,type,project)
update_post_issue(user,type,project)
if project.nil?
update_follow(user,type)
end
update_score(ooption_num)
ooption_num
end

View File

@ -29,9 +29,9 @@ class Attachment < ActiveRecord::Base
include UserScoreHelper
validates_presence_of :filename, :author
validates_length_of :filename, :maximum => 255
validates_length_of :disk_filename, :maximum => 255
validates_length_of :description, :maximum => 255
validates_length_of :filename, :maximum => 254
validates_length_of :disk_filename, :maximum => 254
validates_length_of :description, :maximum => 254
validate :validate_max_file_size
@ -512,11 +512,18 @@ class Attachment < ActiveRecord::Base
end
end
update_attachment(self.author,1)
if self.container_type == 'Project'
update_attachment(self.author,2,self.container)
end
end
#删除附件时重新统计用户的附件数量得分
def down_user_score
update_attachment(self.author,1)
if self.container_type == 'Project'
update_attachment(self.author,2,self.container)
end
end
end

View File

@ -308,12 +308,14 @@ class Changeset < ActiveRecord::Base
#更新用户等级
UserLevels.update_user_level(self.user)
update_changeset(self.user,1)
update_changeset(self.user,2,self.repository.project)
end
#积分刷新
def down_user_score
UserLevels.update_user_level(self.user)
update_changeset(self.user,1)
update_changeset(self.user,2,self.repository.project)
end
end

View File

@ -69,9 +69,11 @@ class Document < ActiveRecord::Base
def be_user_score
UserScore.project(:push_document, self.user,self,{ document_id: self.id })
update_document(self.user,1)
update_document(self.user,2,self.project)
end
def down_user_score
update_document(self.user,1)
update_document(self.user,2,self.project)
end
end

View File

@ -138,10 +138,10 @@ class Issue < ActiveRecord::Base
nil
when 'default'
user_ids = [user.id] + user.groups.map(&:id)
"(#{table_name}.is_private = #{connection.quoted_false}) OR (#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
"(#{table_name}.is_private = #{connection.quoted_false}) OR (#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
when 'own'
user_ids = [user.id] + user.groups.map(&:id)
"(#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
else
'1=0'
end
@ -159,9 +159,9 @@ class Issue < ActiveRecord::Base
when 'all'
true
when 'default'
(!self.is_private? ||self.tracker == user) || (self.author == user || user.is_or_belongs_to?(assigned_to))
!self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
when 'own'
self.tracker == user || self.author == user || user.is_or_belongs_to?(assigned_to)
self.author == user || user.is_or_belongs_to?(assigned_to)
else
false
end
@ -1524,6 +1524,7 @@ class Issue < ActiveRecord::Base
def be_user_score_new_issue
UserScore.project(:post_issue, self.author,self, { issue_id: self.id })
update_post_issue(self.author,1)
update_post_issue(self.author,2,self.project)
end
def down_user_score
@ -1539,8 +1540,13 @@ class Issue < ActiveRecord::Base
# update_issues_status(self.author , 1)
#end
update_post_issue(self.author,1)
update_issue_done_ratio(User.current,1)
update_issues_status(self.author , 1)
#update_issue_done_ratio(self.author,1)
#update_issues_status(self.author , 1)
update_post_issue(self.author,2,self.project)
#update_issue_done_ratio(self.author,2,self.project)
#update_issues_status(self.author , 2)
end

View File

@ -163,6 +163,7 @@ class Journal < ActiveRecord::Base
#协同得分加分
UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(self.user,1)
update_messges_for_issue(self.user,2,self.issue.project)
end
end
@ -173,6 +174,7 @@ class Journal < ActiveRecord::Base
#协同得分减分
UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(self.user,1)
update_messges_for_issue(self.user,2,self.issue.project)
end
end

View File

@ -46,9 +46,15 @@ class JournalDetail < ActiveRecord::Base
#更新缺陷完成度
if self.prop_key == 'done_ratio'
update_issue_done_ratio(self.journal.user,1)
unless self.journal.project.nil?
update_issue_done_ratio(self.journal.user,2,self.journal.project)
end
#更新缺陷状态
elsif self.prop_key == 'status_id'
update_issues_status(self.journal.user , 1)
unless self.journal.project.nil?
update_issues_status(self.journal.user,2,self.journal.project)
end
end
end
@ -57,9 +63,16 @@ class JournalDetail < ActiveRecord::Base
if self.prop_key == 'done_ratio'
update_issue_done_ratio(self.journal.user,1)
unless self.journal.project.nil?
update_issue_done_ratio(self.journal.user,2,self.journal.project)
end
#更新缺陷状态
elsif self.prop_key == 'status_id'
update_issues_status(self.journal.user, 1)
unless self.journal.project.nil?
update_issues_status(self.journal.user,2,self.journal.project)
end
end
end

View File

@ -144,6 +144,9 @@ class JournalsForMessage < ActiveRecord::Base
#协同得分加分
UserScore.joint(:reply_message, self.user,User.find(self.reply_id),self, { journals_for_messages_id: self.id })
update_replay_for_message(self.user,1)
if self.jour_type == "Project"
update_replay_for_message(self.user,2,self.jour)
end
end
end
# 更新用户分数 -by zjc
@ -153,6 +156,9 @@ class JournalsForMessage < ActiveRecord::Base
#协同得分减分
UserScore.joint(:reply_message_delete, self.user,User.find(self.reply_id), { journals_for_messages_id: self.id })
update_replay_for_message(self.user,1)
if self.jour_type == "Project"
update_replay_for_message(self.user,2,self.jour)
end
end
end
end

View File

@ -146,11 +146,12 @@ class Memo < ActiveRecord::Base
end
#更新用户分数 -by zjc
def be_user_score
def be_user_score
#新建memo且无parent的为发帖
if self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil,self ,{ memo_id: self.id })
update_memo_number(User.current,1)
#新建memo且有parent的为回帖
elsif !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { memo_id: self.id })

View File

@ -127,6 +127,14 @@ class Message < ActiveRecord::Base
board.course
end
def course_editable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course)))
end
def course_destroyable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:delete_messages, course) || (self.author == usr && usr.allowed_to?(:delete_own_messages, course)))
end
def editable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:edit_messages, project) || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)))
end
@ -152,11 +160,17 @@ class Message < ActiveRecord::Base
#新建message且无parent的为发帖
if self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id })
update_memo_number(User.current,1)
update_memo_number(self.author,1)
if self.board.project_id != -1
update_memo_number(self.author,2,self.board.project)
end
#新建message且有parent的为回帖
elsif !self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:reply_posting, self.author,self.parent.author,self, { message_id: self.id })
update_replay_for_memo(User.current,1)
update_replay_for_memo(self.author,1)
if self.board.project_id != -1
update_replay_for_memo(self.author,2,self.board.project)
end
end
end
@ -165,9 +179,15 @@ class Message < ActiveRecord::Base
if self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id })
update_memo_number(User.current,1)
if self.board.project_id != -1
update_memo_number(self.author,2,self.board.project)
end
elsif !self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id })
update_replay_for_memo(User.current,1)
if self.board.project_id != -1
update_replay_for_memo(self.author,2,self.board.project)
end
end
end
end

View File

@ -43,14 +43,21 @@ class PraiseTread < ActiveRecord::Base
obj = PraiseTread.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,self, { praise_tread_id: self.id })
update_tread(User.current,1)
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.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,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end
@ -62,14 +69,21 @@ class PraiseTread < ActiveRecord::Base
obj = PraiseTread.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,self, { praise_tread_id: self.id })
update_tread(User.current,1)
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.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,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end

View File

@ -28,13 +28,15 @@
<tr>
<td style="vertical-align: top;width: 70px" >
<table style="text-align: center;width: 100%;table-layout: fixed">
<% user_name = is_teacher ? (homework.user.firstname + homework.user.lastname) : homework.user.login %>
<tr>
<td title="<%= homework.user.name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
<td title="<%= user_name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
</tr>
<tr>
<td title="<%= homework.user.name %>">
<td title="<%= user_name %>">
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong>
<%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user),{:style => "color:#727272"} %>
<%= link_to user_name, user_path(homework.user),{:style => "color:#727272"} %>
</strong></p>
</td>
</tr>

View File

@ -1,9 +1,9 @@
<!--<p><%= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<!--<p><%#= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%#= link_to h(news.title), news_path(news) %>
<%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<% unless news.summary.blank? %></td><td><span class="fontligher"><%=h news.summary %></span><% end %></td>
<td><span class="author"><%= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<%# unless news.summary.blank? %></td><td><span class="fontligher"><%#=h news.summary %></span><% end %></td>
<td><span class="author"><%#= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<table width="660px" border="0" align="center">
<tr>

View File

@ -0,0 +1,32 @@
<% id = "course_resources_ul_" + obj.id.to_s%>
<ul class="messages-for-user-reply" id = '<%= id %>' >
<%= form_for "tag_for_save",:remote=>true,:header=>"Accept: application/javascript",:url=>tag_path,
:update => "tags_show",
:complete => "$(\"#put-tag-form-#{obj.class}-#{obj.id}\").hide();" do |f| %>
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length,:style=>"width: 100px;"%>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit l(:button_project_tags_add),:class => "small" %>
<div class='hidden'>
<% preTags = @preTags.nil? ? [] : @preTags %>
<% preTags.each do |tag|%>
<%= link_to tag, "
javascript:(function(){
var $tagInputVal = $('#put-tag-form-"+obj.class.to_s+"-"+obj.id.to_s+"').find('#name');
var tagArr = [];
tagArr = tagArr.concat( $tagInputVal[0].value.split(',') );
tagArr = tagArr.concat('"+tag.to_s+"');
tagArr = cleanArray(tagArr);
$tagInputVal.val(tagArr.join(','));
})();
"
%>
<% end%>
</div>
<%#= link_to_function l(:button_cancel), "$(\"#put-tag-form-#{obj.class}-#{obj.id}\").hide();"%>
<% end %>
<%# journal.children.each do |reply|%>
<%#= render :partial => "journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply} %>
<%# end %>
</ul>

View File

@ -1,8 +1,8 @@
<% if @events_by_day != nil && @events_by_day.size >0 %>
<div class="content-title-top-avtive">
<!-- <h3><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3> -->
<!-- <h3><%#= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3> -->
<p class="subtitle">
<%= l(:label_date_from_to, :start => format_date(@date_from), :end => format_date(@date_to - 1)) %>
<%#= l(:label_date_from_to, :start => format_date(@date_from), :end => format_date(@date_to - 1)) %>
</p>
<% @events_by_day.keys.sort.reverse.each do |day| %>
@ -29,7 +29,7 @@
<%= l(:label_new_activity) %> </span>
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:style => "word-break:break-all;" %>
</td>
</tr>
<tr>

View File

@ -25,60 +25,70 @@
</tr>
</thead>
<tbody>
<% @containers.each do |container| %>
<% next if container.attachments.empty? -%>
<% if container.is_a?(Version) -%>
<tr>
<%# @containers.each do |container| %>
<%# next if container.attachments.empty? -%>
<%# if container.is_a?(Version) -%>
<!--<tr>
<th colspan="5" align="left" style="line-height: 30px; font-size: 14px; ">
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
<%#= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
</th>
</tr>
<% end -%>
<% container.attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
<%next%>
<%end%>
<tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName unless file.attachmentstype.nil? %></span>
</tr>-->
<%# end -%>
<% if @curse_attachments != nil %>
<% @curse_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
<%next%>
<%end%>
<tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName unless file.attachmentstype.nil? %></span>
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %>
</span>
</td>
<td class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp;
</td>
<td class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp;
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
:attachment => file} %>
</span>
</td>
<td class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center">
<%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td>
</tr>
<tr>
<td class='description' colspan="6">
<div class="tags_area">
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<div class="tags_gradint"></div>
</div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>
</td>
</tr>
<% end -%>
<% reset_cycle %>
</td>
<td class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center">
<%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td>
</tr>
<tr>
<td class='description' colspan="6">
<div class="tags_area">
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<div class="tags_gradint"></div>
</div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>
</td>
</tr>
<% end -%>
<% end %>
<%# reset_cycle %>
<%# end -%>
<!-- %= h downloadAll(@containers) % -->
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
</tbody>
</table>
<!--分页-->
<div class="pagination" style="float:left;">
<ul>
<%= pagination_links_full @feedback_pages %>
</ul>
</div>

View File

@ -25,16 +25,17 @@
</tr>
</thead>
<tbody>
<% @containers.each do |container| %>
<% next if container.attachments.empty? -%>
<% if container.is_a?(Version) -%>
<tr>
<%# @containers.each do |container| %>
<%# next if container.attachments.empty? -%>
<%# if container.is_a?(Version) -%>
<!--tr>
<th colspan="5" align="left" style="line-height: 30px; font-size: 14px; ">
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
<%#= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
</th>
</tr>
<% end -%>
<% container.attachments.each do |file| %>
</tr-->
<%# end -%>
<% if @curse_attachments != nil %>
<% @curse_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of?(@project)%>
<%next%>
<%end%>
@ -75,10 +76,17 @@
</td>
</tr>
<% end -%>
<% reset_cycle %>
<%# reset_cycle %>
<% end -%>
<!-- %= h downloadAll(@containers) % -->
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
</tbody>
</table>
<!--分页-->
<div class="pagination" style="float:left;">
<ul>
<%= pagination_links_full @feedback_pages %>
</ul>
</div>

View File

@ -37,26 +37,26 @@
<!--
<fieldset class="collapsible collapsed">
<legend onclick="toggleFieldset(this);">
<%#= l(:label_options) %>
<%= l(:label_options) %>
</legend>
<div style="display: none;">
<table>
<tr>
<td><%#= l(:field_column_names) %></td>
<td><%#= render_query_columns_selection(@query) %></td>
<td><%= l(:field_column_names) %></td>
<td><%= render_query_columns_selection(@query) %></td>
</tr>
<tr>
<td><label for='group_by'><%#= l(:field_group_by) %></label></td>
<td><%#= select_tag('group_by', options_for_select([[]] + @query.groupable_columns.collect { |c| [c.caption, c.name.to_s] }, @query.group_by)) %></td>
<td><label for='group_by'><%= l(:field_group_by) %></label></td>
<td><%= select_tag('group_by', options_for_select([[]] + @query.groupable_columns.collect { |c| [c.caption, c.name.to_s] }, @query.group_by)) %></td>
</tr>
<tr>
<td><%#= l(:button_show) %></td>
<td><%#= available_block_columns_tags(@query) %></td>
<td><%= l(:button_show) %></td>
<td><%= available_block_columns_tags(@query) %></td>
</tr>
</table>
</div>
</fieldset>
-->
-->
<div class="buttons hide-when-print">
<%= link_to_function l(:label_issue_query), 'submit_query_form("query_form")', :class => 'icon icon-checked' %>
<%= link_to l(:label_issue_cancel_query), {:set_filter => 1, :project_id => @project}, :class => 'icon icon-reload' %>

View File

@ -1,13 +1,13 @@
<!-- <table id="top-menu" style="background-color: #ac344f;margin-top: 10px;margin-bottom: 0px; padding-top: 3px; ">
<tr><td ><%=link_to image_tag("/images/logo_ent.png",weight:"38px", height: "38px"), home_path %></td>
<td valign="top" width="300px"><%= render_menu :top_enterprise_menu if User.current.logged? || !Setting.login_required? -%></td>
<td><%=link_to "企业入口"%></td>
<tr><td ><%#=link_to image_tag("/images/logo_ent.png",weight:"38px", height: "38px"), home_path %></td>
<td valign="top" width="300px"><%#= render_menu :top_enterprise_menu if User.current.logged? || !Setting.login_required? -%></td>
<td><%#=link_to "企业入口"%></td>
<td valign="top" style=" padding-left: 380px">
<%= content_tag('div', "#{link_to(l(:label_layouts_feedback)+'(' + User.current.count_new_jour.to_s + ')', feedback_path(User.current))}".html_safe, :id => 'loggedas') if User.current.logged? %>
<%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
<%#= content_tag('div', "#{link_to(l(:label_layouts_feedback)+'(' + User.current.count_new_jour.to_s + ')', feedback_path(User.current))}".html_safe, :id => 'loggedas') if User.current.logged? %>
<%#= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
</td>
<td valign="top">
<%= render_menu :account_menu -%>
<%#= render_menu :account_menu -%>
</td>
</tr>
</table> -->
@ -31,14 +31,14 @@
<!-- <div style="float: right; margin-top: 13px;">
<%= content_tag('div', "#{link_to(image_tag('/images/mes.png'), feedback_path(User.current))}".html_safe, :title => "留言") if User.current.logged? %>
<%#= content_tag('div', "#{link_to(image_tag('/images/mes.png'), feedback_path(User.current))}".html_safe, :title => "留言") if User.current.logged? %>
</div> -->
<!-- <div align="center" style="float: right; margin-right: -25px; margin-top: 6px; background: #ea7125; width: 12px;border-radius:7px; font-size: 8px; color: #fff; font-weight: bold">
<%= User.current.count_new_jour if User.current.logged? && User.current.count_new_jour != 0 %>
<%#= User.current.count_new_jour if User.current.logged? && User.current.count_new_jour != 0 %>
</div> -->
<!-- <%= content_tag('div', "#{}".html_safe, :id => 'loggedas')%> -->
<!-- <%#= content_tag('div', "#{}".html_safe, :id => 'loggedas')%> -->
<!-- 消息#{link_to((User.current.count_new_jour), feedback_path(User.current))} -->
<!-- <%= content_tag('div', "消息(#{User.current.journals_for_messages.count}".html_safe, :id => 'loggedas')%> -->
<!-- <%#= content_tag('div', "消息(#{User.current.journals_for_messages.count}".html_safe, :id => 'loggedas')%> -->
<!-- <div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 5px;margin-top: -10px;"></div> -->

View File

@ -10,7 +10,7 @@
<span><%=l(:label_organizers)%></span>
<span class="footer_text_link"><%= link_to l(:label_organizers_information),"http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%></span>
<span class="footer_text_link"><%= link_to l(:label_organizers_information_institute), "http://www.nudt.edu.cn/ArticleShow.asp?ID=41", :target => "_blank" %></span>
<span id="copyright"><%=l(:label_copyright)%>@2007~2014</span>
<span id="copyright"><%=l(:label_copyright)%>©2007~2014</span>
<span id="contact_us" class="footer_text_link"><%= link_to l(:label_contact_us),"http://" + Setting.host_name + "/projects/2/member", :target=>"_blank" %></span>
<span id="record"class="footer_text_link"><%= link_to l(:label_record),"http://www.miibeian.gov.cn/", :target => "_blank" %></span>

View File

@ -44,6 +44,13 @@
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=true%>
<% _bool=false %>
<% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %>
<% _bool=true %>
<% end %>
<% end %>
<% if _bool %>
<li id="course_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %>
<ul class="course_sub_menu">
<% User.current.courses.each do |course| %>
@ -53,11 +60,14 @@
<% end %>
</ul>
</li>
<% end %>
<% end -%>
<% end %>
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<% if User.current.projects.count>0 %>
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<% if hasCourse %>
<ul class="project_sub_menu" style="top: 35px">
<% else %>
@ -65,9 +75,10 @@
<% end %>
<% User.current.projects.each do |project| %>
<li><%= link_to project.name.truncate(10, omission: '...'), {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %></li>
<% end %>
<% end %>
</ul>
</li>
<% end %>
<li style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
</li>
</ul>

View File

@ -9,14 +9,14 @@
<%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %>
<!-- <div style="float: right; margin-top: 13px;">
<%= content_tag('div', "#{link_to(image_tag('/images/mes.png'), feedback_path(User.current))}".html_safe, :title => "留言") if User.current.logged? %>
<%#= content_tag('div', "#{link_to(image_tag('/images/mes.png'), feedback_path(User.current))}".html_safe, :title => "留言") if User.current.logged? %>
</div> -->
<!-- <div align="center" style="float: right; margin-right: -25px; margin-top: 6px; background: #ea7125; width: 12px;border-radius:7px; font-size: 8px; color: #fff; font-weight: bold">
<%= User.current.count_new_jour if User.current.logged? && User.current.count_new_jour != 0 %>
<%#= User.current.count_new_jour if User.current.logged? && User.current.count_new_jour != 0 %>
</div> -->
<!-- <%= content_tag('div', "#{}".html_safe, :id => 'loggedas')%> -->
<!-- <%#= content_tag('div', "#{}".html_safe, :id => 'loggedas')%> -->
<!-- 消息#{link_to((User.current.count_new_jour), feedback_path(User.current))} -->
<!-- <%= content_tag('div', "消息(#{User.current.journals_for_messages.count}".html_safe, :id => 'loggedas')%> -->
<!-- <%#= content_tag('div', "消息(#{User.current.journals_for_messages.count}".html_safe, :id => 'loggedas')%> -->
<%= render_menu :top_home_menu if User.current.logged? || !Setting.login_required? -%>
</div>
<div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 5px;margin-top: -10px;"></div>

View File

@ -82,7 +82,7 @@
<%= join_in_course(@course, User.current) %>
<% end %>
<% unless User.current.member_of_course?(@course) %>
<!-- <%= image_tag "/images/fav.png" %> -->
<!-- <%#= image_tag "/images/fav.png" %> -->
<% end %>
<% end %>
</div>

View File

@ -50,11 +50,11 @@
</div>
<div id="sidebar">
<div class="spaceleft">
<div class="inf_user_image">
<% #@project = Project.find_by_id(@project.id)%>
<% @project = Project.find_by_id(@project.id)%>
<table>
<tr>
<td><%= image_tag(url_to_avatar(@project), :class => 'avatar2') %></td>

View File

@ -148,7 +148,7 @@
"编辑",
{:action => 'edit', :id => message},
:title => l(:button_edit)
) if message.editable_by?(User.current) %>
) if message.course_editable_by?(User.current) %>
<%= link_to(
#image_tag('delete.png'),
"删除",
@ -156,7 +156,7 @@
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if message.destroyable_by?(User.current) %>
) if message.course_destroyable_by?(User.current) %>
</div></td>
</tr>
<tr>

View File

@ -30,13 +30,14 @@
border-bottom: 1px dashed rgb(204, 204, 204);
}
.memo-content {
width: 82%;
padding: 1%;
margin: 1%;
margin-bottom: 40px;
background-color: #F6F6F6;
white-space: normal;
/*word-break: break-all; */
word-wrap: break-word;
word-break: break-all;
/*word-wrap: break-word;*/
}
.memo-timestamp {
position: absolute;
@ -155,10 +156,10 @@
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if message.destroyable_by?(User.current) %>
</div></td>
</div>
</td>
</tr>
<tr>
<td class="comments">
<div class="wiki" style="width: 100%;word-break: break-all;">
<%= textAreailizable message,:content,:attachments => message.attachments %>

View File

@ -1,12 +1,13 @@
<%= error_messages_for @news %>
<div class="add_frame_header" >
<% str = l(:bale_news_notice)%>
<%= str %>
<%= is_new ? l(:bale_news_notice):l(:bale_edit_notice)%>
</div>
<div class="box tabular">
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
<!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:468px;", :onblur => "regexTitle();" %></p>
<P><span id="title_notice_span">(60个字符以内)</span></P>
<!-- <p style="margin-left:-10px;"><%#= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:470px;", :onblur => "regexDescription();" %></p>
<P><span id="description_notice_span"></span></P>
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
</div>

View File

@ -3,6 +3,59 @@
label_tips = l(:label_course_news)
%>
<script type="text/javascript">
function regexTitle()
{
var name = $("#news_title").val();
if(name.length ==0)
{
$("#title_notice_span").text("标题不能为空");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
else if(name.length <= 60)
{
$("#title_notice_span").text("填写正确");
$("#title_notice_span").css('color','#008000');
return true;
}
else
{
$("#title_notice_span").text("标题超过60个字符");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
}
function regexDescription()
{
var name = $("#news_description").val();
if(name.length ==0)
{
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else
{
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color','#008000');
return true;
}
}
function submitNews()
{
if(regexTitle() && regexDescription())
{
$("#news-form").submit();
}
}
</script>
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
<%= label_tips %>
</span>
@ -15,8 +68,9 @@
<div id="add-news" class="add_frame" style="display:none;">
<%= labelled_form_for @news, :url => course_news_index_path(@course),
:html => {:id => 'news-form', :multipart => true} do |f| %>
<%= render :partial => 'news/course_form', :locals => {:f => f} %>
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit --> |
<%= render :partial => 'news/course_form', :locals => {:f => f, :is_new => true} %>
<%#= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit -->
<%= link_to l(:button_create), "#", :onclick => 'submitNews();', :class => 'whiteButton m3p10' %>|
<%= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %>

View File

@ -1,3 +1,56 @@
<script type="text/javascript">
function regexTitle()
{
var name = $("#news_title").val();
if(name.length ==0)
{
$("#title_notice_span").text("标题不能为空");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
else if(name.length <= 60)
{
$("#title_notice_span").text("填写正确");
$("#title_notice_span").css('color','#008000');
return true;
}
else
{
$("#title_notice_span").text("标题超过60个字符");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
}
function regexDescription()
{
var name = $("#news_description").val();
if(name.length ==0)
{
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else
{
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color','#008000');
return true;
}
}
function submitNews()
{
if(regexTitle() && regexDescription())
{
$("#news-form").submit();
}
}
</script>
<div class="contextual">
<%= watcher_link(@news, User.current) %>
<%= link_to(l(:button_edit),
@ -14,8 +67,9 @@
<div id="edit-news" style="display:none;">
<%= labelled_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'course_form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= render :partial => 'course_form', :locals => { :f => f, :is_new => false } %>
<%#= submit_tag l(:button_save) %>
<%= link_to l(:button_save), "#", :onclick => 'submitNews();' %>
<%= preview_link preview_news_path(:course_id => @course, :id => @news), 'news-form',target='preview',{:class => ''} %> |
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %>
<% end %>

View File

@ -1,11 +1,10 @@
<%= error_messages_for @news %>
<div class="add_frame_header" >
<% str = @project ? l(:bale_news_notice) : l(:label_news_new) %>
<%= str %>
<%= @project ? l(:label_news_new) : l(:bale_news_notice) %>
</div>
<div class="box tabular">
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
<!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<!-- <p style="margin-left:-10px;"><%#= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
</div>

View File

@ -1,9 +1,9 @@
<!--<p><%= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<!--<p><%#= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%#= link_to h(news.title), news_path(news) %>
<%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<% unless news.summary.blank? %></td><td><span class="fontligher"><%=h news.summary %></span><% end %></td>
<td><span class="author"><%= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<%# unless news.summary.blank? %></td><td><span class="fontligher"><%#=h news.summary %></span><%# end %></td>
<td><span class="author"><%#= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<table width="660px" border="0" align="center">
<tr>

View File

@ -1,4 +1,4 @@
<!-- <h3><%=l(:label_news_new)%></h3> -->
<!-- <h3><%#=l(:label_news_new)%></h3> -->
<% if @project %>
<%= labelled_form_for @news, :url => project_news_index_path(@project),
:html => {:id => 'news-form', :multipart => true} do |f| %>

View File

@ -24,7 +24,7 @@
<%= content_tag "div", content_tag("p", rolesToLanguage(member.roles.sort.collect(&:to_s)).join(', ')), :class => "clear avatar_name" %>
<div class="clear avatar_user">
<p> <!--user_scores(member.user,2,@project).total_score).to_i UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade).to_i-->
<%= l(:label_user_for_project_grade) %>: <span style="color:#ec6300"><%= format("%.2f" ,user_scores(member.user,2,@project).total_score).to_i %></span>
<%= l(:label_user_for_project_grade) %>: <span style="color:#ec6300"><%= format("%.2f" ,read_user_project_scores(member.user,@project)).to_i %></span>
</p>
</div>
<% end %>

View File

@ -4,7 +4,7 @@
<div> = <%= l(:label_issue_score) %> + <%= l(:label_news_score) %> + <%= l(:label_file_score) %> +
<%= l(:label_code_submit_score) %> + <%= l(:label_topic_score) %></div>
<div> = <%= format("%.2f" , issue_score(@project)).to_i %> + <%= format("%.2f" , news_score(@project)).to_i %> +
<%= format("%.2f" , document_score(@project)).to_i %> + <%= format("%.2f" , changesets_score(@project)).to_i %> +
<%= format("%.2f" , documents_score(@project)).to_i %> + <%= format("%.2f" , changesets_score(@project)).to_i %> +
<%= format("%.2f" , board_message_score(@project)).to_i %></div>
<div> = <%= format("%.2f" , project_scores(@project)).to_i %></div>
<!-- end -->

View File

@ -37,7 +37,7 @@
</li>
<li>
<%= link_to l(:label_file_score), {:controller => 'projects', :action => 'file_score_index', :remote => true}%> :
<%= format("%.2f" , document_score(@project)).to_i %>
<%= format("%.2f" , documents_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_code_submit_score), {:controller => 'projects', :action => 'code_submit_score_index', :remote => true}%> :

View File

@ -7,7 +7,7 @@
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:label_project_tool_response) ,project_feedback_path(@project)%></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_files) ,project_files_path(@project) %></li>
<% if @project.enabled_modules.where("name = 'wiki'").count > 0 %>
<li><%= link_to l(:project_module_wiki), project_wiki_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_wiki), project_wiki_path(@project) %></li>
<% end %>
</ul>
<ul><h3>进度跟踪</h3>
@ -17,7 +17,7 @@
</ul>
<ul><h3>其他工具</h3>
<% if @project.enabled_modules.where(" name = 'dts'").count > 0 %>
<li><%= link_to l(:label_module_share) ,share_show_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:label_module_share) ,share_show_path(@project) %></li>
<% end %>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_documents), project_documents_path(@project) %></li>
<li></li>

View File

@ -36,7 +36,8 @@ function checkMaxLength() {
</script>
<!-- fq -->
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
<h3><%= l(:label_user_response) %></h3>
@ -59,6 +60,8 @@ function checkMaxLength() {
</div>
<% end %>
<div style="clear: both;"></div>
<div id="project_feedback">
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
<% if @jour.size >0 %>
<ul class="message-for-user">
<% for journal in @jour%>
@ -72,13 +75,20 @@ function checkMaxLength() {
<span>
<% if reply_allow %>
<%= link_to l(:label_projects_feedback_respond),'#',
{:focus => 'project_respond',
:onclick => "toggleAndSettingWordsVal($('##{id}'),
$('##{id} textarea'),
'#{l(:label_reply_plural)} #{journal.user.name}: ');
{:focus => 'project_respond',
:onclick => "toggleAndSettingWordsVal($('##{id}'),
$('##{id} textarea'),
'#{l(:label_reply_plural)} #{journal.user.name}: ');
return false;"} %>
<% end %>
</span>
<% if User.current.logged? %>
<% if journal.user_id==User.current.id|| User.current.admin? %>
<%= link_to(l(:button_delete),{:controller => 'words', :action => 'destroyJournal', :object_id => journal.id, :project_id=>@project.id, :page=>@page},
:remote => true, :title => l(:button_delete)) %>
<% end %>
<% end %>
</span>
</span>
<div style="clear: both;"></div>
<% if reply_allow %>
@ -99,4 +109,5 @@ function checkMaxLength() {
<ul>
<%= pagination_links_full @feedback_pages %>
</ul>
</div>
</div>

View File

@ -13,16 +13,15 @@
</div>
<div class="activity-content" style="padding:5px 5px 5px 70px;">
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project.id %></strong>
<span class="activity-title font_lighter">
<% if @canShowRealName %>
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
(<%= link_to_user(e.event_author, @canShowRealName) if e.respond_to?(:event_author) %>)
<% else %>
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
<% end %>
<%= l(:label_new_activity) %>
</span>
<span class="activity-title font_lighter">
<% if @canShowRealName %>
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
(<%= link_to_user(e.event_author, @canShowRealName) if e.respond_to?(:event_author) %>)
<% else %>
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
<% end %>
<%= l(:label_new_activity) %>
</span>
<%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %>
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;">

View File

@ -9,9 +9,30 @@
<div style="float: left; width: 600px; padding-top: 6px; margin-left: 8px"><%= softapplication.description.truncate(95, omission: '...') %></div>
<div style="float: left; width: 200px; margin-left: 70px; margin-top: -3px; line-height: 0.5em ">
<%contest = softapplication.contests.first%>
<!--<table width="100%" border="0">-->
<!--<tr>-->
<!--<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_contest)%></td>-->
<!--<td style="width: 100px; word-wrap: break-word; word-break: break-all">-->
<!--<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_type)%></td>-->
<!--<td style="width: 100px; word-wrap: break-word; word-break: break-all">-->
<!--<%= softapplication.app_type_name %>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_adaptive_system)%></td>-->
<!--<td style="width: 100px; word-wrap: break-word; word-break: break-all">-->
<!--<%= softapplication.android_min_version_available %>-->
<!--</td>-->
<!--</tr>-->
<!--</table>-->
<p><%=l(:label_attendingcontestwork_belongs_contest)%><%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%></p>
<p><%=l(:label_attendingcontestwork_belongs_type)%><%= softapplication.app_type_name.truncate(10, omission: '...') %></p>
<p><%=l(:label_attendingcontestwork_adaptive_system)%><%= softapplication.android_min_version_available %></p>
<p><%=l(:label_attendingcontestwork_belongs_type)%><%= softapplication.app_type_name.truncate(14, omission: '...') %></p>
<%strTitle = softapplication.android_min_version_available%>
<p><%=l(:label_attendingcontestwork_adaptive_system)%><lable title="<%= strTitle %>"><%= strTitle.truncate(10,omisiion:'...') %></lable></p>
</div>
<div style="padding-left: 53px">
<span><%=l(:label_attendingcontestwork_developers)%><%= softapplication.application_developers %></span>

View File

@ -3,51 +3,54 @@
<div style="height: auto; padding-bottom: 10px">
<tr>
<td colspan="2" valign="top" width="320">
</td>
<td>
<table width="100%" border="0">
<tr style="font-size: 18px">
<td colspan="2" valign="top"><strong><%= @softapplication.name %></strong></td>
<td style="font-size: 15px; padding-left: 0px">
<%= link_to '删除', softapplication_path(@softapplication), method: :delete, data: {confirm: '您确定要删除吗?'} if @softapplication.destroyable_by? User.current %>&nbsp;
<%= link_to '编辑', edit_softapplication_path(@softapplication), method: :get if @softapplication.destroyable_by? User.current %>
</td>
</tr>
<tr>
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_type)%><%= @softapplication.app_type_name %></td>
<% contest = @softapplication.contests.first %>
<td style="width: 240px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_contest)%><%= contest ? link_to(contest.name, show_attendingcontest_contest_path(contest)) : '尚未加入竞赛' %></td>
</tr>
<tr>
<td style="padding-left: 40px"><%=l(:label_attendingcontestwork_release_person)%><%= @softapplication.user.name %></td>
<td><%=l(:label_attendingcontestwork_adaptive_system)%><%= @softapplication.android_min_version_available %></td>
</tr>
<tr>
<td style="padding-left: 40px">
<span><%=l(:label_attendingcontestwork_download)%></span>
<span>
<% options = {:author => true, :deletable => @softapplication.user.eql?(User.current)} %><%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %>
</span>
</td>
<table width="100%" border="0">
<tr style="font-size: 18px">
<td valign="top"><strong><%= @softapplication.name %></strong></td>
<td style="font-size: 15px; padding-right: 0px" align="right">
<%= link_to '删除', softapplication_path(@softapplication), method: :delete, data: {confirm: '您确定要删除吗?'} if @softapplication.destroyable_by? User.current %>&nbsp;
<%= link_to '编辑', edit_softapplication_path(@softapplication), method: :get if @softapplication.destroyable_by? User.current %>
</td>
</tr>
</table>
</div>
<td><%=l(:label_attendingcontestwork_developers)%><%= @softapplication.application_developers %></td>
</tr>
<tr>
<td style="padding-left: 40px"><%=l(:label_attendingcontestwork_average_scores)%>: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td><%=l(:label_attendingcontestwork_release_time)%><%=format_time @softapplication.created_at %></td>
</tr>
<tr>
<td style="padding-left: 40px">
<% if @project %>
<%=l(:label_attendingcontestwork_deposit_project)%><%= link_to "#@project", project_path(@project) %>
<% end %>
</td>
</tr>
</table>
</td>
</tr>
<div style="height: auto; padding-bottom: 10px">
<table width="100%" border="0">
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_type)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.app_type_name %></td>
<% contest = @softapplication.contests.first %>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_contest)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= contest ? link_to(contest.name, show_attendingcontest_contest_path(contest)) : '尚未加入竞赛' %></td>
</tr>
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_release_person)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.user.name %></td>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_adaptive_system)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.android_min_version_available %></td>
</tr>
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_download)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all">
<% options = {:author => true, :deletable => @softapplication.user.eql?(User.current)} %><%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %>
</td>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_developers)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.application_developers %></td>
</tr>
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_average_scores)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_release_time)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%=format_time @softapplication.created_at %></td>
</tr>
<tr>
<td style="padding-left: 40px">
<% if @project %>
<%=l(:label_attendingcontestwork_deposit_project)%><%= link_to "#@project", project_path(@project) %>
<% end %>
</td>
</tr>
</table>
</div>
<div class="underline-contests_one"></div>
@ -56,7 +59,7 @@
<div style="font-size: 15px;"><%=l(:label_work_description)%></div>
</strong>
<div style="padding-top: 5px"><%= @softapplication.description %></div>
<div style="padding-top: 5px; padding-left:10px"><%= @softapplication.description %></div>
</div>
<div class="underline-contests_one"></div>

View File

@ -34,42 +34,18 @@
</div>
<% elsif object_flag == '6' %>
<span><%#= image_tag("/images/sidebar/tags.png") %></span>
<span><%#= image_tag("/images/sidebar/tags.png") %></span>
<span>
<%= link_to (image_tag "/images/sidebar/add.png"), 'javascript:void(0);', :class => "tags_icona", :onclick=>"$('#put-tag-form-#{obj.class}-#{obj.id}').toggle(); readmore(this);" if User.current.logged? %>
<%#= toggle_link (image_tag "/images/sidebar/add.png"), "put-tag-form-#{obj.class}-#{obj.id}", {:focus => "put-tag-form-#{obj.class}-#{obj.id} #name"} if User.current.logged? %>
<%#= toggle_link (image_tag "/images/sidebar/add.png"), "put-tag-form-#{obj.class}-#{obj.id}", {:focus => "put-tag-form-#{obj.class}-#{obj.id} #name"} if User.current.logged? %>
</span>
&nbsp;&nbsp;
<div id="tags_show-<%=obj.class%>-<%=obj.id%>" style="display:inline; ">
<%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
</div>
<div id="put-tag-form-<%=obj.class%>-<%=obj.id%>" style="display: none">
<%= form_for "tag_for_save",:remote=>true,:header=>"Accept: application/javascript",:url=>tag_path,
:update => "tags_show",
:complete => "$(\"#put-tag-form-#{obj.class}-#{obj.id}\").hide();" do |f| %>
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length,:style=>"width: 100px;"%>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit l(:button_project_tags_add),:class => "small" %>
<div class='hidden'>
<% preTags = @preTags.nil? ? [] : @preTags %>
<% preTags.each do |tag|%>
<%= link_to tag, "
javascript:(function(){
var $tagInputVal = $('#put-tag-form-"+obj.class.to_s+"-"+obj.id.to_s+"').find('#name');
var tagArr = [];
tagArr = tagArr.concat( $tagInputVal[0].value.split(',') );
tagArr = tagArr.concat('"+tag.to_s+"');
tagArr = cleanArray(tagArr);
$tagInputVal.val(tagArr.join(','));
})();
"
%>
<% end%>
</div>
<%#= link_to_function l(:button_cancel), "$(\"#put-tag-form-#{obj.class}-#{obj.id}\").hide();"%>
<% end %>
</div>
&nbsp;&nbsp;
<div id="tags_show-<%=obj.class%>-<%=obj.id%>" style="display:inline; ">
<%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
</div>
<div id="put-tag-form-<%=obj.class%>-<%=obj.id%>" style="display: none;height: 100px;">
<%= render :partial => "courses/course_resources_html", :locals => {:obj => obj ,:object_flag => object_flag } %>
</div>
<% else %>
<span><%= image_tag("/images/sidebar/tags.png") %></span>

View File

@ -70,14 +70,13 @@
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
<% end %>
<% when '5' %>
<% if Forum.find(params[:id]) %>
<% if Forum.find(params[:id]).creator_id == User.current.id %>
<% when '5' %>
<% test = Forum.find(obj.id) %>
<% if test && test.creator_id == User.current.id %>
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
<% end %>
<% end %>
<% end %>
<% when '6' %>
<%# if (User.current.logged? &&
User.current.admin?

View File

@ -32,8 +32,9 @@
<tr>
<td colspan="2" width="580" style="word-break:break-all">
<p class="font_description">
<%= membership.course.short_description %>
</p></td>
<%= textilizable membership.course.short_description %>
</p>
</td>
</tr>
<tr>
<td>

View File

@ -6,11 +6,8 @@
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
<%= link_to(course.name.truncate(30, omission: '...')+":", course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
@ -19,7 +16,11 @@
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
(<%= course.members.count %>人)
<%# files_count = course.attachments.count.to_s %>
(<%= link_to "#{course.attachments.count.to_s}份", course_files_path(course) %>资料)

View File

@ -0,0 +1,50 @@
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
<% if @jour.size >0 %>
<ul class="message-for-user">
<% for journal in @jour%>
<li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user">
<span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span>
<span class="body">
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
<%= textilizable journal.notes%>
<span class="font_lighter"> <%= l :label_update_time %>: <%= format_time journal.created_on %></span>
<% id = 'project_respond_form_'+journal.id.to_s%>
<span>
<% if reply_allow %>
<%= link_to l(:label_projects_feedback_respond),'#',
{:focus => 'project_respond',
:onclick => "toggleAndSettingWordsVal($('##{id}'),
$('##{id} textarea'),
'#{l(:label_reply_plural)} #{journal.user.name}: ');
return false;"} %>
<% end %>
<% if User.current.logged? %>
<% if journal.user_id==User.current.id|| User.current.admin? %>
<%= link_to(l(:button_delete),{:controller => 'words', :action => 'destroyJournal', :object_id => journal.id, :project_id=>@project.id, :page=>@page},
:remote => true, :title => l(:button_delete)) %>
<% end %>
<% end %>
</span>
</span>
<div style="clear: both;"></div>
<% if reply_allow %>
<div id='<%= id %>' class="respond-form">
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
</div>
<% end %>
<div style="clear: both;"></div>
<div>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
</div>
</li>
<% end %>
</ul>
<% end %>
<div class="pagination" style="float:left;">
<ul>
<%= pagination_links_full(@feedback_pages,@feedback_count, :per_page_links => false){|text, parameters, options|
link_to text, project_feedback_path(@project,parameters.merge(:q => params[:q])) }%>
</ul>
</div>

View File

@ -0,0 +1,5 @@
<% if @journalP!=nil %>
//$(".message-for-user").children("#word_li_<%#=@journalP.id%>").remove();
$("#project_feedback").html("<%= escape_javascript(render :partial => 'words/feedback') %>");
<% end %>

View File

@ -1782,6 +1782,7 @@ en:
label_no_file_uploaded: No file uploaded
label_forum_new: New forum
label_memo_new_from_forum: Release memo
bale_edit_notice: Edit
label_user_grade: Individual score
label_active_homework: homework
@ -1797,6 +1798,8 @@ en:
label_record: 湘ICP备09019772
label_check_comment: Check comment
label_notification: Notification
#end
# ajax异步验证

View File

@ -707,6 +707,7 @@ zh:
label_news: 新闻
label_news_new: 添加新闻
bale_news_notice: 添加通知 #huang
bale_edit_notice: 修改通知
label_news_notice: 发布课程通知
label_news_plural: 新闻
label_news_latest: 最近的新闻
@ -1331,7 +1332,7 @@ zh:
permission_add_documents: 新建文档
permission_edit_documents: 编辑文档
permission_delete_documents: 删除文档
label_gantt_progress_line: Progress line
label_gantt_progress_line: 进度线
setting_jsonp_enabled: Enable JSONP support
field_inherit_members: Inherit members
field_closed_on: 已关闭

View File

@ -652,6 +652,7 @@ RedmineApp::Application.routes.draw do
delete 'words/destroy', :to => 'words#destroy'
get 'words/more', :to => 'words#more'
get 'words/back', :to=> 'words#back'
get 'words/destroyJournal', :to => 'words#destroyJournal'
############## fq
post 'calls/create', :to => 'bids#create'
delete 'calls/destroy', :to => 'bids#destroy'
@ -746,6 +747,7 @@ RedmineApp::Application.routes.draw do
match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution'
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
file = File.join(plugin_dir, "config/routes.rb")
if File.exists?(file)

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140814062455) do
ActiveRecord::Schema.define(:version => 20140812065417) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -177,6 +177,58 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
create_table "code_review_assignments", :force => true do |t|
t.integer "issue_id"
t.integer "change_id"
t.integer "attachment_id"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.string "action_type"
t.integer "changeset_id"
end
create_table "code_review_project_settings", :force => true do |t|
t.integer "project_id"
t.integer "tracker_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "updated_by"
t.boolean "hide_code_review_tab", :default => false
t.integer "auto_relation", :default => 1
t.integer "assignment_tracker_id"
t.text "auto_assign"
t.integer "lock_version", :default => 0, :null => false
t.boolean "tracker_in_review_dialog", :default => false
end
create_table "code_review_user_settings", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.integer "mail_notification", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "code_reviews", :force => true do |t|
t.integer "project_id"
t.integer "change_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "line"
t.integer "updated_by_id"
t.integer "lock_version", :default => 0, :null => false
t.integer "status_changed_from"
t.integer "status_changed_to"
t.integer "issue_id"
t.string "action_type"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.integer "attachment_id"
t.integer "file_count", :default => 0, :null => false
t.boolean "diff_all"
end
create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false
@ -396,14 +448,14 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
end
create_table "forums", :force => true do |t|
t.string "name", :null => false
t.text "description"
t.string "name", :null => false
t.string "description", :default => ""
t.integer "topic_count", :default => 0
t.integer "memo_count", :default => 0
t.integer "last_memo_id", :default => 0
t.integer "creator_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "creator_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "groups_users", :id => false, :force => true do |t|
@ -820,18 +872,18 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
create_table "relative_memos", :force => true do |t|
t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :null => false
t.string "subject", :null => false
t.text "content", :limit => 16777215, :null => false
t.integer "author_id"
t.integer "replies_count", :default => 0
t.integer "replies_count", :default => 0
t.integer "last_reply_id"
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
t.string "url"
t.string "username"
t.string "userhomeurl"
@ -855,6 +907,19 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
create_table "rich_rich_files", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "rich_file_file_name"
t.string "rich_file_content_type"
t.integer "rich_file_file_size"
t.datetime "rich_file_updated_at"
t.string "owner_type"
t.integer "owner_id"
t.text "uri_cache"
t.string "simplified_type", :default => "file"
end
create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1
@ -905,10 +970,11 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
t.string "url"
t.string "title"
t.integer "share_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "project_id"
t.integer "user_id"
t.string "description"
end
create_table "softapplications", :force => true do |t|
@ -1014,8 +1080,8 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
t.integer "zip_code"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "identity"
t.string "technical_title"
t.integer "identity"
t.string "student_id"
t.string "teacher_realname"
t.string "student_realname"
@ -1073,9 +1139,6 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
t.integer "file"
t.integer "issue"
end
create_table "user_statuses", :force => true do |t|

View File

@ -43,8 +43,13 @@ module Redmine
end
def attachments_visible?(user=User.current)
(respond_to?(:visible?) ? visible?(user) : true) &&
user.allowed_to?(self.class.attachable_options[:view_permission], self.project)
if self.respond_to?(:project)
(respond_to?(:visible?) ? visible?(user) : true) &&
user.allowed_to?(self.class.attachable_options[:view_permission], self.project)
else
return true
end
end
def attachments_deletable?(user=User.current)

View File

@ -0,0 +1,23 @@
desc "User New Score description"
task :user_new_score do
puts "user_score sync."
end
namespace :user_new_score do
desc "calculating user score"
task :calculating => :environment do
include UserScoreHelper
User.all.each do |user|
result = user_scores(user,1).total_score
puts "score of #{user.login} is #{result}"
end
Project.where("project_type != 1").all.each do |project|
project.member_principals.includes(:roles, :principal).all.each do |member|
result = user_scores(member.user,2,project).total_score
puts "#{user.login}/'s score in #{project.name} is #{result}"
end
end
puts "calculate completed"
end
end

View File

@ -0,0 +1,453 @@
desc "User Score description"
task :user_score_new do
puts "user_score sync."
end
namespace :user_score_new do
desc "calculating user score"
task :calculated => :environment do
include UserScoreHelper
puts "truncating table...#{Rails.env}"
puts "loading..."
# collaboration 协同得分
users = {}
grades = {}
# 发帖
Message.find_by_sql("SELECT `messages`.author_id AS u_id,`boards`.project_id AS p_id, COUNT(*) AS memo_number FROM `messages` JOIN `boards` ON `messages`.board_id = `boards`.id WHERE `messages`.parent_id IS NULL AND `boards`.project_id != -1 GROUP BY `messages`.author_id,`boards`.project_id ").each do|message|
option_num = get_option_num_by_id(message.u_id,2,message.p_id)
option_num.memo = message.memo_number
option_num.save
update_score(option_num)
puts "#{message.u_id}'s memo number in project #{message.p_id}: #{message.memo_number}"
end
Message.find_by_sql("SELECT `messages`.author_id AS u_id, COUNT(*) AS memo_number FROM `messages` JOIN `boards` ON `messages`.board_id = `boards`.id WHERE `messages`.parent_id IS NULL AND `boards`.project_id != -1 GROUP BY `messages`.author_id").each do|message|
option_num = get_option_num_by_id(message.u_id,1)
option_num.memo = message.memo_number
option_num.save
update_score(option_num)
puts "#{message.u_id}'s memo number: #{message.memo_number}"
end
puts "post_message calculate Completed."
#
## 对缺陷的留言
Journal.find_by_sql("SELECT user_id AS u_id,COUNT(*) AS m_count FROM journals WHERE journals.notes IS NOT NULL AND journals.notes != '' GROUP BY u_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,1)
option_num.messages_for_issues = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s messages_for_issues number: #{journal.m_count}"
end
Journal.find_by_sql("SELECT #{Journal.table_name}.user_id AS u_id, #{Issue.table_name}.project_id AS p_id ,COUNT(*) as m_count FROM journals join #{Issue.table_name} on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.notes IS NOT NULL AND journals.notes != '' GROUP BY u_id,p_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,2,journal.p_id)
option_num.messages_for_issues = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s messages_for_issues number in project #{journal.p_id}: #{journal.m_count}"
end
puts ":post_issue_message calculate Completed"
#
## 更改一次缺陷状态
Journal.find_by_sql("SELECT journals.user_id AS u_id, COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' GROUP BY u_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,1)
option_num.issues_status = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s issues_status number: #{journal.m_count}"
end
Journal.find_by_sql("SELECT journals.user_id AS u_id,issues.project_id AS p_id,COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' GROUP BY u_id,p_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,2,journal.p_id)
option_num.issues_status = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s issues_status number in project #{journal.p_id}: #{journal.m_count}"
end
puts ":change_issue_status calculate Completed"
#
## 对留言的回复
JournalsForMessage.find_by_sql("SELECT user_id AS u_id,COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and jour_type = 'Project' GROUP BY u_id").each do |jfm|
option_num = get_option_num_by_id(jfm.u_id,1)
option_num.replay_for_message = jfm.m_count
option_num.save
update_score(option_num)
puts "#{jfm.u_id}'s replay_for_message number: #{jfm.m_count}"
end
JournalsForMessage.find_by_sql("SELECT user_id AS u_id,jour_id AS p_id,COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and jour_type = 'Project' GROUP BY u_id,p_id").each do |jfm|
option_num = get_option_num_by_id(jfm.u_id,2,jfm.p_id)
option_num.replay_for_message = jfm.m_count
option_num.save
update_score(option_num)
puts "#{jfm.u_id}'s replay_for_message number in project #{jfm.p_id}: #{jfm.m_count}"
end
puts ":reply_message calculate Completed"
#
## 对帖子的回复
Message.find_by_sql("SELECT messages.author_id AS u_id, COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND boards.project_id != -1 GROUP BY u_id").each do |message|
option_num = get_option_num_by_id(message.u_id,1)
option_num.replay_for_memo = message.m_count
option_num.save
update_score(option_num)
puts "#{message.u_id}'s replay_for_memo number: #{message.m_count}"
end
Message.find_by_sql("SELECT messages.author_id AS u_id,boards.project_id AS p_id,COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND boards.project_id != -1 GROUP BY u_id,p_id").each do |message|
option_num = get_option_num_by_id(message.u_id,2,message.p_id)
option_num.replay_for_memo = message.m_count
option_num.save
update_score(option_num)
puts "#{message.u_id}'s replay_for_memo number in project #{message.p_id}: #{message.m_count}"
end
puts ":reply_posting calculate Completed."
#
#UserScore.transaction do
# users.each do |user_id, score|
# UserScore.find_or_create_by_user_id(user_id).update_attribute(:collaboration, score)
# end
#end
#puts "=== UserScore#collaboration calculate Completed. collaboration users count: #{users.count}"
#puts ""
#
#users.clear
#
## influence 影响力得分
##关注
Watcher.find_by_sql("SELECT watchable_id AS u_id ,COUNT(*) as m_count FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' GROUP BY u_id").each do |watcher|
option_num = get_option_num_by_id(watcher.u_id,1)
option_num.follow = watcher.m_count
option_num.save
update_score(option_num)
puts "#{watcher.u_id}'s follow number: #{watcher.m_count}"
end
puts ":followed_by calculate Completed."
#
#UserScore.transaction do
# users_influence.each do |user_id, score|
# UserScore.find_or_create_by_user_id(user_id).update_attribute(:influence, score)
# end
#end
#puts "=== UserScore#influence calculate Completed. influence users count: #{users_influence.count}"
#puts ""
## skill 技术得分
#计算相关user的等级
PraiseTread.find_by_sql("SELECT user_id AS u_id,COUNT(*) AS m_count FROM `praise_treads` WHERE praise_tread_object_type IN ( 'Issue','Message') GROUP BY u_id").each do |pt|
user = User.find(pt.u_id)
level = UserLevels.get_level(user)
puts "user #{user.login}'s level is #{level}"
end
## 踩帖
PraiseTread.find_by_sql("SELECT user_id AS u_id,COUNT(*) AS m_count FROM `praise_treads` WHERE praise_tread_object_type IN ( 'Issue','Message') AND praise_or_tread = 0 GROUP BY u_id").each do |pt|
#踩别人扣分
option_num = get_option_num_by_id(pt.u_id,1)
option_num.tread = pt.m_count
option_num.save
update_score(option_num)
puts "#{pt.u_id}'s tread number: #{pt.m_count}"
end
#SELECT AS u_id,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id = `praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' WHERE praise_or_tread = 0 GROUP BY u_id
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 0 GROUP BY target_u_id,u_level").each do |pt|
#缺陷被人踩的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.tread_by_one = pt.m_count
puts "user #{pt.target_u_id} tread by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two = pt.m_count
puts "user #{pt.target_u_id} tread by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three = pt.m_count
puts "user #{pt.target_u_id} tread by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `praise_treads`.user_id AS u_id,`issues`.project_id AS p_id, COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' WHERE praise_or_tread = 0 GROUP BY u_id,p_id").each do |pt|
#项目中踩别人缺陷的次数
option_num = get_option_num_by_id(pt.u_id,2,pt.p_id)
option_num.tread = pt.m_count
option_num.save
update_score(option_num)
puts "#{pt.u_id}'s tread number: #{pt.m_count}"
end
#项目中被人踩缺陷的次数
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`issues`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 0 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.tread_by_one = pt.m_count
puts "user #{pt.target_u_id} tread by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two = pt.m_count
puts "user #{pt.target_u_id} tread by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three = pt.m_count
puts "user #{pt.target_u_id} tread by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 0 GROUP BY target_u_id,u_level").each do |pt|
#讨论区被人踩的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.tread_by_one += pt.m_count
puts "user #{pt.target_u_id} tread by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two += pt.m_count
puts "user #{pt.target_u_id} tread by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three += pt.m_count
puts "user #{pt.target_u_id} tread by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `praise_treads`.user_id AS u_id,`boards`.project_id AS p_id, COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `boards` ON `boards`.id = `messages`.board_id AND `boards`.project_id != '-1' WHERE praise_or_tread = 0 GROUP BY u_id , p_id").each do |pt|
#项目讨论区中踩别人的次数
option_num = get_option_num_by_id(pt.u_id,2,pt.p_id)
option_num.tread += pt.m_count
option_num.save
update_score(option_num)
puts "#{pt.u_id}'s tread number: #{pt.m_count}"
end
#项目中被人踩的次数
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`boards`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id JOIN `boards` ON `boards`.id = `messages`.board_id AND `boards`.project_id != '-1' WHERE praise_or_tread = 0 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.tread_by_one += pt.m_count
puts "user #{pt.target_u_id} tread by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two += pt.m_count
puts "user #{pt.target_u_id} tread by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three += pt.m_count
puts "user #{pt.target_u_id} tread by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
#顶贴
#SELECT AS u_id,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id = `praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' WHERE praise_or_tread = 0 GROUP BY u_id
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 1 GROUP BY target_u_id,u_level").each do |pt|
#缺陷被人顶的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.praise_by_one = pt.m_count
puts "user #{pt.target_u_id} praise by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two = pt.m_count
puts "user #{pt.target_u_id} praise by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three = pt.m_count
puts "user #{pt.target_u_id} praise by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
#项目中被人顶缺陷的次数
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`issues`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 1 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.praise_by_one = pt.m_count
puts "user #{pt.target_u_id} praise by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two = pt.m_count
puts "user #{pt.target_u_id} praise by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three = pt.m_count
puts "user #{pt.target_u_id} praise by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 1 GROUP BY target_u_id,u_level").each do |pt|
#讨论区被人顶的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.praise_by_one += pt.m_count
puts "user #{pt.target_u_id} praise by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two += pt.m_count
puts "user #{pt.target_u_id} praise by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three += pt.m_count
puts "user #{pt.target_u_id} praise by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
#项目中被人踩的次数
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`boards`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id JOIN `boards` ON `boards`.id = `messages`.board_id AND `boards`.project_id != '-1' WHERE praise_or_tread = 1 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.praise_by_one += pt.m_count
puts "user #{pt.target_u_id} praise by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two += pt.m_count
puts "user #{pt.target_u_id} praise by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three += pt.m_count
puts "user #{pt.target_u_id} praise by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
puts "UserScore#skill calculate Completed."
#puts ""
#
## active 项目贡献得分
## 提交代码
Changeset.find_by_sql("SELECT user_id AS u_id, COUNT(*) AS m_count FROM `changesets` GROUP BY u_id").each do |changeset|
unless changeset.u_id.nil?
option_num = get_option_num_by_id(changeset.u_id,1)
option_num.changeset = changeset.m_count
option_num.save
update_score(option_num)
puts "#{changeset.u_id}'s changeset number: #{changeset.m_count}"
end
end
Changeset.find_by_sql("SELECT `changesets`.user_id AS u_id, `repositories`.project_id AS p_id,COUNT(*) AS m_count FROM `changesets` JOIN `repositories` ON `repositories`.id = `changesets`.repository_id GROUP BY u_id,p_id ").each do |changeset|
unless changeset.nil?
option_num = get_option_num_by_id(changeset.u_id,2,changeset.p_id)
option_num.changeset = changeset.m_count
option_num.save
update_score(option_num)
puts "#{changeset.u_id}'s changeset number in project #{changeset.p_id}: #{changeset.m_count}"
end
end
puts ":push_code calculate Completed."
##提交文档
Document.find_by_sql("SELECT user_id AS u_id ,COUNT(*) AS m_count FROM `documents` GROUP BY user_id").each do |document|
option_num = get_option_num_by_id(document.u_id,1)
option_num.document = document.m_count
option_num.save
update_score(option_num)
puts "#{document.u_id}'s document number: #{document.m_count}"
end
Document.find_by_sql("SELECT user_id AS u_id , project_id AS p_id, COUNT(*) AS m_count FROM `documents` GROUP BY u_id,p_id").each do |document|
option_num = get_option_num_by_id(document.u_id,2,document.p_id)
option_num.document = document.m_count
option_num.save
update_score(option_num)
puts "#{document.u_id}'s document number in project #{document.p_id}: #{document.m_count}"
end
puts ":push_document calculate Completed."
##提交附件
Attachment.find_by_sql("SELECT author_id AS u_id,COUNT(*) as m_count FROM #{Attachment.table_name} WHERE container_type = 'Project' GROUP By u_id").each do |attachment|
option_num = get_option_num_by_id(attachment.u_id,1)
option_num.attachment = attachment.m_count
option_num.save
update_score(option_num)
puts "#{attachment.u_id}'s attachment number: #{attachment.m_count}"
end
Attachment.find_by_sql("SELECT author_id AS u_id,container_id AS p_id,COUNT(*) as m_count FROM #{Attachment.table_name} WHERE container_type = 'Project' GROUP By u_id,p_id").each do |attachment|
option_num = get_option_num_by_id(attachment.u_id,2,attachment.p_id)
option_num.attachment = attachment.m_count
option_num.save
update_score(option_num)
puts "#{attachment.u_id}'s attachment number in project #{attachment.p_id}: #{attachment.m_count}"
end
puts ":push_file calculate Completed."
##更新完成度
Journal.find_by_sql("SELECT #{Journal.table_name}.user_id AS u_id, COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' GROUP BY u_id ").each do |j|
option_num = get_option_num_by_id(j.u_id,1)
option_num.issue_done_ratio = j.m_count
option_num.save
update_score(option_num)
puts "#{j.u_id}'s issue_done_ratio number: #{j.m_count}"
end
Journal.find_by_sql("SELECT #{Journal.table_name}.user_id AS u_id, #{Issue.table_name}.project_id AS p_id,COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' GROUP BY u_id,p_id ").each do |j|
option_num = get_option_num_by_id(j.u_id,2,j.p_id)
option_num.issue_done_ratio = j.m_count
option_num.save
update_score(option_num)
puts "#{j.u_id}'s issue_done_ratio number in project #{j.p_id}: #{j.m_count}"
end
puts ":update_issue_ratio calculate Completed."
##发布缺陷
Issue.find_by_sql("SELECT author_id AS u_id,COUNT(*) as m_count FROM #{Issue.table_name} GROUP BY u_id").each do |issues|
option_num = get_option_num_by_id(issues.u_id,1)
option_num.post_issue = issues.m_count
option_num.save
update_score(option_num)
puts "#{issues.u_id}'s issues number: #{issues.m_count}"
end
Issue.find_by_sql("SELECT author_id AS u_id,project_id AS p_id,COUNT(*) as m_count FROM #{Issue.table_name} GROUP BY u_id,p_id").each do |issues|
option_num = get_option_num_by_id(issues.u_id,2,issues.p_id)
option_num.post_issue = issues.m_count
option_num.save
update_score(option_num)
puts "#{issues.u_id}'s issues number in project #{issues.p_id}: #{issues.m_count}"
end
puts ":post_issue calculate Completed."
#
#
#UserScore.transaction do
# users_active.each do |user_id, score|
# UserScore.find_or_create_by_user_id(user_id).update_attribute(:active, score)
# end
#end
#puts "=== UserScore#active calculate Completed. active users count: #{users_active.count}"
#UserGrade.transaction do
# grades.each do |grade_id,score|
# grade = UserGrade.find(grade_id)
# grade.grade = score
# grade.save
# end
#end
#puts "=== UserGrid calculate Completed. UserGrids count: #{grades.count}"
end
end

View File

@ -46,8 +46,8 @@ review = issue.code_review
%>
<%= l(:label_revision) + " "%>
<%= link_to_revision(assignment.revision, repo) %>
<% elsif assignment.attachment %>
<%= link_to(assignment.attachment.filename, :controller => 'attachments', :action => 'show', :id => attachment.id) %>
<% elsif assignment.respond_to?("attachment") && assignment.attachment %>
<%= link_to(assignment.attachment.filename.to_s, :controller => 'attachments', :action => 'show', :id => assignment.attachment.id) %>
<% end %>
</td>
</tr>

View File

@ -107,7 +107,7 @@
<%
submit_url = url_for(:controller => 'code_review', :action => 'new', :id=>@project)
%>
<%= button_to_function l(:button_apply), "$('#review-form').load('#{submit_url}', $('#review_form').serialize2json())" %>
<%= button_to_function l(:label_button_ok), "$('#review-form').load('#{submit_url}', $('#review_form').serialize2json())" %>
<input type="button" value="<%=h l(:button_cancel) %> " onclick="javascript:hideForm();"/>
<%= preview_link({ :controller => 'code_review', :action => 'preview', :id => @project}, 'review_form') %>

View File

@ -20,7 +20,8 @@
<%= authoring reply.created_on, reply.user %>.
</p>
<%= avatar(reply.user, :size => "32") %>
<%= image_tag(url_to_avatar(reply.user), :class => 'avatar2', :width=>32, :height=>32) %>
<%#= avatar(reply.user, :size => "32") %>
<ul>
<% for detail in reply.details %>
<li><%= show_detail(detail) %></li>

View File

@ -62,7 +62,8 @@
<!-- author and creation time -->
<p class="author">
<%= avatar(@review.user, :size => "64") %>
<%= image_tag(url_to_avatar(@review.user), :class => 'avatar2', :width=>64, :height=>64) %>
<%#= avatar(@review.user, :size => "64") %>
<br />
<%= authoring @review.created_at, @review.user %>.
<%= l(:label_updated_time, distance_of_time_in_words(Time.now, @review.updated_at)) + '.' if @review.created_at != @review.updated_at %>

View File

@ -19,8 +19,8 @@
<script>
function change_option(flag) {
var url = "<%= raw url_for(:controller => 'code_review', :action=>'index', :id => @project) %>";
$('#content').load(url, {'show_closed': flag});
// var url = "<%= raw url_for(:controller => 'code_review', :action=>'index', :id => @project) %>";
// $('#content').load(url, {'show_closed': flag});
}
</script>
<div id="code_review_list">
@ -32,6 +32,15 @@ function change_option(flag) {
<p>
<%= form_tag({:controller => 'code_review', :action=>'index', :id => @project}, :id => 'optionform') do %>
<%= check_box_tag 'show_closed', 'true', @show_closed, :onchange => "change_option($('#show_closed').is(':checked'));"%> <%=h l(:label_show_closed_reviews) %>
<script type="text/javascript">
$(document).ready(function (){
$("#optionform").change(function(){
$("#optionform").submit();
});
});
</script>
<% end %>
<%# observe_field 'show_closed', :with => 'show_closed', :update => 'content' %>
</p>