Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
DEV: save logs with split fields
Dieser Commit ist enthalten in:
Ursprung
aa928c319e
Commit
b79039c2e2
3 geänderte Dateien mit 16 neuen und 13 gelöschten Zeilen
|
@ -742,14 +742,11 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_log
|
def save_log
|
||||||
log = "wizard: #{@wizard.id}; action: #{action['type']}; user: #{user.username}"
|
CustomWizard::Log.create(
|
||||||
|
@wizard.id,
|
||||||
if @log.any?
|
action['type'],
|
||||||
@log.each do |item|
|
user.username,
|
||||||
log += "; #{item.to_s}"
|
@log.join('; ')
|
||||||
end
|
)
|
||||||
end
|
|
||||||
|
|
||||||
CustomWizard::Log.create(log)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,22 +2,28 @@
|
||||||
class CustomWizard::Log
|
class CustomWizard::Log
|
||||||
include ActiveModel::Serialization
|
include ActiveModel::Serialization
|
||||||
|
|
||||||
attr_accessor :message, :date
|
attr_accessor :date, :wizard, :action, :user, :message
|
||||||
|
|
||||||
PAGE_LIMIT = 100
|
PAGE_LIMIT = 100
|
||||||
|
|
||||||
def initialize(attrs)
|
def initialize(attrs)
|
||||||
@message = attrs['message']
|
|
||||||
@date = attrs['date']
|
@date = attrs['date']
|
||||||
|
@wizard = attrs['wizard']
|
||||||
|
@action = attrs['action']
|
||||||
|
@user = attrs['user']
|
||||||
|
@message = attrs['message']
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create(message)
|
def self.create(wizard, action, user, message)
|
||||||
log_id = SecureRandom.hex(12)
|
log_id = SecureRandom.hex(12)
|
||||||
|
|
||||||
PluginStore.set('custom_wizard_log',
|
PluginStore.set('custom_wizard_log',
|
||||||
log_id.to_s,
|
log_id.to_s,
|
||||||
{
|
{
|
||||||
date: Time.now,
|
date: Time.now,
|
||||||
|
wizard: wizard,
|
||||||
|
action: action,
|
||||||
|
user: user,
|
||||||
message: message
|
message: message
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class CustomWizard::LogSerializer < ApplicationSerializer
|
class CustomWizard::LogSerializer < ApplicationSerializer
|
||||||
attributes :message, :date
|
attributes :date, :wizard, :action, :user, :message
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren