From 0b565b1be00a6bff64e1f69e0b625fd1aa61545f Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 19 Oct 2015 17:34:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=A7=81=E6=9C=89=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E4=BB=B6=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20151019085603_update_attachments.rb | 23 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20151019085603_update_attachments.rb diff --git a/db/migrate/20151019085603_update_attachments.rb b/db/migrate/20151019085603_update_attachments.rb new file mode 100644 index 000000000..bd3ec2325 --- /dev/null +++ b/db/migrate/20151019085603_update_attachments.rb @@ -0,0 +1,23 @@ +class UpdateAttachments < ActiveRecord::Migration + def up + count = Attachment.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + Attachment.page(i).per(30).each do |attachment| + if attachment.container_type == 'Course' + course = attachment.course + if course + if course.is_public == 0 && attachment.attachtype == 1 + attachment.is_public = 0 + attachment.save + end + end + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 4a0d2312a..44548ad9c 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 => 20151014023806) do +ActiveRecord::Schema.define(:version => 20151019085603) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From ce4da2e4af1cbfdca1d3f3698493f4d266a66acd Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Oct 2015 18:38:27 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/upload.js.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 2420b2a6e..970c5b22d 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -11,5 +11,4 @@ fileSpan.find('a.remove-upload') }) .off('click'); $('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); -console.log(fileSpan.html()) <% end %> From dbbdae1be24c5e310765a57cb2de7b1ad4a26c27 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 20 Oct 2015 09:24:50 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=99=84=E4=BB=B6=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20151019085603_update_attachments.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20151019085603_update_attachments.rb b/db/migrate/20151019085603_update_attachments.rb index bd3ec2325..afb63a277 100644 --- a/db/migrate/20151019085603_update_attachments.rb +++ b/db/migrate/20151019085603_update_attachments.rb @@ -7,7 +7,7 @@ class UpdateAttachments < ActiveRecord::Migration if attachment.container_type == 'Course' course = attachment.course if course - if course.is_public == 0 && attachment.attachtype == 1 + if course.is_public == 0 attachment.is_public = 0 attachment.save end From 1cfa8326aa8b71d2a6102896da6b8366b9c4faf7 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 09:43:22 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A500=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 | 7 +------ .../lib/acts_as_attachable.rb | 18 +++++++----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0f728fc00..f7fb9b1aa 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -442,12 +442,7 @@ class Attachment < ActiveRecord::Base def self.attach_filesex(obj, attachments,attachment_type) - if obj.is_public? - public_status = true - else - public_status = false - end - result = obj.save_attachmentsex(attachments, User.current,attachment_type, public_status) + result = obj.save_attachmentsex(attachments, User.current,attachment_type) obj.attach_saved_attachments result end diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 9378013f9..682714b9b 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -93,13 +93,13 @@ module Redmine end end - def save_attachmentsex(attachments, author=User.current,attachment_type, public_status) + def save_attachmentsex(attachments, author=User.current,attachment_type) @curattachment_type = attachment_type - result = save_attachments(attachments,author, public_status) + result = save_attachments(attachments,author) result end - def save_attachments(attachments, author=User.current,public_status) + def save_attachments(attachments, author=User.current) # 清除临时文件 if attachments tempAttach = attachments[:dummy] @@ -140,16 +140,12 @@ module Redmine end end end - if public_status - if a && !attachment['is_public_checkbox'] - a.is_public = false - elsif a && attachment['is_public_checkbox'] - a.is_public = true - end - else + + if a && !attachment['is_public_checkbox'] a.is_public = false + elsif a && attachment['is_public_checkbox'] + a.is_public = true end - set_attachment_public(a) if a next unless a a.description = attachment['description'].to_s.strip From 90ee4bbe6061ec5c94b25af839329d3e4d60fcdb Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 20 Oct 2015 09:55:51 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20151019085603_update_attachments.rb | 23 ------------------- .../20151020013352_update_attachment.rb | 23 +++++++++++++++++++ ...51020014759_delete_null_course_activity.rb | 17 ++++++++++++++ db/schema.rb | 2 +- 4 files changed, 41 insertions(+), 24 deletions(-) delete mode 100644 db/migrate/20151019085603_update_attachments.rb create mode 100644 db/migrate/20151020013352_update_attachment.rb create mode 100644 db/migrate/20151020014759_delete_null_course_activity.rb diff --git a/db/migrate/20151019085603_update_attachments.rb b/db/migrate/20151019085603_update_attachments.rb deleted file mode 100644 index afb63a277..000000000 --- a/db/migrate/20151019085603_update_attachments.rb +++ /dev/null @@ -1,23 +0,0 @@ -class UpdateAttachments < ActiveRecord::Migration - def up - count = Attachment.all.count / 30 + 2 - transaction do - for i in 1 ... count do i - Attachment.page(i).per(30).each do |attachment| - if attachment.container_type == 'Course' - course = attachment.course - if course - if course.is_public == 0 - attachment.is_public = 0 - attachment.save - end - end - end - end - end - end - end - - def down - end -end diff --git a/db/migrate/20151020013352_update_attachment.rb b/db/migrate/20151020013352_update_attachment.rb new file mode 100644 index 000000000..3e1161c09 --- /dev/null +++ b/db/migrate/20151020013352_update_attachment.rb @@ -0,0 +1,23 @@ +class UpdateAttachment < ActiveRecord::Migration + def up + count = Attachment.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + Attachment.page(i).per(30).each do |attachment| + if attachment.container_type == 'Course' + course = attachment.course + if course + if course.is_public == 0 + attachment.is_public = 0 + attachment.save + end + end + end + end + end + end + end + + def down + end +end diff --git a/db/migrate/20151020014759_delete_null_course_activity.rb b/db/migrate/20151020014759_delete_null_course_activity.rb new file mode 100644 index 000000000..0d7b11693 --- /dev/null +++ b/db/migrate/20151020014759_delete_null_course_activity.rb @@ -0,0 +1,17 @@ +class DeleteNullCourseActivity < ActiveRecord::Migration + def up + count = CourseActivity.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + CourseActivity.page(i).per(30).each do |activity| + unless activity.course_act + activity.destroy + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 44548ad9c..41efc5698 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 => 20151019085603) do +ActiveRecord::Schema.define(:version => 20151020014759) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false