mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 10:46:22 +00:00
Merge branch 'issue-14540' into 'rails'
feat: soportar varias instancias de distributed press #14540 See merge request sutty/sutty!224
This commit is contained in:
commit
bf0a0494cd
3 changed files with 23 additions and 7 deletions
|
@ -12,7 +12,7 @@ require 'distributed_press/v1/client/site'
|
|||
# Al ser publicado, envía los archivos en un tarball y actualiza la
|
||||
# información.
|
||||
class DeployDistributedPress < Deploy
|
||||
store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON
|
||||
store :values, accessors: %i[hostname remote_site_id remote_info distributed_press_publisher_id], coder: JSON
|
||||
|
||||
before_create :create_remote_site!
|
||||
before_destroy :delete_remote_site!
|
||||
|
@ -95,12 +95,14 @@ class DeployDistributedPress < Deploy
|
|||
|
||||
# El cliente de la API
|
||||
#
|
||||
# TODO: cuando soportemos más, tiene que haber una relación entre
|
||||
# DeployDistributedPress y DistributedPressPublisher.
|
||||
#
|
||||
# @return [DistributedPressPublisher]
|
||||
def publisher
|
||||
@publisher ||= DistributedPressPublisher.last
|
||||
@publisher ||=
|
||||
if distributed_press_publisher_id
|
||||
DistributedPressPublisher.find(distributed_press_publisher_id)
|
||||
else
|
||||
DistributedPressPublisher.find_by_default(true)
|
||||
end
|
||||
end
|
||||
|
||||
# El cliente para actualizar el sitio
|
||||
|
|
|
@ -13,8 +13,8 @@ class DistributedPressPublisher < ApplicationRecord
|
|||
# @return [IO]
|
||||
attr_reader :logger_out
|
||||
|
||||
# La instancia es única
|
||||
validates_uniqueness_of :instance
|
||||
# La instancia es necesaria pero no única
|
||||
validates_presence_of :instance
|
||||
|
||||
# El token es necesario
|
||||
validates_presence_of :token
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Una instancia es la instancia por defecto
|
||||
class AddDefaultToDistributedPressPublisher < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
add_column :distributed_press_publishers, :default, :boolean, default: false
|
||||
|
||||
DistributedPressPublisher.last&.update(default: true)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :distributed_press_publishers, :default
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue