debian-mirror-gitlab/app/controllers/dashboard/projects_controller.rb

69 lines
1.7 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class Dashboard::ProjectsController < Dashboard::ApplicationController
2017-08-17 22:00:37 +05:30
include ParamsBackwardCompatibility
2018-03-17 18:26:18 +05:30
include RendersMemberAccess
2016-06-02 11:05:42 +05:30
2017-08-17 22:00:37 +05:30
before_action :set_non_archived_param
before_action :default_sorting
2018-03-27 19:54:05 +05:30
skip_cross_project_access_check :index, :starred
2015-04-26 12:48:37 +05:30
2015-09-25 12:07:36 +05:30
def index
2018-11-08 19:23:39 +05:30
@projects = load_projects(params.merge(non_public: true))
2015-09-25 12:07:36 +05:30
respond_to do |format|
2017-09-10 17:25:29 +05:30
format.html
2015-09-25 12:07:36 +05:30
format.atom do
load_events
2017-09-10 17:25:29 +05:30
render layout: 'xml.atom'
2015-09-25 12:07:36 +05:30
end
2016-04-02 18:10:28 +05:30
format.json do
render json: {
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
}
end
2015-09-25 12:07:36 +05:30
end
end
2015-04-26 12:48:37 +05:30
def starred
2017-09-10 17:25:29 +05:30
@projects = load_projects(params.merge(starred: true))
2018-11-08 19:23:39 +05:30
.includes(:forked_from_project, :tags)
2016-04-02 18:10:28 +05:30
2015-04-26 12:48:37 +05:30
@groups = []
respond_to do |format|
format.html
format.json do
2016-04-02 18:10:28 +05:30
render json: {
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
}
2015-04-26 12:48:37 +05:30
end
end
end
private
2017-08-17 22:00:37 +05:30
def default_sorting
params[:sort] ||= 'latest_activity_desc'
@sort = params[:sort]
end
def load_projects(finder_params)
2018-03-17 18:26:18 +05:30
projects = ProjectsFinder
.new(params: finder_params, current_user: current_user)
.execute
.includes(:route, :creator, namespace: [:route, :owner])
2018-11-08 19:23:39 +05:30
.page(finder_params[:page])
2018-03-17 18:26:18 +05:30
prepare_projects_for_rendering(projects)
2017-08-17 22:00:37 +05:30
end
2015-04-26 12:48:37 +05:30
def load_events
2017-09-10 17:25:29 +05:30
projects = load_projects(params.merge(non_public: true))
@events = EventCollection
.new(projects, offset: params[:offset].to_i, filter: event_filter)
.to_a
2018-03-17 18:26:18 +05:30
Events::RenderService.new(current_user).execute(@events, atom_request: request.format.atom?)
2015-04-26 12:48:37 +05:30
end
end