Skip to content

Commit

Permalink
Merge branch 'dev'. This will become 4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prioux committed Oct 30, 2015
2 parents 5836cf8 + 1a3dd18 commit 0146c59
Show file tree
Hide file tree
Showing 145 changed files with 8,779 additions and 2,624 deletions.
1 change: 1 addition & 0 deletions Bourreau/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ gem "mysql2"
gem "sys-proctable", :git => 'git://github.com/djberg96/sys-proctable.git'
gem "thin"
gem "pbkdf2-ruby"
gem "json-schema"

group :development, :test do
gem "wirble"
Expand Down
14 changes: 12 additions & 2 deletions Bourreau/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class Application < Rails::Application
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += Dir["#{config.root}/lib"]
config.autoload_paths += Dir["#{config.root}/lib/cbrain_task_generators"]

# CBRAIN Plugins load paths: add directories for each Userfile model
config.autoload_paths += Dir[ * Dir.glob("#{config.root}/cbrain_plugins/installed-plugins/userfiles/*") ]

# CBRAIN Plugins load paths: add directory for the CbrainTask models
# This directory contains symbolic links to a special loader code
Expand All @@ -47,8 +51,14 @@ class Application < Rails::Application
# properly set up all tasks installed from plugins (and the defaults tasks).
config.autoload_paths += Dir["#{config.root}/cbrain_plugins/installed-plugins/cbrain_task"]

# CBRAIN Plugins load paths: add directories for each Userfile model
config.autoload_paths += Dir[ * Dir.glob("#{config.root}/cbrain_plugins/installed-plugins/userfiles/*") ]
# CBRAIN Plugins load paths: add directory for descriptor-based CbrainTask
# models. This directory, similarly to the one above, contains symbolic
# links to a special loader code which will call a task generator to
# generate the requested CbrainTask subclass on the fly.
#
# The rake task cbrain:plugins:install:all also takes care of creating the
# symlinks for this location.
config.autoload_paths += Dir["#{config.root}/cbrain_plugins/installed-plugins/cbrain_task_descriptors"]

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
Expand Down
1 change: 1 addition & 0 deletions Bourreau/lib/cbrain_task_generators
4 changes: 4 additions & 0 deletions BrainPortal/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ gem "sys-proctable", :git => 'git://github.com/djberg96/sys-proctable.git'
gem "thin"
gem "rails_autolink"
gem "pbkdf2-ruby"
gem "json-schema"
gem "test-unit"

group :development do
gem "wirble"
gem "looksee"
gem "hirb"
gem "pry"
gem "pry-byebug"
gem "pry-doc"
end

group :test do
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ApplicationController < ActionController::Base

include AuthenticatedSystem
include SessionHelpers
include BasicFilterHelpers
include ViewScopes
include ViewHelpers
include ApiHelpers
include PermissionHelpers
Expand Down
14 changes: 6 additions & 8 deletions BrainPortal/app/controllers/bourreaux_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ class BourreauxController < ApplicationController
API_HIDDEN_ATTRIBUTES = [ :cache_md5 ] # these are hidden back when APIs calls returns objects

def index #:nodoc:
@filter_params["sort_hash"]["order"] ||= "remote_resources.type"
@filter_params["sort_hash"]["dir"] ||= "DESC"
@header_scope = RemoteResource.find_all_accessible_by_user(current_user)
@filtered_scope = base_filtered_scope @header_scope.includes(:user, :group)
@bourreaux = base_sorted_scope @filtered_scope
@scope = scope_from_session('bourreaux')
scope_default_order(@scope, 'type')

if current_user.has_role? :admin_user
@filter_params['details'] = 'on' unless @filter_params.has_key?('details')
end
@base_scope = RemoteResource
.find_all_accessible_by_user(current_user)
.includes(:user, :group)
@bourreaux = @scope.apply(@base_scope)

respond_to do |format|
format.html
Expand Down
5 changes: 0 additions & 5 deletions BrainPortal/app/controllers/custom_filters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ def update #:nodoc:
# DELETE /custom_filters/1.xml
def destroy #:nodoc:
@custom_filter = current_user.custom_filters.find(params[:id])
if @custom_filter.filtered_class_controller == "userfiles"
current_session[@custom_filter.filtered_class_controller.to_sym]["filter_custom_filters_array"].delete @custom_filter.id.to_s
else
current_session[@custom_filter.filtered_class_controller.to_sym]["filter_hash"].delete "custom_filter"
end
@custom_filter.destroy

flash[:notice] = "Custom filter '#{@custom_filter.name}' deleted."
Expand Down
82 changes: 48 additions & 34 deletions BrainPortal/app/controllers/data_providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ class DataProvidersController < ApplicationController
API_HIDDEN_ATTRIBUTES = [ :cloud_storage_client_identifier, :cloud_storage_client_token ]

def index #:nodoc:
@filter_params["sort_hash"]["order"] ||= "data_providers.name"
@scope = scope_from_session('data_providers')
scope_default_order(@scope, 'name')

@header_scope = DataProvider.find_all_accessible_by_user(current_user)
@filtered_scope = base_filtered_scope @header_scope.includes(:user, :group)
@data_providers = base_sorted_scope @filtered_scope

if current_user.has_role? :admin_user
@filter_params['details'] = 'on' unless @filter_params.has_key?('details')
end
@base_scope = DataProvider
.find_all_accessible_by_user(current_user)
.includes(:user, :group)
@data_providers = @scope.apply(@base_scope)

respond_to do |format|
format.html
Expand Down Expand Up @@ -291,12 +289,24 @@ def browse
return
end

@filter_params["browse_hash"] ||= {}
@per_page = @filter_params["browse_hash"]["per_page"]
validate_pagination_values # validates @per_page and @current_page
as_user_id = params[:as_user_id].presence || @filter_params["browse_hash"]["as_user_id"].presence || current_user.id
@as_user = current_user.available_users.where(:id => as_user_id).first || current_user
@filter_params["browse_hash"]["as_user_id"] = @as_user.id.to_s
# Load up the default scope for DP browsing and handle 'name_like'.
@scope = scope_from_session(default_scope_name)
scope_filter_from_params(@scope, :name_like, {
:attribute => 'name',
:operator => 'match'
})

# Browsing as a different user? Make sure the target user is set.
@as_user = current_user
.available_users
.where(:id => (
params['as_user_id'] ||
@scope.custom['as_user_id'] ||
current_user.id
))
.first
@as_user ||= current_user
@scope.custom['as_user_id'] = @as_user.id

begin
# [ base, size, type, mtime ]
Expand Down Expand Up @@ -362,22 +372,16 @@ def browse

end

# Search by name
if @filter_params["browse_hash"]["name_like"].present?
search_term = @filter_params["browse_hash"]["name_like"].to_s.downcase
@fileinfolist = @fileinfolist.select{|file| file.name.to_s.downcase.index(search_term)}
end
# Now that @fileinfolist is complete, apply @scope's elements and paginate
# before display.
@fileinfolist = @scope.apply(@fileinfolist)

@file_count = @fileinfolist.count
unless request.format.to_sym == :xml || request.format.to_sym == :json
@fileinfolist = WillPaginate::Collection.create(@current_page, @per_page) do |pager|
pager.replace(@fileinfolist[(@current_page-1)*@per_page, @per_page] || [])
pager.total_entries = @file_count
pager
end
end
@scope.pagination ||= Scope::Pagination.from_hash({ :per_page => 25 })
@files = @scope.pagination.apply(@fileinfolist) unless
[:xml, :json].include?(request.format.to_sym)

current_session.save_preferences_for_user(current_user, :data_providers, :browse_hash)
scope_to_session(@scope)
current_session.save_preferences

respond_to do |format|
format.html
Expand All @@ -399,12 +403,16 @@ def browse
# This method is (unfortunately) also used to unregister files, and delete them (on the browsable side)
def register
# TODO: refactor completely!
@provider = DataProvider.find_accessible_by_user(params[:id], current_user)
@provider = DataProvider.find_accessible_by_user(params[:id], current_user)

