0
0
Fork 0

Add option to overwrite imported data (#9962)

* Add option to overwrite imported data

Fix #7465

* Add import for domain blocks
This commit is contained in:
Eugen Rochko 2019-02-03 03:59:51 +01:00 committed by GitHub
parent c5071f2d78
commit d14c276e58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 43 deletions

View file

@ -13,20 +13,30 @@
# data_file_size :integer
# data_updated_at :datetime
# account_id :bigint(8) not null
# overwrite :boolean default(FALSE), not null
#
class Import < ApplicationRecord
FILE_TYPES = ['text/plain', 'text/csv'].freeze
FILE_TYPES = %w(text/plain text/csv).freeze
MODES = %i(merge overwrite).freeze
self.inheritance_column = false
belongs_to :account
enum type: [:following, :blocking, :muting]
enum type: [:following, :blocking, :muting, :domain_blocking]
validates :type, presence: true
has_attached_file :data
validates_attachment_content_type :data, content_type: FILE_TYPES
validates_attachment_presence :data
def mode
overwrite? ? :overwrite : :merge
end
def mode=(str)
self.overwrite = str.to_sym == :overwrite
end
end