mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 13:16:23 +00:00
eliminar desde el panel
This commit is contained in:
parent
e9a7625010
commit
bae77d8c69
5 changed files with 34 additions and 3 deletions
|
@ -104,6 +104,19 @@ class PostsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# Eliminar artículos
|
||||
def destroy
|
||||
@site = find_site
|
||||
@lang = find_lang(@site)
|
||||
@post = find_post(@site)
|
||||
|
||||
authorize @post
|
||||
|
||||
@post.destroy
|
||||
|
||||
redirect_to site_posts_path(@site, category: session[:category], lang: @lang)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Solo permitir cambiar estos atributos de cada articulo
|
||||
|
|
|
@ -34,6 +34,12 @@ class PostPolicy < SuttyPolicy
|
|||
usuaria? || post.author == usuarix.email
|
||||
end
|
||||
|
||||
# Solo las usuarias pueden eliminar artículos. Lxs invitadxs pueden
|
||||
# borrar sus propios artículos
|
||||
def destroy?
|
||||
update?
|
||||
end
|
||||
|
||||
class Scope < SuttyPolicy::Scope
|
||||
# Las usuarias pueden ver todos los posts
|
||||
#
|
||||
|
|
|
@ -118,8 +118,16 @@
|
|||
%br
|
||||
|
||||
%td= post.date.strftime('%F')
|
||||
%td= link_to t('posts.edit'),
|
||||
edit_site_post_path(@site, post, lang: @lang),
|
||||
class: 'btn btn-info'
|
||||
%td
|
||||
- if policy(post).edit?
|
||||
= link_to t('posts.edit'),
|
||||
edit_site_post_path(@site, post, lang: @lang),
|
||||
class: 'btn btn-info'
|
||||
- if policy(post).destroy?
|
||||
= link_to t('posts.destroy'),
|
||||
site_post_path(@site, post, lang: @lang),
|
||||
class: 'btn btn-danger',
|
||||
method: :delete,
|
||||
data: { confirm: t('posts.confirm_destroy') }
|
||||
- else
|
||||
%h2= t('posts.none')
|
||||
|
|
|
@ -254,3 +254,5 @@ en:
|
|||
invalid_help: It looks like the form is incomplete. Check the red-colored fields to complete it.
|
||||
sending_help: Saving, please wait...
|
||||
blank: Nothing
|
||||
destroy: Delete
|
||||
confirm_destroy: Are you sure?
|
||||
|
|
|
@ -261,3 +261,5 @@ es:
|
|||
invalid_help: Parece que el formulario no está completo. Verifica los campos marcados en rojo para completarlo.
|
||||
sending_help: Guardando, por favor espera...
|
||||
blank: En blanco
|
||||
destroy: Borrar
|
||||
confirm_destroy: ¿Estás segurx?
|
||||
|
|
Loading…
Reference in a new issue