From 1e234a9adfe4b7b3fa62889567269e42e54c4ae9 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 19 Aug 2014 17:03:26 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=9F=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 4 +- app/helpers/user_score_helper.rb | 185 +++++++++++++++++++++---- lib/tasks/user_new_score.rake | 23 +++ 3 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 lib/tasks/user_new_score.rake diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ccbff8e50..1dba60a6d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -683,8 +683,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").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/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 1353f9a1c..37cffae05 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -418,11 +418,26 @@ 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 = User.find_by_sql("SELECT `users`.id,(SELECT 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 = `users`.id) AS m_count +FROM `users` where 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 = User.find_by_sql("SELECT `users`.id,(SELECT 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 = `users`.id) AS m_count +FROM `users` where id = #{user.id}") + result = 0 + users.each do |user| + result = user.m_count + end + result end end @@ -448,9 +463,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals WHERE journals.user_id = users.id AND journals.notes IS NOT NULL AND journals.notes != '') AS m_count FROM users where id = #{user.id}") + 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 = User.find_by_sql("SELECT users.id,(SELECT 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 = users.id AND journals.notes IS NOT NULL AND journals.notes != ''and #{Issue.table_name}.project_id = '#{project.id}') AS m_count FROM users where id = #{user.id}") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -471,9 +498,21 @@ FROM `users` where id = #{user.id}") 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 = 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}'") + 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 + 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}'") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -481,10 +520,10 @@ 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 @@ -497,9 +536,21 @@ FROM `users` where id = #{user.id}") 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 = 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_count FROM users WHERE users.id = '#{user.id}'") + 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 = 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_count FROM users WHERE users.id = '#{user.id}'") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -508,7 +559,7 @@ 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 @@ -521,9 +572,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = users.id AND boards.project_id != -1) as m_count FROM users WHERE users.id = #{user.id}") + 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 = User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = users.id AND boards.project_id = #{project.id}) FROM users WHERE users.id = #{user.id}") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -538,16 +601,21 @@ 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 = User.find_by_sql("SELECT users.id, (SELECT COUNT(*) FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = users.id) as m_count FROM users WHERE users.id = '#{user.id}'") + result = 0 + if users.count > 0 + result = users.first.m_count + end 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 #更新帖子踩各项数量 @@ -689,9 +757,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT users.id, (SELECT COUNT(*) FROM #{Changeset.table_name} WHERE user_id = users.id) as m_count FROM users WHERE users.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 = User.find_by_sql("SELECT users.id, (SELECT 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 = users.id and #{Repository.table_name}.project_id = #{project.id}) as m_count FROM users WHERE users.id = '#{user.id}'") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -705,9 +785,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT COUNT(*) FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{User.table_name}.id) as m_count FROM #{User.table_name} where #{User.table_name}.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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT COUNT(*) FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{User.table_name}.id and #{Document.table_name}.project_id = '#{project.id}') as m_count FROM #{User.table_name} where #{User.table_name}.id = #{user.id}") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -721,9 +813,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT COUNT(*) FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project') as m_count FROM #{User.table_name} WHERE #{User.table_name}.id = #{user.id}") + 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 + User.find_by_sql("SELECT #{User.table_name}.id,(SELECT COUNT(*) FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}) as m_count FROM #{User.table_name} WHERE #{User.table_name}.id = #{user.id}") + result = 0 + if users.count > 0 + result = users.first.m_coumt + end + result end end @@ -736,9 +840,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT 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.table_name}.id) as m_count FROM #{User.table_name} WHERE #{User.table_name}.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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT 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.table_name}.id and #{Issue.table_name}.project_id = '#{project.id}') as m_count FROM #{User.table_name} WHERE #{User.table_name}.id = #{user.id}") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -752,9 +868,21 @@ FROM `users` where id = #{user.id}") 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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT COUNT(*) FROM #{Issue.table_name} WHERE author_id = #{User.table_name}.id ) as m_count FROM #{User.table_name} WHERE #{User.table_name}.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 = User.find_by_sql("SELECT #{User.table_name}.id,(SELECT COUNT(*) FROM #{Issue.table_name} WHERE author_id = #{User.table_name}.id and project_id = '#{project.id}' ) as m_count FROM #{User.table_name} WHERE #{User.table_name}.id = #{user.id}") + result = 0 + if users.count > 0 + result = users.first.m_count + end + result end end @@ -778,6 +906,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/lib/tasks/user_new_score.rake b/lib/tasks/user_new_score.rake new file mode 100644 index 000000000..32a43e07a --- /dev/null +++ b/lib/tasks/user_new_score.rake @@ -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 :calculate => :environment do + include UserScoreHelper + User.all.each do |user| + result = user_scores(user,1) + 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) + puts "#{user.login}/'s score in #{project.name} is #{result}" + end + end + puts "calculate completed" + end +end \ No newline at end of file From 50e1f413459afee5ee458e3a5ab17f7adcfc96b6 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 11:16:40 +0800 Subject: [PATCH 02/13] =?UTF-8?q?#1307=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9C=9F=E5=AE=9E=E5=A7=93=E5=90=8D=E5=8F=AA?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=90=8D=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=A7=93?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- app/views/bids/_homework_list.html.erb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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/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 %> - + - From a690fd79cf901d4712f2a6e71fc957563ed901d0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 14:43:29 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=97=B6=E6=A0=87=E9=A2=98=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_course_form.html.erb | 2 +- config/locales/en.yml | 3 +++ config/locales/zh.yml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index ad2c7835c..186bab18d 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -1,6 +1,6 @@ <%= error_messages_for @news %>
- <% str = l(:bale_news_notice)%> + <% str = l(:bale_edit_notice)%> <%= str %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 367624f89..602e7a659 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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异步验证 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d17f4c3bd..a73f9db56 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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: 最近的新闻 From 38188804a15dfcbb26b977988d873a4e8c247322 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 14:46:14 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=97=B6=E6=A0=87=E9=A2=98=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_course_form.html.erb | 3 +-- app/views/news/_course_news.html.erb | 2 +- app/views/news/_course_show.html.erb | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index 186bab18d..91b35670c 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -1,7 +1,6 @@ <%= error_messages_for @news %>
- <% str = l(:bale_edit_notice)%> - <%= str %> + <%= is_new ? l(:bale_news_notice):l(:bale_edit_notice)%>

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 5104cd851..adb2ce283 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -15,7 +15,7 @@
+
<%= 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"} %>

