removed code duplication
This commit is contained in:
@ -28,7 +28,6 @@ module CommonBehavior
|
|||||||
format.html { render(options[:template]) }
|
format.html { render(options[:template]) }
|
||||||
format.json { render(json: @object.errors, status: :unprocessable_entity) }
|
format.json { render(json: @object.errors, status: :unprocessable_entity) }
|
||||||
end
|
end
|
||||||
private :respond_with_invalid_object
|
|
||||||
|
|
||||||
def respond_with_valid_object(format, options = {})
|
def respond_with_valid_object(format, options = {})
|
||||||
format.html { redirect_to(options[:path], notice: options[:notice]) }
|
format.html { redirect_to(options[:path], notice: options[:notice]) }
|
||||||
|
@ -15,8 +15,7 @@ class InternalUsersController < ApplicationController
|
|||||||
format.html { redirect_to(sign_in_path, notice: t('.success')) }
|
format.html { redirect_to(sign_in_path, notice: t('.success')) }
|
||||||
format.json { render(nothing: true, status: :ok) }
|
format.json { render(nothing: true, status: :ok) }
|
||||||
else
|
else
|
||||||
format.html { render(:activate) }
|
respond_with_invalid_object(format, object: @user, template: :activate)
|
||||||
format.json { render(json: @user.errors, status: :unprocessable_entity) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -94,8 +93,7 @@ class InternalUsersController < ApplicationController
|
|||||||
format.html { redirect_to(sign_in_path, notice: t('.success')) }
|
format.html { redirect_to(sign_in_path, notice: t('.success')) }
|
||||||
format.json { render(nothing: true, status: :ok) }
|
format.json { render(nothing: true, status: :ok) }
|
||||||
else
|
else
|
||||||
format.html { render(:reset_password) }
|
respond_with_invalid_object(format, object: @user, template: :reset_password)
|
||||||
format.json { render(json: @user.errors, status: :unprocessable_entity) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ class DockerClient
|
|||||||
end
|
end
|
||||||
|
|
||||||
def copy_file_to_workspace(options = {})
|
def copy_file_to_workspace(options = {})
|
||||||
FileUtils.cp(options[:file].native_file.path, File.join(self.class.local_workspace_path(options[:container]), options[:file].path || '', options[:file].name_with_extension))
|
FileUtils.cp(options[:file].native_file.path, local_file_path(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_container(execution_environment)
|
def self.create_container(execution_environment)
|
||||||
@ -47,7 +47,7 @@ class DockerClient
|
|||||||
private :create_workspace
|
private :create_workspace
|
||||||
|
|
||||||
def create_workspace_file(options = {})
|
def create_workspace_file(options = {})
|
||||||
file = File.new(File.join(self.class.local_workspace_path(options[:container]), options[:file].path || '', options[:file].name_with_extension), 'w')
|
file = File.new(local_file_path(options), 'w')
|
||||||
file.write(options[:file].content)
|
file.write(options[:file].content)
|
||||||
file.close
|
file.close
|
||||||
end
|
end
|
||||||
@ -108,6 +108,11 @@ class DockerClient
|
|||||||
FileUtils.mkdir_p(LOCAL_WORKSPACE_ROOT)
|
FileUtils.mkdir_p(LOCAL_WORKSPACE_ROOT)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def local_file_path(options = {})
|
||||||
|
File.join(self.class.local_workspace_path(options[:container]), options[:file].path || '', options[:file].name_with_extension)
|
||||||
|
end
|
||||||
|
private :local_file_path
|
||||||
|
|
||||||
def self.local_workspace_path(container)
|
def self.local_workspace_path(container)
|
||||||
Pathname.new(container.binds.first.split(':').first.sub(config[:workspace_root], LOCAL_WORKSPACE_ROOT.to_s))
|
Pathname.new(container.binds.first.split(':').first.sub(config[:workspace_root], LOCAL_WORKSPACE_ROOT.to_s))
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user