move Team_members controller into project (conflicts with team/members controller)
This commit is contained in:
parent
497f7ab5ba
commit
1dd0feacc7
11
app/controllers/admin/projects/application_controller.rb
Normal file
11
app/controllers/admin/projects/application_controller.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Provides a base class for Admin controllers to subclass
|
||||
#
|
||||
# Automatically sets the layout and ensures an administrator is logged in
|
||||
class Admin::Projects::ApplicationController < Admin::ApplicationController
|
||||
|
||||
protected
|
||||
|
||||
def project
|
||||
@project ||= Project.find_by_path(params[:project_id])
|
||||
end
|
||||
end
|
32
app/controllers/admin/projects/members_controller.rb
Normal file
32
app/controllers/admin/projects/members_controller.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
class Admin::Projects::MembersController < Admin::Projects::ApplicationController
|
||||
def edit
|
||||
@member = team_member
|
||||
@project = project
|
||||
@team_member_relation = team_member_relation
|
||||
end
|
||||
|
||||
def update
|
||||
if team_member_relation.update_attributes(params[:team_member])
|
||||
redirect_to [:admin, project], notice: 'Project Access was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
team_member_relation.destroy
|
||||
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def team_member
|
||||
@member ||= project.users.find(params[:id])
|
||||
end
|
||||
|
||||
def team_member_relation
|
||||
team_member.users_projects.find_by_project_id(project)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
class Admin::TeamMembersController < Admin::ApplicationController
|
||||
def edit
|
||||
@admin_team_member = UsersProject.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@admin_team_member = UsersProject.find(params[:id])
|
||||
|
||||
if @admin_team_member.update_attributes(params[:team_member])
|
||||
redirect_to [:admin, @admin_team_member.project], notice: 'Project Access was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@admin_team_member = UsersProject.find(params[:id])
|
||||
@admin_team_member.destroy
|
||||
|
||||
redirect_to :back
|
||||
end
|
||||
end
|
|
@ -494,6 +494,11 @@ class Project < ActiveRecord::Base
|
|||
http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('')
|
||||
end
|
||||
|
||||
def project_access_human(member)
|
||||
project_user_relation = self.users_projects.find_by_user_id(member.id)
|
||||
self.class.access_options.key(project_user_relation.project_access)
|
||||
end
|
||||
|
||||
# Check if current branch name is marked as protected in the system
|
||||
def protected_branch? branch_name
|
||||
protected_branches.map(&:name).include?(branch_name)
|
||||
|
|
16
app/views/admin/projects/members/_form.html.haml
Normal file
16
app/views/admin/projects/members/_form.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
|||
= form_for @team_member_relation, as: :team_member, url: admin_project_member_path(@project, @member) do |f|
|
||||
-if @team_member_relation.errors.any?
|
||||
.alert-message.block-message.error
|
||||
%ul
|
||||
- @team_member_relation.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.clearfix
|
||||
%label Project Access:
|
||||
.input
|
||||
= f.select :project_access, options_for_select(Project.access_options, @team_member_relation.project_access), {}, class: "project-access-select chosen span3"
|
||||
|
||||
%br
|
||||
.actions
|
||||
= f.submit 'Save', class: "btn primary"
|
||||
= link_to 'Cancel', :back, class: "btn"
|
8
app/views/admin/projects/members/edit.html.haml
Normal file
8
app/views/admin/projects/members/edit.html.haml
Normal file
|
@ -0,0 +1,8 @@
|
|||
%p.slead
|
||||
Edit access for
|
||||
= link_to @member.name, admin_user_path(@member)
|
||||
in
|
||||
= link_to @project.name_with_namespace, admin_project_path(@project)
|
||||
|
||||
%hr
|
||||
= render 'form'
|
|
@ -114,7 +114,7 @@
|
|||
%h5
|
||||
Team
|
||||
%small
|
||||
(#{@project.users_projects.count})
|
||||
(#{@project.users.count})
|
||||
%br
|
||||
%table.zebra-striped.team_members
|
||||
%thead
|
||||
|
@ -124,13 +124,13 @@
|
|||
%th Repository Access
|
||||
%th
|
||||
|
||||
- @project.users_projects.each do |tm|
|
||||
- @project.users.each do |tm|
|
||||
%tr
|
||||
%td
|
||||
= link_to tm.user_name, admin_user_path(tm.user)
|
||||
%td= tm.project_access_human
|
||||
%td= link_to 'Edit Access', edit_admin_team_member_path(tm), class: "btn small"
|
||||
%td= link_to 'Remove from team', admin_team_member_path(tm), confirm: 'Are you sure?', method: :delete, class: "btn danger small"
|
||||
= link_to tm.name, admin_user_path(tm)
|
||||
%td= @project.project_access_human(tm)
|
||||
%td= link_to 'Edit Access', edit_admin_project_member_path(@project, tm), class: "btn small"
|
||||
%td= link_to 'Remove from team', admin_project_member_path(@project, tm), confirm: 'Are you sure?', method: :delete, class: "btn danger small"
|
||||
|
||||
%br
|
||||
%h5 Add new team member
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
= form_for @admin_team_member, as: :team_member, url: admin_team_member_path(@admin_team_member) do |f|
|
||||
-if @admin_team_member.errors.any?
|
||||
.alert-message.block-message.error
|
||||
%ul
|
||||
- @admin_team_member.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.clearfix
|
||||
%label Project Access:
|
||||
.input
|
||||
= f.select :project_access, options_for_select(Project.access_options, @admin_team_member.project_access), {}, class: "project-access-select chosen span3"
|
||||
|
||||
%br
|
||||
.actions
|
||||
= f.submit 'Save', class: "btn primary"
|
||||
= link_to 'Cancel', :back, class: "btn"
|
|
@ -1,8 +0,0 @@
|
|||
%p.slead
|
||||
Edit access for
|
||||
= link_to @admin_team_member.user_name, admin_user_path(@admin_team_member)
|
||||
in
|
||||
= link_to @admin_team_member.project.name_with_namespace, admin_project_path(@admin_team_member)
|
||||
|
||||
%hr
|
||||
= render 'form'
|
|
@ -68,6 +68,9 @@ Gitlab::Application.routes.draw do
|
|||
get :team
|
||||
put :team_update
|
||||
end
|
||||
scope module: :projects do
|
||||
resources :members, only: [:edit, :update, :destroy]
|
||||
end
|
||||
end
|
||||
resources :teams do #, constraints: { id: /[^\/]+/ } do end
|
||||
scope module: :teams do
|
||||
|
@ -75,7 +78,6 @@ Gitlab::Application.routes.draw do
|
|||
resources :projects, only: [:edit, :update, :destroy, :new, :create]
|
||||
end
|
||||
end
|
||||
resources :team_members, only: [:edit, :update, :destroy]
|
||||
resources :hooks, only: [:index, :create, :destroy] do
|
||||
get :test
|
||||
end
|
||||
|
|
26
spec/controllers/admin/projects/members_controller_spec.rb
Normal file
26
spec/controllers/admin/projects/members_controller_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::Projects::MembersController do
|
||||
|
||||
describe "GET 'edit'" do
|
||||
it "returns http success" do
|
||||
get 'edit'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'update'" do
|
||||
it "returns http success" do
|
||||
get 'update'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'destroy'" do
|
||||
it "returns http success" do
|
||||
get 'destroy'
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue