summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/groups_controller.rb4
-rw-r--r--app/controllers/dashboard_controller.rb5
-rw-r--r--app/controllers/graphs_controller.rb2
-rw-r--r--app/controllers/groups_controller.rb19
-rw-r--r--app/controllers/issues_controller.rb2
-rw-r--r--app/controllers/team_members_controller.rb6
-rw-r--r--app/controllers/users_controller.rb2
-rw-r--r--app/controllers/users_groups_controller.rb40
8 files changed, 53 insertions, 27 deletions
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index c38461c89db..6e6c8d54e29 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -66,14 +66,12 @@ class Admin::GroupsController < Admin::ApplicationController
end
def project_teams_update
- @group.add_users_to_project_teams(params[:user_ids].split(','), params[:project_access])
+ @group.add_users(params[:user_ids].split(','), params[:group_access])
redirect_to [:admin, @group], notice: 'Users were successfully added.'
end
def destroy
- @group.truncate_teams
-
@group.destroy
redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index b74c22b1547..9b3f59600c6 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -34,11 +34,12 @@ class DashboardController < ApplicationController
@projects
end
- @projects = @projects.tagged_with(params[:label]) if params[:label].present?
@projects = @projects.search(params[:search]) if params[:search].present?
- @projects = @projects.page(params[:page]).per(30)
@labels = Project.where(id: @projects.map(&:id)).tags_on(:labels)
+
+ @projects = @projects.tagged_with(params[:label]) if params[:label].present?
+ @projects = @projects.page(params[:page]).per(30)
end
# Get authored or assigned open merge requests
diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb
index 5ae9c15c0f7..6c2ac5fcbf4 100644
--- a/app/controllers/graphs_controller.rb
+++ b/app/controllers/graphs_controller.rb
@@ -10,7 +10,7 @@ class GraphsController < ProjectResourceController
format.js do
@repo = @project.repository
@stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref)
- @log = @stats.parsed_log.to_json
+ @log = @stats.parsed_log.to_json rescue []
end
end
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index e6559b8d8fe..f44bc10cf39 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -1,6 +1,6 @@
class GroupsController < ApplicationController
respond_to :html
- before_filter :group, except: [:new, :create]
+ before_filter :group, except: [:new, :create, :people]
# Authorize
before_filter :authorize_read_group!, except: [:new, :create]
@@ -63,19 +63,8 @@ class GroupsController < ApplicationController
def people
@project = group.projects.find(params[:project_id]) if params[:project_id]
- @users = @project ? @project.users : group.users
- @users.sort_by!(&:name)
-
- if @project
- @team_member = @project.users_projects.new
- else
- @team_member = UsersProject.new
- end
- end
-
- def team_members
- @group.add_users_to_project_teams(params[:user_ids].split(','), params[:project_access])
- redirect_to people_group_path(@group), notice: 'Users were successfully added.'
+ @members = group.users_groups.order('group_access DESC')
+ @users_group = UsersGroup.new
end
def edit
@@ -83,7 +72,7 @@ class GroupsController < ApplicationController
def update
group_params = params[:group].dup
- owner_id =group_params.delete(:owner_id)
+ owner_id = group_params.delete(:owner_id)
if owner_id
@group.owner = User.find(owner_id)
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index ba92ba2bdae..65e72792924 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -23,7 +23,7 @@ class IssuesController < ProjectResourceController
assignee_id, milestone_id = params[:assignee_id], params[:milestone_id]
- @assignee = @project.users.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero?
+ @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero?
@milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero?
respond_to do |format|
diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb
index 35aa315dac1..095d7a3af55 100644
--- a/app/controllers/team_members_controller.rb
+++ b/app/controllers/team_members_controller.rb
@@ -4,10 +4,8 @@ class TeamMembersController < ProjectResourceController
before_filter :authorize_admin_project!, except: [:index, :show]
def index
- @team = @project.users_projects.scoped
- @team = @team.send(params[:type]) if %w(masters developers reporters guests).include?(params[:type])
- @team = @team.sort_by(&:project_access).reverse.group_by(&:project_access)
-
+ @group = @project.group
+ @users_projects = @project.users_projects.order('project_access DESC')
@assigned_teams = @project.user_team_project_relationships
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 4947c33f959..028af8ff59f 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -3,7 +3,7 @@ class UsersController < ApplicationController
def show
@user = User.find_by_username!(params[:username])
- @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id))
+ @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)).order('namespace_id DESC')
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
@title = @user.name
diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb
new file mode 100644
index 00000000000..ebc79d621a4
--- /dev/null
+++ b/app/controllers/users_groups_controller.rb
@@ -0,0 +1,40 @@
+class UsersGroupsController < ApplicationController
+ before_filter :group
+
+ # Authorize
+ before_filter :authorize_admin_group!
+
+ layout 'group'
+
+ def create
+ @group.add_users(params[:user_ids].split(','), params[:group_access])
+
+ redirect_to people_group_path(@group), notice: 'Users were successfully added.'
+ end
+
+ def update
+ # TODO: implement
+ end
+
+ def destroy
+ @users_group = @group.users_groups.find(params[:id])
+ @users_group.destroy
+
+ respond_to do |format|
+ format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' }
+ format.js { render nothing: true }
+ end
+ end
+
+ protected
+
+ def group
+ @group ||= Group.find_by_path(params[:group_id])
+ end
+
+ def authorize_admin_group!
+ unless can?(current_user, :manage_group, group)
+ return render_404
+ end
+ end
+end