2013-05-15 18:28:39 +01:00
|
|
|
class HomeController < ApplicationController
|
2015-05-05 13:25:29 +01:00
|
|
|
before_action :authenticate_user!, except: [:root]
|
2015-04-15 11:29:25 +01:00
|
|
|
skip_after_action :verify_authorized
|
2013-05-15 18:28:39 +01:00
|
|
|
|
2016-04-29 15:10:30 +01:00
|
|
|
def index
|
2016-05-04 16:49:30 +01:00
|
|
|
redirect_to projects_path
|
2016-04-29 15:10:30 +01:00
|
|
|
end
|
|
|
|
|
2015-05-05 13:25:29 +01:00
|
|
|
def activity(is_my_activity = false)
|
2013-05-15 18:28:39 +01:00
|
|
|
@activity_feeds = current_user.activity_feeds
|
2015-05-05 13:25:29 +01:00
|
|
|
.by_project_name(params[:project_name_filter])
|
|
|
|
.by_owner_uname(params[:owner_filter])
|
|
|
|
|
|
|
|
@activity_feeds = if is_my_activity
|
|
|
|
@activity_feeds.where(creator_id: current_user)
|
|
|
|
else
|
|
|
|
@activity_feeds.where.not(creator_id: current_user)
|
|
|
|
end
|
|
|
|
|
2014-05-06 10:51:04 +01:00
|
|
|
@activity_feeds = @activity_feeds.paginate page: current_page
|
2014-04-11 09:57:00 +01:00
|
|
|
|
2016-04-29 15:10:30 +01:00
|
|
|
if @activity_feeds.next_page
|
|
|
|
if is_my_activity
|
|
|
|
method = :own_activity_path
|
|
|
|
else
|
|
|
|
method = :activity_feeds_path
|
|
|
|
end
|
|
|
|
@next_page_link = method.to_proc.call(self, page: @activity_feeds.next_page, owner_filter: params[:owner_filter],
|
|
|
|
project_name_filter: params[:project_name_filter], format: :json)
|
|
|
|
end
|
|
|
|
|
2013-05-15 18:28:39 +01:00
|
|
|
respond_to do |format|
|
2015-05-05 13:25:29 +01:00
|
|
|
format.json { render 'activity' }
|
2013-05-15 18:28:39 +01:00
|
|
|
format.atom
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-05 13:25:29 +01:00
|
|
|
def own_activity
|
|
|
|
activity(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_owners_list
|
|
|
|
if params[:term].present?
|
2015-05-13 16:58:54 +01:00
|
|
|
users = User.opened.search(params[:term]).first(5)
|
|
|
|
groups = Group.opened.search(params[:term]).first(5)
|
2015-05-05 13:25:29 +01:00
|
|
|
@owners = users | groups
|
|
|
|
|
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
format.json {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_project_names_list
|
|
|
|
if params[:term].present?
|
|
|
|
@projects = ProjectPolicy::Scope.new(current_user, Project).membered
|
|
|
|
|
|
|
|
@projects = @projects.where(owner_uname: params[:owner_uname]) if params[:owner_uname].present?
|
|
|
|
@projects = @projects.by_name("%#{params[:term]}%")
|
|
|
|
.distinct
|
|
|
|
.pluck(:name)
|
|
|
|
.first(10)
|
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
format.json {}
|
|
|
|
end
|
|
|
|
end
|
2015-03-26 00:26:24 +00:00
|
|
|
end
|