@filter_params["browse_hash"] ||= {}
as_user_id = params[:as_user_id].presence || @filter_params["browse_hash"]["as_user_id"].presence || current_user.id
@as_user = current_user.available_users.where(:id => as_user_id).first || current_user
@filter_params["browse_hash"]["as_user_id"] = @as_user.id.to_s
scope = scope_from_session('data_providers#browse')
@as_user = current_user
.available_users
.where(:id => scope.custom['as_user_id'] ||= (
params['as_user_id'] || current_user.id
))
.first
@as_user ||= current_user

unless @provider.is_browsable?(current_user)
flash[:error] = "You cannot register files from this provider."
Expand Down Expand Up @@ -648,11 +656,17 @@ def register

# Report inconsistencies in the data provider.
def report
@scope = scope_from_session(default_scope_name)
@provider = DataProvider.find(params[:id])
@issues = @provider.provider_report(params[:reload])

scope_default_order(@scope, :severity)
@scope.pagination ||= Scope::Pagination.from_hash({ :per_page => 25 })
@view_scope = @scope.apply(@issues, paginate: true)

respond_to do |format|
format.html # report.html.erb
format.html
format.js
format.xml { render :xml => { :issues => @issues } }
format.json { render :json => { :issues => @issues } }
end
Expand Down
24 changes: 14 additions & 10 deletions BrainPortal/app/controllers/exception_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Controller for viewing or managing exception logs.
class ExceptionLogsController < ApplicationController

Revision_info=CbrainFileRevision[__FILE__] #:nodoc:

before_filter :login_required
before_filter :login_required
before_filter :admin_role_required

def index #:nodoc:
@filter_params["sort_hash"]["order"] ||= 'exception_logs.created_at'
@filter_params["sort_hash"]["dir"] ||= 'DESC'
@filtered_scope = base_filtered_scope
@exception_logs = base_sorted_scope(@filtered_scope).paginate(:page => @current_page, :per_page => @per_page)
@scope = scope_from_session('exception_logs')
scope_default_order(@scope, 'created_at', :desc)

@base_scope = ExceptionLog
@view_scope = @scope.apply(@base_scope)

current_session.save_preferences_for_user(current_user, :exception_logs, :per_page)
@scope.pagination ||= Scope::Pagination.from_hash({ :per_page => 50 })
@exception_logs = @scope.pagination.apply(@view_scope)

scope_to_session(@scope)
current_session.save_preferences

respond_to do |format|
format.html # index.html.erb
Expand All @@ -56,7 +60,7 @@ def show #:nodoc:
def destroy #:nodoc:
@exception_logs = ExceptionLog.find(params[:exception_log_ids])
@exception_logs.each(&:destroy)

flash[:notice] = "#{view_pluralize(@exception_logs.count, "exception")} deleted."

respond_to do |format|
Expand Down
18 changes: 9 additions & 9 deletions BrainPortal/app/controllers/feedbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

#RESTful controller for the Feedback resource.
class FeedbacksController < ApplicationController
before_filter :login_required

Revision_info=CbrainFileRevision[__FILE__] #:nodoc:

# GET /feedbacks
# GET /feedbacks.xml
def index #:nodoc:
@filter_params["sort_hash"]["order"] ||= 'feedbacks.created_at'
@filter_params["sort_hash"]["dir"] ||= 'DESC'
@filtered_scope = base_filtered_scope
@feedbacks = base_sorted_scope @filtered_scope.includes(:user)
@scope = scope_from_session('feedbacks')
scope_default_order(@scope, 'created_at', :desc)

@base_scope = Feedback.includes(:user)
@feedbacks = @scope.apply(@base_scope)

respond_to do |format|
format.js
Expand Down Expand Up @@ -106,7 +106,7 @@ def update #:nodoc:
def destroy #:nodoc:
@feedback = Feedback.find(params[:id])
@feedback.destroy

respond_to do |format|
format.html { redirect_to :action => :index, :status => 303 }
format.js { redirect_to :action => :index, :format => :js, :status => 303 }
Expand Down
Loading

0 comments on commit 0146c59

Please sign in to comment.