diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/teams/application_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/teams/projects_controller.rb | 22 | ||||
-rw-r--r-- | app/helpers/user_teams_helper.rb | 2 | ||||
-rw-r--r-- | app/views/teams/members/_show.html.haml | 2 |
4 files changed, 22 insertions, 6 deletions
diff --git a/app/controllers/teams/application_controller.rb b/app/controllers/teams/application_controller.rb index 1cfb0e0991a..f1ecb5b2ce8 100644 --- a/app/controllers/teams/application_controller.rb +++ b/app/controllers/teams/application_controller.rb @@ -1,6 +1,4 @@ class Teams::ApplicationController < ApplicationController - before_filter :user_team, only: [:index, :show, :edit, :update, :destroy, :issues, :merge_requests, :search, :members] - protected def user_team diff --git a/app/controllers/teams/projects_controller.rb b/app/controllers/teams/projects_controller.rb index 796f37f6d5d..84de96861fb 100644 --- a/app/controllers/teams/projects_controller.rb +++ b/app/controllers/teams/projects_controller.rb @@ -1,21 +1,39 @@ class Teams::ProjectsController < Teams::ApplicationController def index - @projects = @user_team.projects - @avaliable_projects = current_user.admin? ? Project.without_team(@user_team) : (Project.personal(current_user) + current_user.projects).uniq + @projects = user_team.projects + @avaliable_projects = current_user.admin? ? Project.without_team(user_team) : (Project.personal(current_user) + current_user.projects).uniq end def new + @projects = Project.scoped + @projects = @projects.without_team(user_team) if user_team.projects.any? + #@projects.reject!(&:empty_repo?) end def create + unless params[:project_ids].blank? + project_ids = params[:project_ids] + access = params[:greatest_project_access] + user_team.assign_to_projects(project_ids, access) + end + + redirect_to admin_team_path(user_team), notice: 'Projects was successfully added.' end def edit + @user_team = user_team end def update + if user_team.update_project_access(project, params[:greatest_project_access]) + redirect_to admin_team_path(user_team), notice: 'Membership was successfully updated.' + else + render :edit + end end def destroy + user_team.resign_from_project(project) + redirect_to admin_team_path(user_team), notice: 'Project was successfully removed.' end end diff --git a/app/helpers/user_teams_helper.rb b/app/helpers/user_teams_helper.rb index 01e10de52fb..60deb9e09e5 100644 --- a/app/helpers/user_teams_helper.rb +++ b/app/helpers/user_teams_helper.rb @@ -19,7 +19,7 @@ module UserTeamsHelper team.user_team_user_relationships.sort_by(&:permission).reverse.group_by(&:permission) end - def remove_from_team_message(team, member) + def remove_from_user_team_message(team, member) "You are going to remove #{member.name} from #{team.name}. Are you sure?" end diff --git a/app/views/teams/members/_show.html.haml b/app/views/teams/members/_show.html.haml index dfe73c77652..a06d269ac00 100644 --- a/app/views/teams/members/_show.html.haml +++ b/app/views/teams/members/_show.html.haml @@ -27,5 +27,5 @@ - elsif user.blocked %span.btn.disabled.blocked Blocked - elsif allow_admin - = link_to team_member_path(@user_team, user), confirm: remove_from_team_message(@user_team, user), method: :delete, class: "very_small btn danger" do + = link_to team_member_path(@user_team, user), confirm: remove_from_user_team_message(@user_team, user), method: :delete, class: "very_small btn danger" do %i.icon-minus.icon-white |