mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 23:20:44 +01:00
Add EmailDomainBlock.parents
scope (#31968)
This commit is contained in:
parent
6ae1fcd059
commit
697947116e
3 changed files with 6 additions and 4 deletions
|
@ -5,7 +5,7 @@ module Admin
|
||||||
def index
|
def index
|
||||||
authorize :email_domain_block, :index?
|
authorize :email_domain_block, :index?
|
||||||
|
|
||||||
@email_domain_blocks = EmailDomainBlock.where(parent_id: nil).includes(:children).order(id: :desc).page(params[:page])
|
@email_domain_blocks = EmailDomainBlock.parents.includes(:children).order(id: :desc).page(params[:page])
|
||||||
@form = Form::EmailDomainBlockBatch.new
|
@form = Form::EmailDomainBlockBatch.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ class EmailDomainBlock < ApplicationRecord
|
||||||
|
|
||||||
validates :domain, presence: true, uniqueness: true, domain: true
|
validates :domain, presence: true, uniqueness: true, domain: true
|
||||||
|
|
||||||
|
scope :parents, -> { where(parent_id: nil) }
|
||||||
|
|
||||||
# Used for adding multiple blocks at once
|
# Used for adding multiple blocks at once
|
||||||
attr_accessor :other_domains
|
attr_accessor :other_domains
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ module Mastodon::CLI
|
||||||
class EmailDomainBlocks < Base
|
class EmailDomainBlocks < Base
|
||||||
desc 'list', 'List blocked e-mail domains'
|
desc 'list', 'List blocked e-mail domains'
|
||||||
def list
|
def list
|
||||||
EmailDomainBlock.where(parent_id: nil).find_each do |entry|
|
EmailDomainBlock.parents.find_each do |parent|
|
||||||
say(entry.domain.to_s, :white)
|
say(parent.domain.to_s, :white)
|
||||||
|
|
||||||
shell.indent do
|
shell.indent do
|
||||||
EmailDomainBlock.where(parent_id: entry.id).find_each do |child|
|
EmailDomainBlock.where(parent_id: parent.id).find_each do |child|
|
||||||
say(child.domain, :cyan)
|
say(child.domain, :cyan)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue