forked from e621ng/e621ng
[Docker] Add seeding for mascots
Will only work after deploy, because of the added field in the API response
This commit is contained in:
parent
0de7135df9
commit
cc2a395b37
@ -81,5 +81,9 @@ class Mascot < ApplicationRecord
|
||||
q.order("lower(artist_name)")
|
||||
end
|
||||
|
||||
def method_attributes
|
||||
super + [:url_path]
|
||||
end
|
||||
|
||||
include FileMethods
|
||||
end
|
||||
|
17
db/seeds.rb
17
db/seeds.rb
@ -73,8 +73,25 @@ def import_posts
|
||||
end
|
||||
end
|
||||
|
||||
def import_mascots
|
||||
api_request("/mascots.json").each do |mascot|
|
||||
puts mascot["url_path"]
|
||||
Mascot.create!(
|
||||
creator: CurrentUser.user,
|
||||
mascot_file: Downloads::File.new(mascot["url_path"]).download!,
|
||||
display_name: mascot["display_name"],
|
||||
background_color: mascot["background_color"],
|
||||
artist_url: mascot["artist_url"],
|
||||
artist_name: mascot["artist_name"],
|
||||
safe_mode_only: mascot["safe_mode_only"],
|
||||
active: mascot["active"],
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
unless Rails.env.test?
|
||||
CurrentUser.user = admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
import_posts
|
||||
import_mascots
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user