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/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 %> 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 4a0d2312a..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 => 20151014023806) do +ActiveRecord::Schema.define(:version => 20151020014759) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false 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 - a.is_public = false - end + 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