mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 00:16:23 +00:00
feat: poder modificar la base de los parametros del post
This commit is contained in:
parent
a10da6fa1c
commit
1624c62a12
1 changed files with 10 additions and 3 deletions
|
@ -13,7 +13,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
post.draft.value = true if site.invitade? usuarie
|
||||
post.assign_attributes(post_params)
|
||||
|
||||
params.require(:post).permit(:slug).tap do |p|
|
||||
params.require(base).permit(:slug).tap do |p|
|
||||
post.slug.value = p[:slug] if p[:slug].present?
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
#
|
||||
# { uuid => 2, uuid => 1, uuid => 0 }
|
||||
def reorder
|
||||
reorder = params.require(:post).permit(reorder: {})&.dig(:reorder)&.transform_values(&:to_i)
|
||||
reorder = params.require(base).permit(reorder: {})&.dig(:reorder)&.transform_values(&:to_i)
|
||||
posts = site.posts(lang: locale).where(uuid: reorder.keys)
|
||||
|
||||
files = posts.map do |post|
|
||||
|
@ -105,6 +105,13 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
|
||||
private
|
||||
|
||||
# La base donde buscar los parámetros
|
||||
#
|
||||
# @return [Symbol]
|
||||
def base
|
||||
@base ||= params.permit(:base).try(:[], :base).try(:to_sym) || :post
|
||||
end
|
||||
|
||||
# Una lista de archivos a modificar
|
||||
#
|
||||
# @return [Set]
|
||||
|
@ -126,7 +133,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
|
||||
# Solo permitir cambiar estos atributos de cada articulo
|
||||
def post_params
|
||||
@post_params ||= params.require(:post).permit(post.params).to_h
|
||||
@post_params ||= params.require(base).permit(post.params).to_h
|
||||
end
|
||||
|
||||
# Eliminar metadatos internos
|
||||
|
|
Loading…
Reference in a new issue