mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 13:56:22 +00:00
fix: poder ir a la cola de moderación
This commit is contained in:
parent
e05a8aafda
commit
2aa2b9f3bb
8 changed files with 103 additions and 44 deletions
|
@ -32,6 +32,22 @@ $sizes: (
|
|||
@import "bootstrap";
|
||||
@import "editor";
|
||||
|
||||
@each $color, $rgb in $theme-colors {
|
||||
.#{$color} {
|
||||
color: var(--#{$color});
|
||||
|
||||
&:focus {
|
||||
color: var(--#{$color});
|
||||
}
|
||||
|
||||
::-moz-selection,
|
||||
::selection {
|
||||
background: var(--#{$color});
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.editor {
|
||||
.editor-content {
|
||||
figure {
|
||||
|
|
|
@ -11,9 +11,12 @@ class ModerationQueueController < ApplicationController
|
|||
|
||||
# Cola de moderación viendo todo el sitio
|
||||
def index
|
||||
authorize ModerationQueue.new(site)
|
||||
breadcrumb site.title, site_posts_path(site)
|
||||
breadcrumb I18n.t('moderation_queue.index.title'), ''
|
||||
|
||||
site.moderation_checked!
|
||||
|
||||
# @todo cambiar el estado por query
|
||||
@activity_pubs = site.activity_pubs
|
||||
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)
|
||||
|
|
3
app/models/moderation_queue.rb
Normal file
3
app/models/moderation_queue.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
ModerationQueue = Struct.new(:site)
|
|
@ -19,6 +19,29 @@ class Site
|
|||
|
||||
before_save :generate_private_key_pem!, unless: :private_key_pem?
|
||||
|
||||
def moderation_enabled?
|
||||
deploy_social_inbox.present?
|
||||
end
|
||||
|
||||
def deploy_social_inbox
|
||||
@deploy_social_inbox ||= deploys.find_by(type: 'DeploySocialDistributedPress')
|
||||
end
|
||||
|
||||
def moderation_checked!
|
||||
deploy_social_inbox.touch
|
||||
end
|
||||
|
||||
# @return [Bool]
|
||||
def moderation_needed?
|
||||
return false unless moderation_enabled?
|
||||
|
||||
last_activity_pub = activity_pubs.order(updated_at: :desc).first&.updated_at
|
||||
|
||||
return false if last_activity_pub.blank?
|
||||
|
||||
last_activity_pub > deploy_social_inbox.updated_at
|
||||
end
|
||||
|
||||
# @return [SocialInbox]
|
||||
def social_inbox
|
||||
@social_inbox ||= SocialInbox.new(site: self)
|
||||
|
|
9
app/policies/moderation_queue_policy.rb
Normal file
9
app/policies/moderation_queue_policy.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Si la cola de moderación está activada y le usuarie tiene permisos de
|
||||
# usuarie.
|
||||
ModerationQueuePolicy = Struct.new(:usuarie, :moderation_queue) do
|
||||
def index?
|
||||
moderation_queue.site.moderation_enabled? && moderation_queue.site.usuarie?(usuarie)
|
||||
end
|
||||
end
|
|
@ -1,10 +1,10 @@
|
|||
%main.row
|
||||
%aside.menu.col-md-3
|
||||
.mb-3
|
||||
= render 'sites/header', site: @site
|
||||
|
||||
= render 'sites/status', site: @site
|
||||
|
||||
= render 'sites/build', site: @site, class: 'btn-block'
|
||||
= render 'sites/moderation_queue', site: @site, class: 'btn-block'
|
||||
|
||||
%h3= t('posts.new')
|
||||
%table.table.table-sm.mb-3
|
||||
|
|
9
app/views/sites/_moderation_queue.haml
Normal file
9
app/views/sites/_moderation_queue.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- if policy(ModerationQueue.new(site)).index?
|
||||
- moderation_needed = site.moderation_needed?
|
||||
|
||||
- local_assigns[:class] = "btn btn-secondary #{local_assigns[:class]}"
|
||||
= link_to site_moderation_queue_path(site), class: local_assigns[:class], title: (t('.moderation_needed') if moderation_needed) do
|
||||
= t('moderation_queue.index.title')
|
||||
- if moderation_needed
|
||||
%span.primary ⏺
|
||||
%span.sr-only= t('.moderation_needed')
|
|
@ -15,11 +15,6 @@
|
|||
%tbody
|
||||
- @sites.each do |site|
|
||||
- next unless site.jekyll?
|
||||
- rol = current_usuarie.rol_for_site(site)
|
||||
-#
|
||||
TODO: Solo les usuaries cachean porque tenemos que separar
|
||||
les botones por permisos.
|
||||
- cache_if (rol.usuarie? && !rol.temporal), [site, I18n.locale] do
|
||||
%tr
|
||||
%td
|
||||
%h2
|
||||
|
@ -30,17 +25,17 @@
|
|||
%p.lead= site.description
|
||||
%br
|
||||
= link_to t('.visit'), site.url, class: 'btn btn-secondary'
|
||||
- if rol.temporal
|
||||
= button_to t('sites.invitations.accept'),
|
||||
site_usuaries_accept_invitation_path(site),
|
||||
method: :patch,
|
||||
- if current_usuarie.rol_for_site(site).temporal?
|
||||
= render 'components/btn_base',
|
||||
text: t('sites.invitations.accept'),
|
||||
path: site_usuaries_accept_invitation_path(site),
|
||||
title: t('help.sites.invitations.accept'),
|
||||
class: 'btn btn-secondary'
|
||||
= button_to t('sites.invitations.reject'),
|
||||
site_usuaries_reject_invitation_path(site),
|
||||
method: :patch,
|
||||
class: 'btn-secondary'
|
||||
= render 'components/btn_base',
|
||||
text: t('sites.invitations.reject'),
|
||||
path: site_usuaries_reject_invitation_path(site),
|
||||
title: t('help.sites.invitations.reject'),
|
||||
class: 'btn btn-secondary'
|
||||
class: 'btn-secondary'
|
||||
- else
|
||||
- if policy(site).show?
|
||||
= render 'layouts/btn_with_tooltip',
|
||||
|
@ -48,10 +43,11 @@
|
|||
type: 'success',
|
||||
link: site_path(site),
|
||||
text: t('sites.posts')
|
||||
= render 'sites/build', site: site
|
||||
= render 'sites/moderation_queue', site: site
|
||||
- if policy(SiteUsuarie.new(site, current_usuarie)).index?
|
||||
= render 'layouts/btn_with_tooltip',
|
||||
tooltip: t('usuaries.index.help.self'),
|
||||
text: t('usuaries.index.title'),
|
||||
type: 'info',
|
||||
link: site_usuaries_path(site)
|
||||
= render 'sites/build', site: site
|
||||
|
|
Loading…
Reference in a new issue