forked from e621ng/e621ng
[Mascots] More granular control on which site they appear
Previously it was only possible to exclude them from e9. This allows mascots exclusive to e6 as well.
This commit is contained in:
parent
a24bfeed69
commit
b58707fab2
@ -38,6 +38,6 @@ class MascotsController < ApplicationController
|
||||
private
|
||||
|
||||
def mascot_params
|
||||
params.fetch(:mascot, {}).permit(%i[mascot_file display_name background_color artist_url artist_name safe_mode_only active])
|
||||
params.fetch(:mascot, {}).permit(%i[mascot_file display_name background_color artist_url artist_name available_on_string active])
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
class Mascot < ApplicationRecord
|
||||
belongs_to_creator
|
||||
|
||||
array_attribute :available_on
|
||||
attr_accessor :mascot_file
|
||||
|
||||
validates :display_name, :background_color, :artist_url, :artist_name, presence: true
|
||||
@ -33,8 +34,7 @@ class Mascot < ApplicationRecord
|
||||
|
||||
def self.active_for_browser
|
||||
Cache.fetch("active_mascots", 1.day) do
|
||||
query = Mascot.where(active: true)
|
||||
query = query.where(safe_mode_only: false) if !Danbooru.config.safe_mode?
|
||||
query = Mascot.where(active: true).where("? = ANY(available_on)", Danbooru.config.app_name)
|
||||
mascots = query.map do |mascot|
|
||||
mascot.slice(:id, :background_color, :artist_url, :artist_name).merge(background_url: mascot.url_path)
|
||||
end
|
||||
|
@ -5,7 +5,7 @@
|
||||
<%= f.input :background_color %>
|
||||
<%= f.input :artist_url %>
|
||||
<%= f.input :artist_name %>
|
||||
<%= f.input :safe_mode_only, label: "E9 Only" %>
|
||||
<%= f.input :available_on_string, label: "Available on" %>
|
||||
<%= f.input :active %>
|
||||
<%= f.submit %>
|
||||
<% end %>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<th>Artist Name</th>
|
||||
<th>Artist URL</th>
|
||||
<th>Active</th>
|
||||
<th>E9 Only</th>
|
||||
<th>Available on</th>
|
||||
<th>Created</th>
|
||||
<% if CurrentUser.user.is_admin? %>
|
||||
<th></th>
|
||||
@ -25,7 +25,7 @@
|
||||
<td><%= mascot.artist_name %></td>
|
||||
<td><%= mascot.artist_url %></td>
|
||||
<td><%= mascot.active %></td>
|
||||
<td><%= mascot.safe_mode_only %></td>
|
||||
<td><%= mascot.available_on_string %></td>
|
||||
<td><%= compact_time mascot.created_at %></td>
|
||||
<% if CurrentUser.user.is_admin? %>
|
||||
<td>
|
||||
|
5
db/migrate/20230203162010_mascots_add_available_on.rb
Normal file
5
db/migrate/20230203162010_mascots_add_available_on.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class MascotsAddAvailableOn < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :mascots, :available_on, :string, array: true, null: false, default: []
|
||||
end
|
||||
end
|
@ -1036,7 +1036,8 @@ CREATE TABLE public.mascots (
|
||||
safe_mode_only boolean DEFAULT false NOT NULL,
|
||||
active boolean DEFAULT true NOT NULL,
|
||||
created_at timestamp(6) without time zone NOT NULL,
|
||||
updated_at timestamp(6) without time zone NOT NULL
|
||||
updated_at timestamp(6) without time zone NOT NULL,
|
||||
available_on character varying[] DEFAULT '{}'::character varying[] NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@ -4797,6 +4798,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20220516103329'),
|
||||
('20220710133556'),
|
||||
('20220810131625'),
|
||||
('20221014085948');
|
||||
('20221014085948'),
|
||||
('20230203162010');
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user