mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-25 23:46:22 +00:00
feat: filtros comunes
This commit is contained in:
parent
2df9f721cd
commit
0da69de6a7
10 changed files with 30 additions and 13 deletions
|
@ -3,6 +3,7 @@
|
||||||
# Gestiona la cola de moderación de actores
|
# Gestiona la cola de moderación de actores
|
||||||
class ActorModerationsController < ApplicationController
|
class ActorModerationsController < ApplicationController
|
||||||
include ModerationConcern
|
include ModerationConcern
|
||||||
|
include ModerationFiltersConcern
|
||||||
|
|
||||||
ActorModeration.events.each do |actor_event|
|
ActorModeration.events.each do |actor_event|
|
||||||
define_method(actor_event) do
|
define_method(actor_event) do
|
||||||
|
@ -20,7 +21,7 @@ class ActorModerationsController < ApplicationController
|
||||||
# Ver el perfil remoto
|
# Ver el perfil remoto
|
||||||
def show
|
def show
|
||||||
@remote_profile = actor_moderation.actor.content
|
@remote_profile = actor_moderation.actor.content
|
||||||
@moderation_queue = site.activity_pubs.where(actor_id: actor_moderation.actor_id)
|
@moderation_queue = rubanok_process(site.activity_pubs.where(actor_id: actor_moderation.actor_id), with: ActivityPubProcessor)
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_on_several
|
def action_on_several
|
||||||
|
|
15
app/controllers/concerns/moderation_filters_concern.rb
Normal file
15
app/controllers/concerns/moderation_filters_concern.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module ModerationFiltersConcern
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
before_action :store_filters_in_session!, only: %i[index show]
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def store_filters_in_session!
|
||||||
|
session[:moderation_queue_filters] = params.permit(:instance_state, :actor_state, :activity_pub_state)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Cola de moderación de ActivityPub
|
# Cola de moderación de ActivityPub
|
||||||
class ModerationQueueController < ApplicationController
|
class ModerationQueueController < ApplicationController
|
||||||
|
include ModerationFiltersConcern
|
||||||
|
|
||||||
# Cola de moderación viendo todo el sitio
|
# Cola de moderación viendo todo el sitio
|
||||||
def index
|
def index
|
||||||
session[:moderation_queue_filters] = params.permit(:state, :actor_state, :activity_pub_state)
|
|
||||||
|
|
||||||
# @todo cambiar el estado por query
|
# @todo cambiar el estado por query
|
||||||
@activity_pubs = site.activity_pubs
|
@activity_pubs = site.activity_pubs
|
||||||
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)
|
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)
|
||||||
|
|
|
@ -6,7 +6,7 @@ class InstanceModerationProcessor < Rubanok::Processor
|
||||||
raw.includes(:instance).order('activity_pub_instances.hostname')
|
raw.includes(:instance).order('activity_pub_instances.hostname')
|
||||||
end
|
end
|
||||||
|
|
||||||
map :state, activate_always: true do |state: 'paused'|
|
map :instance_state, activate_always: true do |instance_state: 'paused'|
|
||||||
raw.where(aasm_state: state)
|
raw.where(aasm_state: instance_state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
- ActivityPub.states.each do |state|
|
- ActivityPub.states.each do |state|
|
||||||
= render 'components/dropdown_item',
|
= render 'components/dropdown_item',
|
||||||
text: t(".submenu_#{state}", count: activity_pubs.unscope(where: :aasm_state).public_send(state).count),
|
text: t(".submenu_#{state}", count: activity_pubs.unscope(where: :aasm_state).public_send(state).count),
|
||||||
path: site_moderation_queue_path(filter_states(activity_pub_state: state))
|
path: filter_states(activity_pub_state: state)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-#
|
-#
|
||||||
@param :text [String] Contenido del link
|
@param :text [String] Contenido del link
|
||||||
@param :path [String] Link
|
@param :path [String,Hash] Link
|
||||||
= link_to text, path, class: 'dropdown-item', data: { target: 'dropdown.item' }
|
= link_to text, path, class: 'dropdown-item', data: { target: 'dropdown.item' }
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
= render 'components/instances_checked_submenu', form_id: form_id, current_state: current_state
|
= render 'components/instances_checked_submenu', form_id: form_id, current_state: current_state
|
||||||
|
|
||||||
= render 'components/dropdown', text: t('.text_show') do
|
= render 'components/dropdown', text: t('.text_show') do
|
||||||
= render 'components/instances_show_submenu', site: site
|
= render 'components/instances_show_submenu', instance_moderations: instance_moderations
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
= render 'components/dropdown_item', text: t('.submenu_paused', count: site.instance_moderations.paused.count), path: site_moderation_queue_path(state: 'paused')
|
- InstanceModeration.states.each do |state|
|
||||||
= render 'components/dropdown_item', text: t('.submenu_allowed', count: site.instance_moderations.allowed.count), path: site_moderation_queue_path(state: 'allowed')
|
= render 'components/dropdown_item',
|
||||||
= render 'components/dropdown_item', text: t('.submenu_blocked', count: site.instance_moderations.blocked.count), path: site_moderation_queue_path(state: 'blocked')
|
text: t(".submenu_#{state}", count: instance_moderations.unscope(where: :aasm_state).public_send(state).count),
|
||||||
|
path: filter_states(instance_state: state)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
- ActorModeration.states.each do |actor_state|
|
- ActorModeration.states.each do |actor_state|
|
||||||
= render 'components/dropdown_item',
|
= render 'components/dropdown_item',
|
||||||
text: t(".submenu_#{actor_state}", count: actor_moderations.unscope(where: :aasm_state).public_send(actor_state).count),
|
text: t(".submenu_#{actor_state}", count: actor_moderations.unscope(where: :aasm_state).public_send(actor_state).count),
|
||||||
path: site_moderation_queue_path(filter_states(actor_state: actor_state))
|
path: filter_states(actor_state: actor_state)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
= render 'components/select_all', id: 'instances', form_id: form_id
|
= render 'components/select_all', id: 'instances', form_id: form_id
|
||||||
.col-11
|
.col-11
|
||||||
-# Filtros
|
-# Filtros
|
||||||
= render 'components/instances_filters', site: site, form_id: form_id
|
= render 'components/instances_filters', instance_moderations: instance_moderations, form_id: form_id
|
||||||
|
|
||||||
.col-12
|
.col-12
|
||||||
- if instance_moderations.count.zero?
|
- if instance_moderations.count.zero?
|
||||||
|
|
Loading…
Reference in a new issue