remove more scribd
Change-Id: Ia8a928a8447b878cab571ab400143e6145db194e Reviewed-on: https://gerrit.instructure.com/146535 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: Rob Orton <rob@instructure.com> QA-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
parent
1b813e5240
commit
25c2220268
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2013 - present Instructure, Inc.
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
|
@ -14,11 +14,21 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
class MoveScribdDocsToRootAttachments < ActiveRecord::Migration[4.2]
|
||||
class DropScribdMimeType < ActiveRecord::Migration[5.1]
|
||||
tag :postdeploy
|
||||
|
||||
def self.up
|
||||
DataFixup::MoveScribdDocsToRootAttachments.send_later_if_production_enqueue_args(:run, :priority => Delayed::LOW_PRIORITY, :max_attempts => 1)
|
||||
def up
|
||||
drop_table :scribd_mime_types
|
||||
end
|
||||
|
||||
def down
|
||||
create_table "scribd_mime_types" do |t|
|
||||
t.string :extension, limit: 255
|
||||
t.string :name, limit: 255
|
||||
t.timestamps
|
||||
end
|
||||
add_index :scribd_mime_types, :extension, name: 'index_scribd_mime_types_on_extension'
|
||||
end
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2013 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
module DataFixup::MoveScribdDocsToRootAttachments
|
||||
def self.run
|
||||
Shackles.activate(:slave) do
|
||||
Attachment.where("scribd_doc IS NOT NULL AND root_attachment_id IS NOT NULL").preload(:root_attachment).find_each do |a|
|
||||
ra = a.root_attachment
|
||||
# bad data!
|
||||
next unless ra
|
||||
|
||||
# if the root doesn't have a scribd doc, move it over
|
||||
if !ra.scribd_doc
|
||||
ra.scribd_doc = a.scribd_doc
|
||||
else
|
||||
# otherwise, this is a dup, and we need to delete it
|
||||
Scribd::API.instance.user = a.scribd_user
|
||||
begin
|
||||
a.scribd_doc.destroy
|
||||
rescue Scribd::ResponseError => e
|
||||
# does not exist
|
||||
raise unless e.code == '612'
|
||||
end
|
||||
end
|
||||
# clear the scribd doc off the child
|
||||
a.scribd_doc = nil
|
||||
a.scribd_attempts = 0
|
||||
a.workflow_state = 'deleted' # not file_state :P
|
||||
Shackles.activate(:master) do
|
||||
a.save!
|
||||
ra.save! if ra.changed?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,11 +10,6 @@ def create_notification(values = {})
|
|||
Canvas::MessageHelper.create_notification(values)
|
||||
end
|
||||
|
||||
def create_scribd_mime_type(ext, name)
|
||||
ping
|
||||
ScribdMimeType.where(extension: ext, name: name).first_or_create
|
||||
end
|
||||
|
||||
namespace :db do
|
||||
desc "Generate security.yml key"
|
||||
task :generate_security_key do
|
||||
|
@ -37,34 +32,6 @@ namespace :db do
|
|||
Rake::Task['db:load_environment'].invoke
|
||||
end
|
||||
|
||||
desc "Make sure all scribd mime types are set up correctly"
|
||||
task :ensure_scribd_mime_types => :load_environment do
|
||||
create_scribd_mime_type('doc', 'application/msword')
|
||||
create_scribd_mime_type('ppt', 'application/vnd.ms-powerpoint')
|
||||
create_scribd_mime_type('pdf', 'application/pdf')
|
||||
create_scribd_mime_type('xls', 'application/vnd.ms-excel')
|
||||
create_scribd_mime_type('ps', 'application/postscript')
|
||||
create_scribd_mime_type('rtf', 'application/rtf')
|
||||
create_scribd_mime_type('rtf', 'text/rtf')
|
||||
create_scribd_mime_type('docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
|
||||
create_scribd_mime_type('pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation')
|
||||
create_scribd_mime_type('xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
||||
create_scribd_mime_type('ppt', 'application/mspowerpoint')
|
||||
create_scribd_mime_type('xls', 'application/excel')
|
||||
create_scribd_mime_type('txt', 'text/plain')
|
||||
create_scribd_mime_type('odt', 'application/vnd.oasis.opendocument.text')
|
||||
create_scribd_mime_type('odp', 'application/vnd.oasis.opendocument.presentation')
|
||||
create_scribd_mime_type('ods', 'application/vnd.oasis.opendocument.spreadsheet')
|
||||
create_scribd_mime_type('sxw', 'application/vnd.sun.xml.writer')
|
||||
create_scribd_mime_type('sxi', 'application/vnd.sun.xml.impress')
|
||||
create_scribd_mime_type('sxc', 'application/vnd.sun.xml.calc')
|
||||
create_scribd_mime_type('xltx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template')
|
||||
create_scribd_mime_type('ppsx', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow')
|
||||
create_scribd_mime_type('potx', 'application/vnd.openxmlformats-officedocument.presentationml.template')
|
||||
create_scribd_mime_type('dotx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template')
|
||||
puts 'Scribd Mime Types added'
|
||||
end
|
||||
|
||||
desc "Make sure all message templates have notifications in the db"
|
||||
task :evaluate_notification_templates => :load_environment do
|
||||
Dir.glob(Rails.root.join('app', 'messages', '*.erb')) do |filename|
|
||||
|
@ -204,7 +171,7 @@ namespace :db do
|
|||
end
|
||||
|
||||
desc "generate data"
|
||||
task :generate_data => [:configure_default_settings, :load_notifications, :ensure_scribd_mime_types,
|
||||
task :generate_data => [:configure_default_settings, :load_notifications,
|
||||
:evaluate_notification_templates] do
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue