From 41aa81f9660ad5bc8c0e50ac1d5fa287166e9801 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 18 Apr 2016 14:44:29 +0800 Subject: [PATCH 1/7] =?UTF-8?q?rake=20=E4=BB=BB=E5=8A=A1=EF=BC=9A=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=96=87=E4=BB=B6=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_files.rake | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/tasks/sync_files.rake diff --git a/lib/tasks/sync_files.rake b/lib/tasks/sync_files.rake new file mode 100644 index 000000000..5c9326356 --- /dev/null +++ b/lib/tasks/sync_files.rake @@ -0,0 +1,38 @@ +require 'trustie/gitlab/sync' + +namespace :trustie do + namespace :files do + desc "sync course'file" + task :course => :environment do + # Course.all.each do |course| + # unless course.attachments.count.to_i == 0 + # attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and container_type ='Course'").count + # project_score = ProjectScore.where("project_id=?", project.id).first + # if project_score.nil? + # ProjectScore.create(:project_id => project.id, :attach_num => 0) + # else + # project_score.attach_num = attachment_count + # project_score.save + # end + # end + # end + end + + desc "sync project'file" + task :project => :environment do + Project.all.each do |project| + unless project.attachments.count.to_i == 0 + attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{project.id} and container_type ='Project'").count + project_score = ProjectScore.where("project_id=?", project.id).first + if project_score.nil? + ProjectScore.create(:project_id => project.id, :attach_num => 0) + else + project_score.attach_num = attachment_count + project_score.save + end + end + end + end + + end +end From 8064fe6c46fff52bc7db9b214eb30127344e475d Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 18 Apr 2016 15:37:32 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=B8=96=E5=AD=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 49 +++++++++++++------------------ app/models/message.rb | 14 ++++----- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 366cea06b..9572034aa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -120,59 +120,52 @@ module ApplicationHelper case type when "HomeworkCommon" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :homework_journal_num => 1) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :homework_journal_num => 1) else - score = course_contributor_score.homework_journal_num + 1 + score = course_contributor_score.homework_journal_num.to_i + 1 course_contributor_score.update_attributes(:homework_journal_num => score) end # 课程留言 when "Course" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :journal_num => 1) else - score = course_contributor_score.journal_num + 1 + score = course_contributor_score.journal_num.to_i + 1 course_contributor_score.update_attributes(:journal_num => score) end when "Message" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1, :message_reply_num => 0, - :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1) else - score = course_contributor_score.message_num + 1 + score = course_contributor_score.message_num.to_i + 1 course_contributor_score.update_attributes(:message_num => score) end when "MessageReply" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 1, - :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_reply_num => 1) else - score = course_contributor_score.message_reply_num + 1 + score = course_contributor_score.message_reply_num.to_i + 1 course_contributor_score.update_attributes(:message_reply_num => score) end when "NewReply" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_reply_num => 1) else - score = course_contributor_score.news_reply_num + 1 + score = course_contributor_score.news_reply_num.to_i + 1 course_contributor_score.update_attributes(:news_reply_num => score) end when "News" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :news_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_num => 1) else - score = course_contributor_score.news_num + 1 + score = course_contributor_score.news_num.to_i + 1 course_contributor_score.update_attributes(:news_num => score) end when "Attachment" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :news_num => 0, :resource_num => 1, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :resource_num => 1) else - score = course_contributor_score.resource_num + 1 + score = course_contributor_score.resource_num.to_i + 1 course_contributor_score.update_attributes(:resource_num => score) end end @@ -184,38 +177,38 @@ module ApplicationHelper case type when "HomeworkCommon" unless course_contributor_score.nil? - score = course_contributor_score.homework_journal_num - 1 + score = course_contributor_score.homework_journal_num.to_i - 1 course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score) end # 课程留言 when "Course" unless course_contributor_score.nil? - score = course_contributor_score.journal_num - 1 + score = course_contributor_score.journal_num.to_i - 1 course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score) end when "Message" unless course_contributor_score.nil? - score = course_contributor_score.message_num - 1 + score = course_contributor_score.message_num.to_i - 1 course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score) end when "MessageReply" unless course_contributor_score.nil? - score = course_contributor_score.message_reply_num - 1 + score = course_contributor_score.message_reply_num.to_i - 1 course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score) end when "NewReply" unless course_contributor_score.nil? - score = course_contributor_score.news_reply_num - 1 + score = course_contributor_score.news_reply_num.to_i - 1 course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score) end when "News" unless course_contributor_score.nil? - score = course_contributor_score.news_num - 1 + score = course_contributor_score.news_num.to_i - 1 course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score) end when "Attachment" unless course_contributor_score.nil? - score = course_contributor_score.resource_num - 1 + score = course_contributor_score.resource_num.to_i - 1 course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score) end end diff --git a/app/models/message.rb b/app/models/message.rb index d697db236..f5df220a0 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -77,12 +77,10 @@ class Message < ActiveRecord::Base validates_length_of :subject, :maximum => 255 validate :cannot_reply_to_locked_topic, :on => :create - after_create :add_author_as_watcher, :reset_counters!, :add_boards_count + # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - - after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, - :act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id) + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count #before_save :be_user_score scope :visible, lambda {|*args| @@ -134,11 +132,11 @@ class Message < ActiveRecord::Base if self.project && !project.project_score.nil? # 讨论区 if self.parent_id.nil? - count = self.project.project_score.board_num + 1 - self.project.project_score.update_attribute(:board_num, count) + count = self.project.project_score.board_num.to_i + 1 + self.project.project_score.update_column(:board_num, count) else # 回复 - count = self.project.project_score.board_message_num + 1 - self.project.project_score.update_attribute(:board_message_num, count) + count = self.project.project_score.board_message_num.to_i + 1 + self.project.project_score.update_column(:board_message_num, count) end end end From a907089bd04bf14e0c9b07b5e5bb81d39644870f Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Apr 2016 10:41:48 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=AF=E4=BB=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 754bd4dee..55d76ffeb 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -362,7 +362,8 @@ class Attachment < ActiveRecord::Base #有了历史记录的数据记录是不能被删除的。 #true 能被删除 false 不能被删除 def destroyable - self.attachment_histories.count == 0 + true + # self.attachment_histories.count == 0 end # Returns file's location on disk From ade19af9f26008ccbaf20acde35f73d20c61f017 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Apr 2016 10:55:17 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E8=83=BD=E4=B8=8B=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1dacffb6f..fe3c3272a 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -660,8 +660,8 @@ class AttachmentsController < ApplicationController end def has_login - unless @attachment && @attachment.container_type == "Organization" - unless @attachment && @attachment.container_type == "PhoneAppVersion" + unless (@attachment && @attachment.container_type == "Organization").nil? + unless (@attachment && @attachment.container_type == "PhoneAppVersion").nil? render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) end end From 43f5f821d5e98875875d0c3ce05d1ee98720579d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Apr 2016 11:10:58 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9C=AA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=94=A8=E6=88=B7=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_org_subfield_list.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index 722024a85..ad3ce7a3e 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -43,8 +43,8 @@
    + <% if User.current.logged? %>
  • - <% if User.current.logged? %> <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" %>
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • @@ -66,8 +66,8 @@
    • <%= link_to("发  送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    <% end %> - <% end %>
  • + <% end %>
From b1f47fe1200a5a238fc68618ee65d834c4360569 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Apr 2016 11:19:29 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=88=A0=E9=99=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 55d76ffeb..754bd4dee 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -362,8 +362,7 @@ class Attachment < ActiveRecord::Base #有了历史记录的数据记录是不能被删除的。 #true 能被删除 false 不能被删除 def destroyable - true - # self.attachment_histories.count == 0 + self.attachment_histories.count == 0 end # Returns file's location on disk From 1ded6ddf0485e2be000bd9f48bc7c407e246d29b Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 19 Apr 2016 13:03:12 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=B7=B2=E6=8F=90=E4=BA=A4=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_programing_work_show.html.erb | 2 +- app/views/users/new_user_commit_homework.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index becec239a..eb16dc807 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -69,7 +69,7 @@
<%=x["result"].force_encoding("UTF-8")%> 
正确输出: -
<%=x["output"]%>
+
<%=x["output"].force_encoding("UTF-8")%>
耗时:
<%=x["time_used"]==0?1:x["time_used"]%>毫秒
diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index e84b7a95e..1f8d3ca26 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -143,9 +143,9 @@ 测试错误! <% end %> 您的输出: -
<%=x["result"]%> 
+
<%=x["result"].force_encoding("UTF-8")%> 
正确输出: -
<%= x["output"] %>
+
<%= x["output"].force_encoding("UTF-8") %>
 耗时:
<%=x["time_used"]==0?1:x["time_used"]%>毫秒