From f8b45866336c097267261bc34c80bfb5afd1e4d5 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 1 Mar 2024 16:11:33 -0300 Subject: [PATCH] feat: poder cambiar el estado a varies actores --- .../actor_moderations_controller.rb | 18 +++++++++++++ .../components/_profiles_checked_submenu.haml | 6 ++--- app/views/moderation_queue/_account.haml | 2 +- app/views/moderation_queue/_accounts.haml | 26 ++++++++++--------- config/locales/en.yml | 4 +-- config/locales/es.yml | 8 +++--- config/routes.rb | 2 ++ 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/app/controllers/actor_moderations_controller.rb b/app/controllers/actor_moderations_controller.rb index 7450835b..907f21c6 100644 --- a/app/controllers/actor_moderations_controller.rb +++ b/app/controllers/actor_moderations_controller.rb @@ -20,6 +20,24 @@ class ActorModerationsController < ApplicationController @remote_profile = actor_moderation.actor.content end + def action_on_several + actor_moderations = site.actor_moderations.where(id: params[:actor_moderation]) + + authorize actor_moderations + + action = params[:actor_moderation_action].to_sym + method = :"#{action}!" + may = :"may_#{action}?" + + return unless ActorModeration.events.include? action + + ActorModeration.transaction do + actor_moderations.find_each do |actor_moderation| + actor_moderation.public_send(method) if actor_moderation.public_send(may) + end + end + end + private def actor_moderation diff --git a/app/views/components/_profiles_checked_submenu.haml b/app/views/components/_profiles_checked_submenu.haml index 8d8f8940..c0b99aa5 100644 --- a/app/views/components/_profiles_checked_submenu.haml +++ b/app/views/components/_profiles_checked_submenu.haml @@ -1,4 +1,2 @@ -= render 'components/dropdown_item', text: t('.submenu_pause'), path: '/' -= render 'components/dropdown_item', text: t('.submenu_accept'), path: '/' -= render 'components/dropdown_item', text: t('.submenu_reject'), path: '/' -= render 'components/dropdown_item', text: t('.submenu_block'), path: '/' +- ActorModeration.events.each do |actor_event| + = render 'components/dropdown_button', text: t(".submenu_#{actor_event}"), name: 'actor_moderation_action', value: actor_event diff --git a/app/views/moderation_queue/_account.haml b/app/views/moderation_queue/_account.haml index 5e574c71..e891b4ad 100644 --- a/app/views/moderation_queue/_account.haml +++ b/app/views/moderation_queue/_account.haml @@ -1,6 +1,6 @@ .row.no-gutters.pt-2 .col-1 - = render 'components/checkbox', id: profile['id'], name: 'actor[]', value: profile['id'], data: { target: 'select-all.input' } + = render 'components/checkbox', id: actor_moderation.id, name: 'actor_moderation[]', value: actor_moderation.id, data: { target: 'select-all.input' } .col-11 %h4 = link_to sanitize(profile['name']), site_actor_moderation_path(id: actor_moderation) diff --git a/app/views/moderation_queue/_accounts.haml b/app/views/moderation_queue/_accounts.haml index c7dba0a1..35b0b86e 100644 --- a/app/views/moderation_queue/_accounts.haml +++ b/app/views/moderation_queue/_accounts.haml @@ -1,12 +1,14 @@ -.row.no-gutters.pt-2{ data: { controller: 'select-all' } } - .col-1.d-flex.align-items-center - = render 'components/select_all', id: 'actors' - .col-11 - -# Filtros - = render 'components/profiles_filters', actor_moderations: actor_moderations - .col-12 - - if actor_moderations.count.zero? - %h4= t('moderation_queue.nothing') - - actor_moderations.find_each do |actor_moderation| - %hr - = render 'account', actor_moderation: actor_moderation, profile: actor_moderation.actor.content +%form{ action: site_actor_moderations_action_on_several_path, method: :post } + .row.no-gutters.pt-2{ data: { controller: 'select-all' } } + .col-1.d-flex.align-items-center + = render 'components/select_all', id: 'actors' + .col-11 + -# Filtros + = render 'components/profiles_filters', actor_moderations: actor_moderations + .col-12 + - if actor_moderations.count.zero? + %h4= t('moderation_queue.nothing') + - actor_moderations.find_each do |actor_moderation| + - cache [actor_moderation, actor_moderation.actor] do + %hr + = render 'account', actor_moderation: actor_moderation, profile: actor_moderation.actor.content diff --git a/config/locales/en.yml b/config/locales/en.yml index 4aea89f7..6d5baf5a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -81,9 +81,9 @@ en: text_checked: With selected profiles_checked_submenu: submenu_pause: Pause - submenu_accept: Accept - submenu_reject: Reject + submenu_allow: Allow submenu_block: Block + submenu_report: Report profiles_show_submenu: submenu_paused: "Paused (%{count})" submenu_allowed: "Allowed (%{count})" diff --git a/config/locales/es.yml b/config/locales/es.yml index 7b033859..13534822 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -80,10 +80,10 @@ es: text_show: Ver text_checked: Con los marcados profiles_checked_submenu: - submenu_pause: Pausado - submenu_accept: Aceptado - submenu_reject: Rechazado - submenu_block: Bloqueado + submenu_pause: Pausar + submenu_allow: Aceptar + submenu_block: Bloquear + submenu_report: Reportar profiles_show_submenu: submenu_paused: "Pausadas (%{count})" submenu_allowed: "Permitidas (%{count})" diff --git a/config/routes.rb b/config/routes.rb index 32936d42..9d825a3c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -80,6 +80,8 @@ Rails.application.routes.draw do end end + patch :actor_moderations_action_on_several, to: 'actor_moderations#action_on_several' + # Gestionar artĂ­culos segĂșn idioma nested do scope '/(:locale)', constraint: /[a-z]{2}(-[A-Z]{2})?/ do