Clean up auto tagging
This commit is contained in:
@@ -5,22 +5,32 @@ module Admin
|
||||
|
||||
include Deps["commands.auto_tagging.create",
|
||||
"views.auto_tagging.index",
|
||||
auto_tag: "commands.auto_tagging.tag"]
|
||||
"validation.contracts.auto_tagging_contract",
|
||||
auto_tag: "commands.auto_tagging.tag",
|
||||
new_view: "views.auto_tagging.new"]
|
||||
|
||||
def handle(req, res)
|
||||
title_contains = req.params[:title_contains]
|
||||
body_contains = req.params[:body_contains]
|
||||
tag_id = req.params[:tag_id]
|
||||
|
||||
result = create.(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
validation = auto_tagging_contract.call(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
|
||||
if result.success?
|
||||
auto_tag.(auto_tag_id: result.value!)
|
||||
if validation.success?
|
||||
result = create.(title_contains: title_contains,
|
||||
body_contains: body_contains,
|
||||
tag_id: tag_id)
|
||||
|
||||
if result.success?
|
||||
auto_tag.(auto_tag_id: result.value!)
|
||||
end
|
||||
|
||||
res.render index
|
||||
end
|
||||
|
||||
res.render index
|
||||
res.render new_view, errors: validation.errors
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -6,7 +6,7 @@ module Admin
|
||||
include Deps[new_view: "views.auto_tagging.new"]
|
||||
|
||||
def handle(req, res)
|
||||
res.render new_view
|
||||
res.render new_view, errors: {}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user