<%#=h news.summary %><% end %><%#= authoring news.created_on, news.author %>

--> diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index 91b35670c..7ce42439a 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -3,9 +3,11 @@ <%= is_new ? l(:bale_news_notice):l(:bale_edit_notice)%>
-

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

+

<%= f.text_field :title, :required => true, :size => 60, :style => "width:468px;", :onblur => "regexTitle();" %>

+

(60个字符以内)

-

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

+

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:470px;", :onblur => "regexDescription();" %>

+

<%= render :partial => 'attachments/form', :locals => {:container => @news} %>

diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index adb2ce283..fdf12c06d 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -3,6 +3,59 @@ label_tips = l(:label_course_news) %> + + <%= label_tips %> @@ -16,7 +69,8 @@ <%= 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, :is_new => true} %> - <%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %> | + <%#= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %> + <%= 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' %> diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index eb4b5e8b7..c6661d9fe 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -1,3 +1,56 @@ + +
<%= watcher_link(@news, User.current) %> <%= link_to(l(:button_edit), @@ -15,7 +68,8 @@ <%= 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, :is_new => false } %> - <%= submit_tag l(:button_save) %> + <%#= 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 %> From b30bfd073c9972205682cbcd48eda23f7a2ce222 Mon Sep 17 00:00:00 2001 From: linhk <304431313@.com> Date: Thu, 21 Aug 2014 16:55:46 +0800 Subject: [PATCH 08/13] 1 --- app/controllers/projects_controller.rb | 2 +- app/controllers/words_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3fea454de..329159a05 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -407,7 +407,7 @@ class ProjectsController < ApplicationController @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 = 3 + @limit = 10 offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) page = 1 + offset / @limit diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index e31bb2738..2d03b2112 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -99,7 +99,7 @@ class WordsController < ApplicationController @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 + @limit = 10 offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) page = 1 + offset / @limit From 337ca5fb9339a4c11564d1923bb470d8b16e3e83 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 17:14:30 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=95=99=E8=A8=80=E5=8F=96=E6=B6=88=E6=8C=89=E9=92=AE=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_newfeedback.html.erb | 2 +- app/views/words/_new.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 22ff5a280..d6337e1d0 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -2,7 +2,7 @@
<%= render :partial => 'words/new', :locals => {:user => @user, :sta => @state} %>
-
+
<%= l(:label_newfeedback_message) %>(<%= @feedback_count%>)
diff --git a/app/views/words/_new.html.erb b/app/views/words/_new.html.erb index aa2001028..bc4d19225 100644 --- a/app/views/words/_new.html.erb +++ b/app/views/words/_new.html.erb @@ -72,7 +72,7 @@
+ <%= submit_tag l(:button_cancel), :name => nil, :class => "enterprise", :onclick => "clearMessage('new_form_user_message');", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear), :name => nil, :class => "enterprise", :onclick => "clearMessage('new_form_user_message');", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
<% else %> From 063593218713bf51a660bd4f324b67d1fa85c8c8 Mon Sep 17 00:00:00 2001 From: linhk <304431313@.com> Date: Thu, 21 Aug 2014 17:31:36 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E9=A1=B9=E7=9B=AE=E9=93=BE=E6=8E=A5=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 20f64dc3f..b70d73eb6 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -129,7 +129,7 @@ <% if e.user == User.current %> - <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to(l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier)) %> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %> + <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to(l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.id)) %> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %> <% else %> From c4fff8a8ac759a79bd8d498020c05f8662b4e3cf Mon Sep 17 00:00:00 2001 From: chenmin <19763783@qq.com> Date: Fri, 22 Aug 2014 08:41:06 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=B8=96=E5=AD=90=E4=B8=BB=E9=A2=98=E8=BF=87=E9=95=BF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BC=98=E5=8C=96=EF=BC=9B=20=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E4=B8=BB=E9=A2=98=E4=B8=8B=E6=96=B9=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E8=99=9A=E7=BA=BFbug=E4=BF=AE=E5=A4=8D=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_project_show.html.erb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index ad91c72f8..ec06e3e86 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -95,11 +95,11 @@

