From b7989808655e29cfad5db4d04755b28194108a88 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Mar 2024 15:13:01 -0300 Subject: [PATCH] feat: acciones masivas para comentarios --- app/controllers/activity_pubs_controller.rb | 16 ++++++++++++++++ config/locales/en.yml | 3 ++- config/locales/es.yml | 7 ++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/controllers/activity_pubs_controller.rb b/app/controllers/activity_pubs_controller.rb index 057e65f7..9bbbb9cc 100644 --- a/app/controllers/activity_pubs_controller.rb +++ b/app/controllers/activity_pubs_controller.rb @@ -15,7 +15,23 @@ class ActivityPubsController < ApplicationController end def action_on_several + activity_pubs = site.activity_pubs.where(id: params[:activity_pub]) + + authorize activity_pubs + + action = params[:activity_pub_action].to_sym + method = :"#{action}!" + may = :"may_#{action}?" + redirect_to_moderation_queue! + + return unless ActivityPub.events.include? action + + ActivityPub.transaction do + activity_pubs.find_each do |activity_pub| + activity_pub.public_send(method) if activity_pub.public_send(may) + end + end end private diff --git a/config/locales/en.yml b/config/locales/en.yml index eecd5ebd..a10b9f3a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -69,8 +69,9 @@ en: text_checked: With selected comments_checked_submenu: submenu_pause: Pause - submenu_accept: Accept + submenu_approve: Approve submenu_reject: Reject + submenu_report: Report comments_show_submenu: submenu_paused: "Paused (%{count})" submenu_approved: "Approved (%{count})" diff --git a/config/locales/es.yml b/config/locales/es.yml index 0f9eb68a..f5487e47 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -68,9 +68,10 @@ es: text_show: Ver text_checked: Con los marcados comments_checked_submenu: - submenu_pause: Pausado - submenu_accept: Aceptado - submenu_reject: Rechazado + submenu_pause: Pausar + submenu_approve: Aprobar + submenu_reject: Rechazar + submenu_report: Reportar comments_show_submenu: submenu_paused: "Pausados (%{count})" submenu_approved: "Aprobados (%{count})"