scinote-web/app/controllers/user_repositories_controller.rb

29 lines
683 B
Ruby
Raw Normal View History

2017-06-06 23:35:29 +08:00
class UserRepositoriesController < ApplicationController
before_action :load_vars
def save_table_state
service = RepositoryTableStateService.new(current_user, @repository)
service.update_state(params.require(:state).permit!.to_h)
render json: {
status: :ok
}
2017-06-06 23:35:29 +08:00
end
def load_table_state
service = RepositoryTableStateService.new(current_user, @repository)
state = service.load_state.state
if state
render json: {
state: state
}
2017-06-06 23:35:29 +08:00
end
end
private
def load_vars
@repository = RepositoryBase.find_by(id: params[:repository_id])
render_403 if @repository.nil? || !can_read_repository?(@repository)
2017-06-06 23:35:29 +08:00
end
end