节点库开放管理权限

This commit is contained in:
2025-01-10 09:29:28 +08:00
parent 38d860385d
commit aef492cc4f
2 changed files with 14 additions and 2 deletions

View File

@@ -1,12 +1,13 @@
class Action::NodesController < ApplicationController
before_action :require_admin, except: [:index]
# before_action :require_admin, except: [:index]
before_action :require_login
before_action :find_action_node, except: [:index, :create, :new]
def index
@node_types = Action::NodeType.all
@no_type_nodes = Action::Node.where(action_node_types_id: nil)
respond_to do |format|
format.html { @nodes = Action::Node.all }
format.html { @nodes = Action::Node.where("name LIKE :search OR full_name LIKE :search", :search => "%#{params[:search]}%") }
format.json
end
end
@@ -16,6 +17,7 @@ class Action::NodesController < ApplicationController
if params.require(:node).present? && params.require(:node)[:link_type_array].present?
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",")
end
@node.user_id = current_user.id
respond_to do |format|
if @node.save
format.html { redirect_to action_nodes_path, notice: '创建成功.' }
@@ -45,6 +47,7 @@ class Action::NodesController < ApplicationController
if params.require(:node).present? && params.require(:node)[:link_type_array].present?
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",")
end
@node.user_id = current_user.id if @node.user_id.blank?
@node.update(node_params)
respond_to do |format|
format.html { redirect_to action_nodes_path, notice: '更新成功.' }