diff --git a/ReadMe.txt b/ReadMe.txt
index 7e8af4e21..538457d3d 100644
--- a/ReadMe.txt
+++ b/ReadMe.txt
@@ -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
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 178a82d17..4f731e580 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -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
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 44d68de26..c58cd3f82 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -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)
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index be27a71ea..047f7103e 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -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|
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index c80ce6d69..666c39d30 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -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
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index e840664b4..cdeb17e54 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -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
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 9437889b2..e564bc940 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -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
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ccbff8e50..1893224f8 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -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
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 110f81537..e31bb2738 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -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
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4d8b53e3c..7f38d8db9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index aad350d22..e08e50e80 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -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
diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb
index 07b0ee921..bdb070cc2 100644
--- a/app/helpers/project_score_helper.rb
+++ b/app/helpers/project_score_helper.rb
@@ -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
diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb
index 38f4f91f0..376f676b7 100644
--- a/app/helpers/user_score_helper.rb
+++ b/app/helpers/user_score_helper.rb
@@ -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}")
#鏇存柊鎻愪氦浠g爜娆℃暟
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
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index bcd8852f5..e25434e6e 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -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
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 38bdd0cc8..f2228e699 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -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
diff --git a/app/models/document.rb b/app/models/document.rb
index 42692bc22..7c2fa5a6d 100644
--- a/app/models/document.rb
+++ b/app/models/document.rb
@@ -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
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 68afe21a2..3a14d288d 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -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
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 0fe2b804b..a386c2b80 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -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
diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb
index 82a63b028..57541fe85 100644
--- a/app/models/journal_detail.rb
+++ b/app/models/journal_detail.rb
@@ -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
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index dd687f263..20e0c15f4 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -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
diff --git a/app/models/memo.rb b/app/models/memo.rb
index 2c0d3571f..b02564834 100644
--- a/app/models/memo.rb
+++ b/app/models/memo.rb
@@ -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 })
diff --git a/app/models/message.rb b/app/models/message.rb
index 647a665dc..0fdfc5b15 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -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
diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb
index 0a7282d26..3df5c72d9 100644
--- a/app/models/praise_tread.rb
+++ b/app/models/praise_tread.rb
@@ -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
diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb
index 6797bc9eb..6d3a2adcc 100644
--- a/app/views/bids/_homework_list.html.erb
+++ b/app/views/bids/_homework_list.html.erb
@@ -28,13 +28,15 @@
+ <% user_name = is_teacher ? (homework.user.firstname + homework.user.lastname) : homework.user.login %>
- <%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> |
+ <%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> |
-
+
+ |
- <%= 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"} %>
|
diff --git a/app/views/contestnotifications/_news.html.erb b/app/views/contestnotifications/_news.html.erb
index 301a193d8..fbac2557f 100644
--- a/app/views/contestnotifications/_news.html.erb
+++ b/app/views/contestnotifications/_news.html.erb
@@ -1,9 +1,9 @@
-
+ <%# unless news.summary.blank? %><%#=h news.summary %><% end %> |
+<%#= authoring news.created_on, news.author %> | -->
diff --git a/app/views/courses/_course_resources_html.erb b/app/views/courses/_course_resources_html.erb
new file mode 100644
index 000000000..8f706725d
--- /dev/null
+++ b/app/views/courses/_course_resources_html.erb
@@ -0,0 +1,32 @@
+<% id = "course_resources_ul_" + obj.id.to_s%>
+
+ <%= 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" %>
+
+ <% 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%>
+
+ <%#= 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 %>
+
\ No newline at end of file
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index d7d579dd1..366ec0c39 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -1,8 +1,8 @@
<% if @events_by_day != nil && @events_by_day.size >0 %>
-
+
- <%= 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)) %>
<% @events_by_day.keys.sort.reverse.each do |day| %>
@@ -29,7 +29,7 @@
<%= l(:label_new_activity) %>
- <%= 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;" %>
diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb
index 76112bc78..f70142a05 100644
--- a/app/views/files/_course_show_all_attachment.html.erb
+++ b/app/views/files/_course_show_all_attachment.html.erb
@@ -25,60 +25,70 @@
- <% @containers.each do |container| %>
- <% next if container.attachments.empty? -%>
- <% if container.is_a?(Version) -%>
-
+ <%# @containers.each do |container| %>
+ <%# next if container.attachments.empty? -%>
+ <%# if container.is_a?(Version) -%>
+
- <%= number_to_human_size(file.filesize) %> |
-
- <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %>
+ | -->
+ <%# end -%>
+ <% if @curse_attachments != nil %>
+ <% @curse_attachments.each do |file| %>
+ <%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
+ <%next%>
+ <%end%>
+ ">
+ <%= 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;" %> |
+
+ <%= number_to_human_size(file.filesize) %> |
+
+ <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %>
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %>
- |
- <%= file.show_suffix_type %> |
-
- <%= file.file_dense_str %>
-
+ |
+ <%= file.show_suffix_type %> |
+
+ <%= file.file_dense_str %>
+
<%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
:attachment => file} %>
- |
- <%= file.downloads %> |
-
-
- <%= link_to(image_tag('delete.png'), attachment_path(file),
- :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
- |
-
-
-
-
-
- |
-
- <% end -%>
- <% reset_cycle %>
+
+ <%= file.downloads %> |
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+ |
+
+
+
+
+
+ |
+
<% end -%>
+ <% end %>
+ <%# reset_cycle %>
+ <%# end -%>
+
+
+
+
diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb
index 838153c78..043fe1183 100644
--- a/app/views/files/_show_all_attachment.html.erb
+++ b/app/views/files/_show_all_attachment.html.erb
@@ -25,16 +25,17 @@
|
- <% @containers.each do |container| %>
- <% next if container.attachments.empty? -%>
- <% if container.is_a?(Version) -%>
-
+ <%# @containers.each do |container| %>
+ <%# next if container.attachments.empty? -%>
+ <%# if container.is_a?(Version) -%>
+
+ <%# 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 @@
<% end -%>
- <% reset_cycle %>
+ <%# reset_cycle %>
<% end -%>
+
+
+
diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb
index 804b52d68..f5018fc94 100644
--- a/app/views/issues/index.html.erb
+++ b/app/views/issues/index.html.erb
@@ -37,26 +37,26 @@
+ -->
<%= 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' %>
diff --git a/app/views/layouts/_base_enterprise_header.html.erb b/app/views/layouts/_base_enterprise_header.html.erb
index 7fd21afe1..d98b94839 100644
--- a/app/views/layouts/_base_enterprise_header.html.erb
+++ b/app/views/layouts/_base_enterprise_header.html.erb
@@ -1,13 +1,13 @@
@@ -31,14 +31,14 @@
-
+
-
+
diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb
index 990a6d3c8..46fc0debd 100644
--- a/app/views/layouts/_base_footer.html.erb
+++ b/app/views/layouts/_base_footer.html.erb
@@ -10,7 +10,7 @@
<%=l(:label_organizers)%>
- <%=l(:label_copyright)%>@2007~2014
+ <%=l(:label_copyright)%>漏2007~2014
diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb
index 3116a9a68..b943cf565 100644
--- a/app/views/layouts/_base_header.html.erb
+++ b/app/views/layouts/_base_header.html.erb
@@ -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 %>
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %>
+ <% end %>
<% end -%>
<% end %>
- <%= 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 %>
+
+ <%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<% if hasCourse %>
+ <% end %>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
diff --git a/app/views/layouts/_base_home_menu.html.erb b/app/views/layouts/_base_home_menu.html.erb
index ca3e5c847..9327cae49 100644
--- a/app/views/layouts/_base_home_menu.html.erb
+++ b/app/views/layouts/_base_home_menu.html.erb
@@ -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? %>
-
+
-
+
<%= render_menu :top_home_menu if User.current.logged? || !Setting.login_required? -%>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 725e7fba9..01510865b 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -82,7 +82,7 @@
<%= join_in_course(@course, User.current) %>
<% end %>
<% unless User.current.member_of_course?(@course) %>
-
+
<% end %>
<% end %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index d8eb17acd..c3ad0fe08 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -50,11 +50,11 @@
-
+