-
+
<% if @project %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject.truncate(20, omission: '...'), project_boards_path(@topic.project),title: @topic.subject.to_s %> <% elsif @course %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course) %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject.truncate(20,omission:'...'), course_boards_path(@topic.course),title: @topic.subject.to_s %> <% end %>
@@ -179,9 +179,6 @@
<% end %> - - - <% if !@topic.locked? && authorize_for('messages', 'reply') %> diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index ec06e3e86..7f88816f5 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -97,9 +97,9 @@
<% if @project %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject.truncate(20, omission: '...'), project_boards_path(@topic.project),title: @topic.subject.to_s %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject.truncate(24, omission: '...'), project_boards_path(@topic.project),title: @topic.subject.to_s %> <% elsif @course %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject.truncate(20,omission:'...'), course_boards_path(@topic.course),title: @topic.subject.to_s %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject.truncate(24,omission:'...'), course_boards_path(@topic.course),title: @topic.subject.to_s %> <% end %>
From 554d744929924ac37e1ca585906256ef3baad6c9 Mon Sep 17 00:00:00 2001 From: chenmin <19763783@qq.com> Date: Fri, 22 Aug 2014 09:18:45 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=92=8C=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=B8=96=E5=AD=90=E6=98=BE=E7=A4=BA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=90=84=E5=B8=96=E5=AD=90=E5=86=85=E5=AE=B9=E6=B2=A1=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E7=9A=84bug=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_show.html.erb | 4 +++- app/views/boards/_project_show.html.erb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 25d35d407..ca33b7516 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -63,7 +63,9 @@ - + diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 1327f13e9..ef1afd27e 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -71,7 +71,9 @@
<%= link_to h(topic.subject), board_message_path(@board, topic) %><%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title: topic.subject.to_s %> +
<%=link_to (topic.replies_count), board_message_path(@board, topic) %>
回答
- +
<%= link_to h(topic.subject), board_message_path(@board, topic) %><%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title:topic.subject.to_s %> +