rosa-build/app/controllers/users/profile_controller.rb

29 lines
841 B
Ruby
Raw Normal View History

class Users::ProfileController < Users::BaseController
2014-11-13 00:17:22 +00:00
include PaginateHelper
2015-03-04 23:19:19 +00:00
skip_before_action :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
def show
authorize @user
2014-11-13 00:17:22 +00:00
respond_to do |format|
format.html do
@groups = @user.groups.order(:uname)
end
format.json do
@projects = @user.own_projects.search(params[:term]).recent
case params[:visibility]
when 'open'
@projects = @projects.opened
2014-11-13 00:17:22 +00:00
when 'hidden'
2015-03-26 00:26:24 +00:00
@projects = ProjectPolicy::Scope.new(current_user, @projects.by_visibilities('hidden')).read
2014-11-13 00:17:22 +00:00
else
2015-03-26 00:26:24 +00:00
@projects = ProjectPolicy::Scope.new(current_user, @projects).read
2014-11-13 00:17:22 +00:00
end
@total_items = @projects.count
@projects = @projects.paginate(paginate_params)
2013-09-10 18:03:00 +01:00
end
end
end
end