gitlabhq/app/controllers/admin/projects_controller.rb

51 lines
1.3 KiB
Ruby
Raw Normal View History

class Admin::ProjectsController < AdminController
before_filter :project, only: [:edit, :show, :update, :destroy, :team_update]
2011-10-08 23:36:38 +02:00
def index
@projects = Project.scoped
2012-11-23 05:24:09 +01:00
@projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
@projects = @projects.search(params[:name]) if params[:name].present?
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
2011-10-08 23:36:38 +02:00
end
def show
2012-07-31 07:32:49 +02:00
@users = User.scoped
@users = @users.not_in_project(@project) if @project.users.present?
2012-07-31 07:32:49 +02:00
@users = @users.all
2011-10-08 23:36:38 +02:00
end
def edit
end
def team_update
@project.add_users_ids_to_team(params[:user_ids], params[:project_access])
2011-10-08 23:36:38 +02:00
redirect_to [:admin, @project], notice: 'Project was successfully updated.'
2011-10-08 23:36:38 +02:00
end
def update
status = ProjectUpdateContext.new(project, current_user, params).execute(:admin)
if status
redirect_to [:admin, @project], notice: 'Project was successfully updated.'
2011-10-27 15:44:29 +02:00
else
render action: "edit"
2011-10-08 23:36:38 +02:00
end
end
def destroy
@project.destroy
2012-07-31 07:32:49 +02:00
2012-11-26 01:22:44 +01:00
redirect_to admin_projects_path, notice: 'Project was successfully deleted.'
2012-07-31 07:32:49 +02:00
end
protected
def project
id = params[:project_id] || params[:id]
@project = Project.find_with_namespace(id)
@project || render_404
end
2011-10-08 23:36:38 +02:00
end