forked from e621ng/e621ng
[Mascots] Add option to restrict to e926
This commit is contained in:
parent
b5fbc1e2eb
commit
c46e1f5fd9
@ -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 active])
|
||||
params.fetch(:mascot, {}).permit(%i[mascot_file display_name background_color artist_url artist_name safe_mode_only active])
|
||||
end
|
||||
end
|
||||
|
@ -33,7 +33,9 @@ class Mascot < ApplicationRecord
|
||||
|
||||
def self.active_for_browser
|
||||
Cache.get("active_mascots", 1.day) do
|
||||
mascots = Mascot.where(active: true).map do |mascot|
|
||||
query = Mascot.where(active: true)
|
||||
query = query.where(safe_mode_only: false) if !Danbooru.config.safe_mode?
|
||||
mascots = query.map do |mascot|
|
||||
mascot.slice(:id, :background_color, :artist_url, :artist_name).merge(background_url: mascot.url_path)
|
||||
end
|
||||
mascots.index_by { |mascot| mascot["id"] }
|
||||
|
@ -5,6 +5,7 @@
|
||||
<%= f.input :background_color %>
|
||||
<%= f.input :artist_url %>
|
||||
<%= f.input :artist_name %>
|
||||
<%= f.input :safe_mode_only, label: "E9 Only" %>
|
||||
<%= f.input :active %>
|
||||
<%= f.submit %>
|
||||
<% end %>
|
||||
|
@ -10,6 +10,7 @@
|
||||
<th>Artist Name</th>
|
||||
<th>Artist URL</th>
|
||||
<th>Active</th>
|
||||
<th>E9 Only</th>
|
||||
<th>Created</th>
|
||||
<% if CurrentUser.user.is_admin? %>
|
||||
<th></th>
|
||||
@ -24,6 +25,7 @@
|
||||
<td><%= mascot.artist_name %></td>
|
||||
<td><%= mascot.artist_url %></td>
|
||||
<td><%= mascot.active %></td>
|
||||
<td><%= mascot.safe_mode_only %></td>
|
||||
<td><%= compact_time mascot.created_at %></td>
|
||||
<% if CurrentUser.user.is_admin? %>
|
||||
<td>
|
||||
|
@ -8,6 +8,7 @@ class AddMascotTable < ActiveRecord::Migration[6.1]
|
||||
t.string :background_color, null: false
|
||||
t.string :artist_url, null: false
|
||||
t.string :artist_name, null: false
|
||||
t.boolean :safe_mode_only, default: false, null: false
|
||||
t.boolean :active, default: true, null: false
|
||||
t.timestamps
|
||||
end
|
||||
|
@ -1047,6 +1047,7 @@ CREATE TABLE public.mascots (
|
||||
background_color character varying NOT NULL,
|
||||
artist_url character varying NOT NULL,
|
||||
artist_name character varying NOT NULL,
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user