From 6607e72ca461f05e4f6c7dd1c759de2765d49a9a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 12:08:24 +0800 Subject: [PATCH 01/13] =?UTF-8?q?user=5Fscore=5Fhelper.rb=E8=BF=98?= =?UTF-8?q?=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/user_score_helper.rb | 192 +++++++++++++++---------------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index c94763e31..9a35f276c 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -27,7 +27,7 @@ module UserScoreHelper issue_c = issue_c + Journal.where("user_id = ?", user.id).count ############################ memos = Memo.where('author_id = ? AND parent_id IS NOT NULL', user.id) - + memos.each do |m| if Memo.find(m.parent_id).author.id != user.id issue_c = issue_c + 1 @@ -35,18 +35,18 @@ module UserScoreHelper issue_c = issue_c - 1 end end - - + + pmemos = Memo.where('author_id = ? AND parent_id IS NULL', user.id) pmemos.each do |pm| issue_c = issue_c + pm.replies_count end ############################ - + issue_c = issue_c + JournalsForMessage.where('user_id = ? AND reply_id IS NOT NULL AND reply_id <> ?', user.id, user.id).count + JournalsForMessage.where('reply_id = ? AND user_id <> ?', user.id, user.id).count - - - + + + return issue_c end @@ -58,14 +58,14 @@ module UserScoreHelper def calculate_skill_count(user) - + praise_count_l0 = 0 praise_count_l1 = 0 praise_count_l2 = 0 tread_count_l0 = 0 tread_count_l1 = 0 tread_count_l2 = 0 - issues = Issue.where('author_id = ?', user.id) + issues = Issue.where('author_id = ?', user.id) issues.each do |i| pts = PraiseTread.where('praise_tread_object_id = ?', i.id) pts.each do |p| @@ -75,7 +75,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -97,7 +97,7 @@ module UserScoreHelper - + bids = Bid.where('author_id = ?', user.id) bids.each do |b| ptcs = PraiseTread.where('praise_tread_object_id = ?', b.id) @@ -108,7 +108,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -127,7 +127,7 @@ module UserScoreHelper end end end - + contests = Contest.where('author_id = ?', user.id) contests.each do |c| ptcs = PraiseTread.where('praise_tread_object_id = ?', c.id) @@ -138,7 +138,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -154,12 +154,12 @@ module UserScoreHelper else tread_count_l2 + tread_count_l2 + 1 end - end - end + end + end end - - - + + + # case level # when 0 skill_score = praise_count - 0.5 * tread_count # when 1 skill_score = 2 * praise_count - 1.5 * tread_count @@ -169,10 +169,10 @@ module UserScoreHelper # end skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f - - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f - + - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f + tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count - + skill_score = skill_score.to_f - tread_user_count.to_f @@ -182,17 +182,17 @@ module UserScoreHelper return skill_score - - - + + + end - + def calculate_level(user) commit_count = user.changesets.count max_praise_num = 0 - - - issues = Issue.where('author_id = ?', user.id) + + + issues = Issue.where('author_id = ?', user.id) issues.each do |i| ptcs = PraiseTreadCache.where('object_id = ?', i.id) ptcs.each do |p| @@ -201,7 +201,7 @@ module UserScoreHelper end end end - + bids = Bid.where('author_id = ?', user.id) bids.each do |b| ptcs = PraiseTreadCache.where('object_id = ?', b.id) @@ -211,7 +211,7 @@ module UserScoreHelper end end end - + contests = Contest.where('author_id = ?', user.id) contests.each do |c| ptcs = PraiseTreadCache.where('object_id = ?', c.id) @@ -219,12 +219,12 @@ module UserScoreHelper if p.praise_num.to_i > max_praise_num.to_i max_praise_num = p.praise_num end - end + end end - - + + best_answer_num = 0 - + isManager = 0 members = Member.where('user_id = ?', user.id) members.each do |m| @@ -238,21 +238,21 @@ module UserScoreHelper end - + level = 0 - + if max_praise_num > 4 level = 1 end if commit_count > 0 and commit_count < 101 level = 1 - end + end if commit_count > 100 or isManager == 1 level = 2 end - + return level - + end def calculate_activity_count(user) @@ -282,23 +282,23 @@ module UserScoreHelper def calculate_issue(user) commit_count = user.changesets.count - + issue_details_count = 0 issues = Issue.where('assigned_to_id = ?', user.id) - + change_count = 0 issues.each do |issue| js = issue.journals js.each do |j| change_count = change_count + j.details.where("prop_key = ?", "done_ratio").count end - - + + issue_details_count = change_count + issue_details_count end - + return (commit_count + issue_details_count) - + end @@ -306,9 +306,9 @@ module UserScoreHelper attachments = Attachment.where("container_type IS NOT NULL AND container_type <> 'Issue' AND author_id = ?", user.id).count return attachments - + end - + def calculate_user_score(user) collaboration = calculate_collaboration_count(user) influence = calculate_influence_count(user) @@ -320,9 +320,9 @@ module UserScoreHelper #user.user_score << UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill, # :activity => activity, :file => file, :issue => issue, :level => level) UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill, - :activity => activity, :file => file, :issue => issue, :level => level) + :activity => activity, :file => file, :issue => issue, :level => level) end - + def update_user_score(user) collaboration = calculate_collaboration_count(user) influence = calculate_influence_count(user) @@ -331,7 +331,7 @@ module UserScoreHelper issue = calculate_issue(user) ##activity = calculate_activity_count(user) - + level = calculate_level(user) user.user_score.update_attributes(:collaboration => collaboration, :influence => influence, :skill => skill, :activity => activity, :file => file, :issue => issue, :level => level) @@ -348,37 +348,37 @@ module UserScoreHelper 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.nil? - result.project_id = project.id - end - else - result = option_number.first - end - result + 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.nil? + result.project_id = project.id + end + else + result = option_number.first + end + result end def get_option_num_by_id(user_id,type,project_id=nil) @@ -433,7 +433,7 @@ module UserScoreHelper #协同得分 def collaboration(option_number) - option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo end #影响力得分 def influence(option_number) @@ -441,11 +441,11 @@ module UserScoreHelper end #技术得分 def skill(option_number) - option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 + option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 end #项目贡献得分 def active(option_number) - option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2 end #更新发帖数 @@ -473,7 +473,7 @@ WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}") WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}") result = 0 users.each do |user| - result = user.m_count + result = user.m_count end result end @@ -481,15 +481,15 @@ WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}") end def memo_score(user,project=nil) - if project.nil? - User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id + if project.nil? + User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 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}") - else - User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id + else + User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 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}") - end + end end #更新对缺陷留言数 @@ -505,7 +505,7 @@ FROM `users` where id = #{user.id}") 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 + result = users.first.m_count end result else @@ -521,7 +521,7 @@ FROM `users` where id = #{user.id}") def messges_for_issue_score(user,project=nil) if project.nil? - 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_score FROM users where id = #{user.id}") + 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_score FROM users where id = #{user.id}") else 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_score FROM users where id = #{user.id}") end @@ -594,11 +594,11 @@ FROM `users` where id = #{user.id}") end def replay_for_message_score(user,project=nil) - if project.nil? + 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 + 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}'") - end + end end #更新对帖子的回复数量 From 78cfed2b684635123d012f4dc04cefdf6aa59b8b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 14:29:04 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/user_score_helper.rb | 94 ++++++++++++++++---------------- app/models/query.rb | 39 ++++++------- 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 9a35f276c..5d76fce9b 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -169,7 +169,7 @@ module UserScoreHelper # end skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f - - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f + - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count @@ -320,7 +320,7 @@ module UserScoreHelper #user.user_score << UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill, # :activity => activity, :file => file, :issue => issue, :level => level) UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill, - :activity => activity, :file => file, :issue => issue, :level => level) + :activity => activity, :file => file, :issue => issue, :level => level) end def update_user_score(user) @@ -348,37 +348,37 @@ module UserScoreHelper 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.nil? - result.project_id = project.id - end - else - result = option_number.first - end - result + 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.nil? + result.project_id = project.id + end + else + result = option_number.first + end + result end def get_option_num_by_id(user_id,type,project_id=nil) @@ -433,7 +433,7 @@ module UserScoreHelper #协同得分 def collaboration(option_number) - option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo + option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo end #影响力得分 def influence(option_number) @@ -441,11 +441,11 @@ module UserScoreHelper end #技术得分 def skill(option_number) - option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 + option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 end #项目贡献得分 def active(option_number) - option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2 + option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 end #更新发帖数 @@ -473,7 +473,7 @@ WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}") WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}") result = 0 users.each do |user| - result = user.m_count + result = user.m_count end result end @@ -481,15 +481,15 @@ WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}") end def memo_score(user,project=nil) - if project.nil? - User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id + if project.nil? + User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 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}") - else - User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id + else + User.find_by_sql("SELECT `users`.id,(SELECT COUNT(*) * 2 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}") - end + end end #更新对缺陷留言数 @@ -505,7 +505,7 @@ FROM `users` where id = #{user.id}") 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 + result = users.first.m_count end result else @@ -521,7 +521,7 @@ FROM `users` where id = #{user.id}") def messges_for_issue_score(user,project=nil) if project.nil? - 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_score FROM users where id = #{user.id}") + 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_score FROM users where id = #{user.id}") else 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_score FROM users where id = #{user.id}") end @@ -594,11 +594,11 @@ FROM `users` where id = #{user.id}") end def replay_for_message_score(user,project=nil) - if project.nil? + 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 + 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}'") - end + end end #更新对帖子的回复数量 diff --git a/app/models/query.rb b/app/models/query.rb index 7f51aa53c..65c78e71f 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -493,26 +493,27 @@ class Query < ActiveRecord::Base def project_statement project_clauses = [] # unless project.descendants.blank? - if project && project.descendants && project.descendants.active && !project.descendants.active.empty? - ids = [project.id] - if has_filter?("subproject_id") - case operator_for("subproject_id") - when '=' - # include the selected subprojects - ids += values_for("subproject_id").each(&:to_i) - when '!*' - # main project only - else - # all subprojects - ids += project.descendants.collect(&:id) - end - elsif Setting.display_subprojects_issues? - ids += project.descendants.collect(&:id) - end - project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') - elsif project + # if project && project.descendants && project.descendants.active && !project.descendants.active.empty? + # ids = [project.id] + # if has_filter?("subproject_id") + # case operator_for("subproject_id") + # when '=' + # # include the selected subprojects + # ids += values_for("subproject_id").each(&:to_i) + # when '!*' + # # main project only + # else + # # all subprojects + # ids += project.descendants.collect(&:id) + # end + # elsif Setting.display_subprojects_issues? + # ids += project.descendants.collect(&:id) + # end + # project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') + # elsif project + if project project_clauses << "#{Project.table_name}.id = %d" % project.id - end + end # end project_clauses.any? ? project_clauses.join(' AND ') : nil end From f3e4812d005ad4fedf995ebe2b5eca3dcb16984b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 15:01:59 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BE=97=E5=88=86=E6=96=B9=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/user_score_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 5d76fce9b..c82255d00 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -423,7 +423,7 @@ module UserScoreHelper #更新分数 def update_score(option_number) - option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number) + option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + project_active(option_number) if option_number.total_score < 0 option_number.total_score = 0 end @@ -444,7 +444,7 @@ module UserScoreHelper option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 end #项目贡献得分 - def active(option_number) + def project_active(option_number) option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 end From 704337fe5698e1d279d669ee5b63c1b48391b218 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sun, 6 Sep 2015 15:16:32 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E5=85=A8=E9=80=89=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=B5=84=E6=BA=90=EF=BC=8C=E7=84=B6=E5=90=8E=E5=86=8D=E7=94=A8?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E8=BF=87=E6=BB=A4=EF=BC=8C=E5=85=A8?= =?UTF-8?q?=E9=80=89checkbox=E5=92=8C=E9=80=89=E6=8B=A9=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=9A=84=E4=B8=AA=E6=95=B0=E5=BA=94=E8=AF=A5=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/resource_search.js.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index 894c1d2fa..d295ce003 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -1,3 +1,5 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#res_all_count").html(<%= @atta_count%>); \ No newline at end of file +$("#res_all_count").html(<%= @atta_count%>); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); \ No newline at end of file From 55758c3c2fb0d1191938de8c3f2ef42e4b5f8bc5 Mon Sep 17 00:00:00 2001 From: cxt Date: Sun, 6 Sep 2015 15:31:26 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=8E=89=E6=9C=AA?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E7=9A=84=E9=97=AE=E5=8D=B7=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/_course_poll.html.erb | 4 +++- app/views/users/_user_activities.html.erb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3480b238..a110850aa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -767,7 +767,7 @@ class UsersController < ApplicationController @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - course_types = "('Message','News','HomeworkCommon','poll')" + course_types = "('Message','News','HomeworkCommon','Poll')" project_types = "('Message','Issue')" if params[:type].present? case params[:type] diff --git a/app/views/users/_course_poll.html.erb b/app/views/users/_course_poll.html.erb index 24adf108e..bde8de90d 100644 --- a/app/views/users/_course_poll.html.erb +++ b/app/views/users/_course_poll.html.erb @@ -1,5 +1,6 @@ <% has_commit = has_commit_poll?(activity.id ,User.current)%> <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> +<% if has_commit || activity.user_id == User.current %>
@@ -43,4 +44,5 @@
-
\ No newline at end of file + +<% end %> \ No newline at end of file diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 2d447d739..4ff98b1b7 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -23,7 +23,7 @@ target.show(); }else{ btn.data('init',0); - btn.html('点击展开更多回复('+btn.data('count')+')'); + btn.html('展开更多('+btn.data('count')+')'); target.hide(); target.eq(0).show(); target.eq(1).show(); From 08fd7e125f4552e7669c82a94971ef1587570667 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sun, 6 Sep 2015 15:41:43 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=BB=8E=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=BA=93=E5=BC=95=E5=85=A5=E4=BD=9C=E8=80=85=E4=B8=BA?= =?UTF-8?q?=E5=88=AB=E4=BA=BA=E7=9A=84=E8=B5=84=E6=BA=90=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=A0=E9=99=A4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3480b238..366ed5ff2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -507,6 +507,7 @@ class UsersController < ApplicationController att_copy = atta.copy att_copy.container_id = nil att_copy.container_type = nil + att_copy.author_id = User.current.id att_copy.copy_from = atta.id att_copy.save @attachments << att_copy From 9f8fee82679e20a5c87db741b1811ead49afe0c3 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 15:46:28 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_influence_new_score_index.html.erb | 2 +- app/views/users/_score_new_index.html.erb | 4 ++-- app/views/users/_show_new_score.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/users/_influence_new_score_index.html.erb b/app/views/users/_influence_new_score_index.html.erb index 505785351..f99cdee19 100644 --- a/app/views/users/_influence_new_score_index.html.erb +++ b/app/views/users/_influence_new_score_index.html.erb @@ -5,4 +5,4 @@
    <%= l('userscore.active.update_issues')%> * 2 = <%= option_num.issue_done_ratio %> * 2 = <%= option_num.issue_done_ratio * 2 %>
    <%= l('userscore.active.release_issues')%> * 4 = <%= option_num.post_issue %> * 4 = <%= option_num.post_issue * 4 %>
    <%= l('userscore.active.release_messages')%> * 1 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %>
-
    <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= active(option_num) %>
\ No newline at end of file +
    <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= project_active(option_num) %>
\ No newline at end of file diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index e50b240fd..c1d23d0ed 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -5,8 +5,8 @@ <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
= <%= format("%.2f" ,collaboration(option_num)).to_i %> + <%= format("%.2f" , influence(option_num) ).to_i %> - + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" , active(option_num)).to_i %>
- <% if (format("%.2f" ,collaboration(option_num)).to_i + format("%.2f" , influence(option_num) ).to_i + format("%.2f" , skill(option_num)).to_i + format("%.2f" , active(option_num)).to_i) < 0 %> + + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" ,project_active(option_num)).to_i %> + <% if (format("%.2f" ,collaboration(option_num)).to_i + format("%.2f" , influence(option_num) ).to_i + format("%.2f" , skill(option_num)).to_i + format("%.2f" , project_active(option_num)).to_i) < 0 %>
<%= l(:label_score_less_than_zero) %>
<% else %>
= <%= format("%.2f" ,option_num.total_score).to_i %>
diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index 2081c38d6..4e89506a6 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -68,7 +68,7 @@
  • <%= link_to l(:label_user_score_of_active), "javascript:void(0)", :onclick => "show_div('influence_new_score_index')" %> : - <%= format("%.2f" , active(option_num)).to_i %> + <%= format("%.2f" , project_active(option_num)).to_i %>
  • From 29379788fe9e62669c3f23ad49646ab3b201d416 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 16:31:15 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=87=8C=E5=9B=9E=E5=A4=8D=E7=BC=BA=E9=99=B7=E7=95=99=E8=A8=80?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b3624b14d..6a0b351ba 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -386,14 +386,16 @@ class IssuesController < ApplicationController end def add_journal - jour = Journal.new - jour.user_id = User.current.id - jour.notes = params[:notes] - jour.journalized = @issue - jour.save - @user_activity_id = params[:user_activity_id] - respond_to do |format| - format.js + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end end end From 093273968b39fa802d18614d12659eb04c3d61a9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 16:38:12 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=A8=E7=BC=BA=E9=99=B7=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 5bf838c25..ec38d5c1d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150906025009) do +ActiveRecord::Schema.define(:version => 20150906083453) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 9ddb4f66831c9db283736cabe66b10b9ab1eab93 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 16:38:24 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8C=BF=E5=90=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=A8=E7=BC=BA=E9=99=B7=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20150906083453_delete_anonymous_jour.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20150906083453_delete_anonymous_jour.rb diff --git a/db/migrate/20150906083453_delete_anonymous_jour.rb b/db/migrate/20150906083453_delete_anonymous_jour.rb new file mode 100644 index 000000000..5361eb5e1 --- /dev/null +++ b/db/migrate/20150906083453_delete_anonymous_jour.rb @@ -0,0 +1,15 @@ +class DeleteAnonymousJour < ActiveRecord::Migration + def up + jour_count = Journal.all.count / 30 + 2 + transaction do + for i in 1 ... jour_count do i + Journal.page(i).per(30).each do |jour| + jour.destroy if jour.user_id == 2 + end + end + end + end + + def down + end +end From e0376b5176ffc0c09907765f312e42fb465ad2cd Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 16:46:03 +0800 Subject: [PATCH 11/13] =?UTF-8?q?tag=E7=9A=84=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E5=92=8C=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_tags.html.erb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/base_tags.html.erb b/app/views/layouts/base_tags.html.erb index 6a5b490d1..3fd00e042 100644 --- a/app/views/layouts/base_tags.html.erb +++ b/app/views/layouts/base_tags.html.erb @@ -19,12 +19,23 @@ <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> + <%= stylesheet_link_tag 'base','header', :media => 'all'%> + +
    + +
    +
    -<%= render :partial => 'layouts/base_header'%>
    - <%= render :partial => 'layouts/base_footer'%>
    @@ -47,6 +57,11 @@
    + +
    +<%= render :partial => 'layouts/footer' %> +
    + <%= call_hook :view_layouts_base_body_bottom %> From 089c4ab490256638cc8cb27a057139829044cf32 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 16:49:29 +0800 Subject: [PATCH 12/13] =?UTF-8?q?1=E3=80=81=E7=94=A8=E6=88=B7=E5=8F=AA?= =?UTF-8?q?=E5=8F=AF=E6=9F=A5=E7=9C=8B=E8=87=AA=E5=B7=B1=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=95=8C=E9=9D=A2=202=E3=80=81=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=92=8C=E7=99=BB=E5=BD=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 126 +++++++++++++++------------- 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3480b238..d0b0bd82d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -296,12 +296,16 @@ class UsersController < ApplicationController #用户作业列表 def user_homeworks - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10) - respond_to do |format| - format.js - format.html {render :layout => 'new_base_user'} + if User.current == @user + @page = params[:page] ? params[:page].to_i + 1 : 0 + user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" + @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10) + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 end end @@ -345,16 +349,20 @@ class UsersController < ApplicationController end def new_user_commit_homework - @user = User.current - @homework = HomeworkCommon.find(params[:homework_id]) - @is_test = params[:is_test] == 'true' - @student_work = @homework.student_works.where(user_id: User.current.id).first - if @student_work.nil? - @student_work = StudentWork.new - end - respond_to do |format| - format.js - format.html {render :layout => 'new_base_user'} + if User.current.logged? + @user = User.current + @homework = HomeworkCommon.find(params[:homework_id]) + @is_test = params[:is_test] == 'true' + @student_work = @homework.student_works.where(user_id: User.current.id).first + if @student_work.nil? + @student_work = StudentWork.new + end + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 end end @@ -364,53 +372,57 @@ class UsersController < ApplicationController end def user_new_homework - if params[:homework_common] - homework = HomeworkCommon.new - homework.name = params[:homework_common][:name] - homework.description = params[:homework_common][:description] - homework.end_time = params[:homework_common][:end_time] || Time.now - homework.publish_time = Time.now - homework.homework_type = params[:homework_type].to_i || 1 - homework.late_penalty = 2 - homework.user_id = User.current.id - homework.course_id = params[:course_id] + if User.current.logged? + if params[:homework_common] + homework = HomeworkCommon.new + homework.name = params[:homework_common][:name] + homework.description = params[:homework_common][:description] + homework.end_time = params[:homework_common][:end_time] || Time.now + homework.publish_time = Time.now + homework.homework_type = params[:homework_type].to_i || 1 + homework.late_penalty = 2 + homework.user_id = User.current.id + homework.course_id = params[:course_id] - homework.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(homework) + homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(homework) - #匿评作业相关属性 - if homework.homework_type == 1 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now - homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 - homework_detail_manual.absence_penalty = 2 - homework.homework_detail_manual = homework_detail_manual - else - homework_detail_programing = HomeworkDetailPrograming.new - homework.homework_detail_programing = homework_detail_programing - homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_programing.language = params[:program][:language].to_i + #匿评作业相关属性 + if homework.homework_type == 1 + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = Time.now + homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 + homework_detail_manual.absence_penalty = 2 + homework.homework_detail_manual = homework_detail_manual + else + homework_detail_programing = HomeworkDetailPrograming.new + homework.homework_detail_programing = homework_detail_programing + homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_programing.language = params[:program][:language].to_i - inputs = params[:program][:input] - if Array === inputs - inputs.each_with_index do |val, i| - homework.homework_tests << HomeworkTest.new( - input: val, - output: params[:program][:output][i] - ) + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + homework.homework_tests << HomeworkTest.new( + input: val, + output: params[:program][:output][i] + ) + end end - end - - end - if homework.save - homework_detail_manual.save if homework_detail_manual - homework_detail_programing.save if homework_detail_programing - redirect_to user_homeworks_user_path(User.current.id) + end + + if homework.save + homework_detail_manual.save if homework_detail_manual + homework_detail_programing.save if homework_detail_programing + redirect_to user_homeworks_user_path(User.current.id) + end end + else + render_403 end end From b89218a1b374dd3049d28ad0ffbfec961d176b5a Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 6 Sep 2015 16:50:03 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=AA=E8=AF=BB=E6=B6=88=E6=81=AF=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=92=8C=E2=80=9C=E5=85=A8=E9=83=A8=E8=AE=BE=E4=B8=BA?= =?UTF-8?q?=E5=B7=B2=E8=AF=BB=E2=80=9D=E5=8A=9F=E8=83=BD=20=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E7=95=99=E8=A8=80=E6=B7=BB=E5=8A=A0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 30 +++++++++++++++----------- app/views/users/user_messages.html.erb | 6 +++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3480b238..d1eeda707 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -102,22 +102,22 @@ class UsersController < ApplicationController # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) def user_messages unless User.current.logged? - render_403 + redirect_to signin_url return end # 当前用户查看消息,则设置消息为已读 - #if params[:viewed] == "all" - # course_querys = @user.course_messages - # forge_querys = @user.forge_messages - # user_querys = @user.user_feedback_messages - # forum_querys = @user.memo_messages - # if User.current.id == @user.id - # course_querys.update_all(:viewed => true) - # forge_querys.update_all(:viewed => true) - # user_querys.update_all(:viewed => true) - # forum_querys.update_all(:viewed => true) - # end - #end + if params[:viewed] == "all" + course_querys = @user.course_messages + forge_querys = @user.forge_messages + user_querys = @user.user_feedback_messages + forum_querys = @user.memo_messages + if User.current.id == @user.id + course_querys.update_all(:viewed => true) + forge_querys.update_all(:viewed => true) + user_querys.update_all(:viewed => true) + forum_querys.update_all(:viewed => true) + end + end # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count case params[:type] when nil @@ -540,6 +540,10 @@ class UsersController < ApplicationController # modified by fq def user_newfeedback + unless User.current.logged? + redirect_to signin_url + return + end # 更新用户留言消息状态 @user.journals_for_messages.each do |jour_message| jour_message.user_feedback_messages.each do |userfeedback_message| diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 1d288b4b8..c3c1a447b 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -29,7 +29,11 @@
    - +<% if params[:type].nil? %> +
    + 有 <%= User.current.count_new_message %> 条未读<%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %> +
    +<% end %> <% if @message_alls.count >0 %> <%# 课程消息 %> <% unless @message_alls.nil? %>