0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 11:52:54 +01:00
Dieser Commit ist enthalten in:
Faizaan Gagan 2021-10-14 18:27:18 +05:30
Ursprung 538d618ff3
Commit d9d4c7d8fa
3 geänderte Dateien mit 40 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,33 @@
# frozen_string_literal: true
class CustomWizard::Guardian
def initialize(user)
@user = user
end
def can_edit_topic?(topic)
creating_wizard = topic.wizard_created.presence
return false unless creating_wizard
wizard_builder = CustomWizard::Builder.new(creating_wizard, @user)
wizard = wizard_builder.build
wizard_actions = wizard.actions
return false if wizard_actions.empty?
create_topic_action = wizard_actions.find do |action|
action['type'] === 'create_topic'
end
return wizard_can_create_topic_on_category?(action, topic)
end
private
def wizard_can_create_topic_on_category?(action, topic)
return false unless topic.category.present?
category = CustomWizard::Mapper.new(
inputs: action['category'],
data:
)
end
end

Datei anzeigen

@ -86,6 +86,7 @@ after_initialize do
../lib/custom_wizard/submission.rb
../lib/custom_wizard/template.rb
../lib/custom_wizard/wizard.rb
../lib/custom_wizard/guardian.rb
../lib/custom_wizard/api/api.rb
../lib/custom_wizard/api/authorization.rb
../lib/custom_wizard/api/endpoint.rb

Datei anzeigen

@ -0,0 +1,6 @@
# frozen_string_literal: true
require_relative '../../plugin_helper'
describe CustomWizard::Guardian do
end