mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-24 02:31:50 +00:00
Merge branch 'issue-13244' of 0xacab.org:sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
81b06f75ab
4 changed files with 27 additions and 0 deletions
12
app/services/concerns/auto_publish_concern.rb
Normal file
12
app/services/concerns/auto_publish_concern.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
|
||||||
|
module AutoPublishConcern
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
def auto_publish!
|
||||||
|
DeployJob.perform_later(site) if site.auto_publish?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,6 +3,8 @@
|
||||||
# Este servicio se encarga de crear artículos y guardarlos en git,
|
# Este servicio se encarga de crear artículos y guardarlos en git,
|
||||||
# asignándoselos a une usuarie
|
# asignándoselos a une usuarie
|
||||||
PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
||||||
|
include AutoPublishConcern
|
||||||
|
|
||||||
# Crea un artículo nuevo
|
# Crea un artículo nuevo
|
||||||
#
|
#
|
||||||
# @return Post
|
# @return Post
|
||||||
|
@ -29,6 +31,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
||||||
# Devolver el post aunque no se haya salvado para poder rescatar los
|
# Devolver el post aunque no se haya salvado para poder rescatar los
|
||||||
# errores
|
# errores
|
||||||
post
|
post
|
||||||
|
auto_publish!
|
||||||
end
|
end
|
||||||
|
|
||||||
# Crear un post anónimo, con opciones más limitadas. No usamos post.
|
# Crear un post anónimo, con opciones más limitadas. No usamos post.
|
||||||
|
@ -42,6 +45,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
||||||
|
|
||||||
commit(action: :created, add: files) if post.update(anon_post_params)
|
commit(action: :created, add: files) if post.update(anon_post_params)
|
||||||
post
|
post
|
||||||
|
auto_publish!
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -66,6 +70,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
||||||
# Devolver el post aunque no se haya salvado para poder rescatar los
|
# Devolver el post aunque no se haya salvado para poder rescatar los
|
||||||
# errores
|
# errores
|
||||||
post
|
post
|
||||||
|
auto_publish!
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
# Se encargar de guardar cambios en sitios
|
# Se encargar de guardar cambios en sitios
|
||||||
# TODO: Implementar rollback en la configuración
|
# TODO: Implementar rollback en la configuración
|
||||||
SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
|
include AutoPublishConcern
|
||||||
|
|
||||||
def deploy
|
def deploy
|
||||||
site.enqueue!
|
site.enqueue!
|
||||||
DeployJob.perform_later site
|
DeployJob.perform_later site
|
||||||
|
|
8
db/migrate/20230822165038_add_autopublish_to_sites.rb
Normal file
8
db/migrate/20230822165038_add_autopublish_to_sites.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Agrega posibilidad de autopublicación del sitio
|
||||||
|
class AddAutopublishToSites < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :sites, :auto_publish, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue