Cleanup after merge
Dieser Commit ist enthalten in:
Ursprung
69fd3d451d
Commit
d57f260def
4 geänderte Dateien mit 70 neuen und 30 gelöschten Zeilen
|
@ -1,9 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminLogsController < CustomWizard::AdminController
|
||||
before_action :find_wizard, except: [:index]
|
||||
|
||||
def index
|
||||
render_serialized(
|
||||
CustomWizard::Log.list(params[:page].to_i, params[:limit].to_i),
|
||||
CustomWizard::LogSerializer
|
||||
render json: ActiveModel::ArraySerializer.new(
|
||||
CustomWizard::Wizard.list(current_user),
|
||||
each_serializer: CustomWizard::BasicWizardSerializer
|
||||
)
|
||||
end
|
||||
|
||||
def show
|
||||
render_json_dump(
|
||||
wizard: CustomWizard::BasicWizardSerializer.new(@wizard, root: false),
|
||||
logs: ActiveModel::ArraySerializer.new(
|
||||
log_list.logs,
|
||||
each_serializer: CustomWizard::LogSerializer
|
||||
),
|
||||
total: log_list.total
|
||||
)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def log_list
|
||||
@log_list ||= begin
|
||||
list = CustomWizard::Log.list(params[:page].to_i, params[:limit].to_i, params[:wizard_id])
|
||||
|
||||
if list.logs.any? && (usernames = list.logs.map(&:username)).present?
|
||||
user_map = User.where(username: usernames)
|
||||
.reduce({}) do |result, user|
|
||||
result[user.username] = user
|
||||
result
|
||||
end
|
||||
|
||||
list.logs.each do |log_item|
|
||||
log_item.user = user_map[log_item.username]
|
||||
end
|
||||
end
|
||||
|
||||
list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CustomWizard::LogSerializer < ApplicationSerializer
|
||||
attributes :message, :date
|
||||
attributes :date,
|
||||
:action,
|
||||
:username,
|
||||
:message
|
||||
|
||||
has_one :user, serializer: ::BasicUserSerializer, embed: :objects
|
||||
end
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::SubmissionSerializer < ApplicationSerializer
|
||||
attributes :id,
|
||||
:username,
|
||||
:fields,
|
||||
:submitted_at,
|
||||
:route_to,
|
||||
:redirect_on_complete,
|
||||
:redirect_to
|
||||
:submitted_at
|
||||
|
||||
def username
|
||||
object.user.present? ?
|
||||
object.user.username :
|
||||
I18n.t('admin.wizard.submission.no_user', user_id: object.user_id)
|
||||
has_one :user, serializer: ::BasicUserSerializer, embed: :objects
|
||||
|
||||
def include_user?
|
||||
object.user.present?
|
||||
end
|
||||
|
||||
def fields
|
||||
@fields ||= begin
|
||||
result = {}
|
||||
|
||||
object.wizard.template['steps'].each do |step|
|
||||
step['fields'].each do |field|
|
||||
if value = object.fields[field['id']]
|
||||
result[field['id']] = {
|
||||
value: value,
|
||||
type: field['type'],
|
||||
label: field['label']
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
if ENV['SIMPLECOV']
|
||||
require 'simplecov'
|
||||
|
||||
SimpleCov.start do
|
||||
root "plugins/discourse-custom-wizard"
|
||||
track_files "plugins/discourse-custom-wizard/**/*.rb"
|
||||
add_filter { |src| src.filename =~ /(\/spec\/|\/db\/|plugin\.rb|api|gems)/ }
|
||||
SimpleCov.minimum_coverage 80
|
||||
end
|
||||
end
|
||||
|
||||
require 'oj'
|
||||
Oj.default_options = Oj.default_options.merge(cache_str: -1)
|
||||
|
||||
require 'rails_helper'
|
||||
require 'webmock/rspec'
|
||||
|
||||
def get_wizard_fixture(path)
|
||||
JSON.parse(
|
||||
File.open(
|
||||
|
|
Laden …
In neuem Issue referenzieren