2013-05-15 18:28:39 +01:00
|
|
|
class HomeController < ApplicationController
|
2014-03-30 06:45:52 +01:00
|
|
|
layout 'bootstrap'
|
2014-01-21 04:51:49 +00:00
|
|
|
before_filter :authenticate_user!, only: [:activity, :issues, :pull_requests]
|
2013-05-15 18:28:39 +01:00
|
|
|
|
|
|
|
def root
|
2014-01-21 04:51:49 +00:00
|
|
|
render 'pages/tour/abf-tour-project-description-1', layout: 'tour'
|
2013-05-15 18:28:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def activity
|
|
|
|
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
|
|
|
|
@activity_feeds = current_user.activity_feeds
|
2014-01-21 04:51:49 +00:00
|
|
|
@activity_feeds = @activity_feeds.where(kind: "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
|
2014-05-06 10:51:04 +01:00
|
|
|
@activity_feeds = @activity_feeds.paginate page: current_page
|
2014-04-11 09:57:00 +01:00
|
|
|
|
2013-05-15 18:28:39 +01:00
|
|
|
respond_to do |format|
|
2014-05-12 11:02:48 +01:00
|
|
|
format.html { render 'activity' }
|
2014-04-08 14:11:34 +01:00
|
|
|
format.json {}
|
2013-05-15 18:28:39 +01:00
|
|
|
format.atom
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def issues
|
|
|
|
@created_issues = current_user.issues
|
2014-01-21 04:51:49 +00:00
|
|
|
@assigned_issues = Issue.where(assignee_id: current_user.id)
|
2013-05-15 18:28:39 +01:00
|
|
|
pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id)
|
2014-01-21 04:51:49 +00:00
|
|
|
@all_issues = Issue.where(project_id: pr_ids)
|
2013-05-15 18:28:39 +01:00
|
|
|
@created_issues, @assigned_issues, @all_issues =
|
|
|
|
if action_name == 'issues'
|
|
|
|
[@created_issues.without_pull_requests,
|
|
|
|
@assigned_issues.without_pull_requests,
|
|
|
|
@all_issues.without_pull_requests]
|
|
|
|
else
|
|
|
|
[@created_issues.joins(:pull_request),
|
|
|
|
@assigned_issues.joins(:pull_request),
|
|
|
|
@all_issues.joins(:pull_request)]
|
|
|
|
end
|
|
|
|
|
|
|
|
case params[:filter]
|
|
|
|
when 'created'
|
|
|
|
@issues = @created_issues
|
|
|
|
when 'assigned'
|
|
|
|
@issues = @assigned_issues
|
|
|
|
else
|
|
|
|
params[:filter] = 'all' # default
|
|
|
|
@issues = @all_issues
|
|
|
|
end
|
|
|
|
@filter = params[:filter]
|
2014-05-06 10:51:04 +01:00
|
|
|
@opened_issues, @closed_issues = @issues.not_closed_or_merged, @issues.closed_or_merged
|
2013-05-15 18:28:39 +01:00
|
|
|
|
|
|
|
@status = params[:status] == 'closed' ? :closed : :open
|
|
|
|
@issues = @issues.send( (@status == :closed) ? :closed_or_merged : :not_closed_or_merged )
|
|
|
|
|
|
|
|
@sort = params[:sort] == 'updated' ? :updated : :created
|
|
|
|
@direction = params[:direction] == 'asc' ? :asc : :desc
|
|
|
|
@issues = @issues.order("issues.#{@sort}_at #{@direction}")
|
|
|
|
.includes(:assignee, :user, :pull_request).uniq
|
2014-05-06 10:51:04 +01:00
|
|
|
.paginate page: current_page
|
2014-05-05 20:16:15 +01:00
|
|
|
|
|
|
|
respond_to do |format|
|
2014-05-12 11:02:48 +01:00
|
|
|
format.html { render 'activity' }
|
2014-05-05 20:16:15 +01:00
|
|
|
format.json { render 'issues' }
|
|
|
|
end
|
2013-05-15 18:28:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def pull_requests
|
|
|
|
issues
|
|
|
|
end
|
|
|
|
end
|