163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/openc3/models/tool_model.rb', line 163
def create(update: false, force: false, queued: false)
tools = self.class.all(scope: @scope)
unless update
if @folder_name
tools.each do |_tool_name, tool|
if tool['folder_name'] == @folder_name
raise "Tool with folder_name #{@folder_name} already exists at create"
end
end
end
end
unless @position
_, tool = tools.max_by { |_tool_name, tool| tool['position'] }
if tool
@position = tool['position'] + 1
else
@position = 0
end
end
if @url and !@url.start_with?('/') and !@url.start_with?('http')
raise "URL must be a full URL (http://domain.com/path) or a relative path (/path)"
end
super(update: update, force: force, queued: queued)
end
|