Commit 0bc714c2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove form for adding user to several projects from admin area.

Remove unnecessary projects order on User#show
parent 19d628dd
...@@ -9,11 +9,6 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -9,11 +9,6 @@ class Admin::UsersController < Admin::ApplicationController
end end
def show def show
# Projects user can be added to
@not_in_projects = Project.scoped
@not_in_projects = @not_in_projects.without_user(admin_user) if admin_user.authorized_projects.present?
# Projects he already own or joined
@projects = admin_user.authorized_projects @projects = admin_user.authorized_projects
end end
......
...@@ -3,7 +3,7 @@ class UsersController < ApplicationController ...@@ -3,7 +3,7 @@ class UsersController < ApplicationController
def show def show
@user = User.find_by_username!(params[:username]) @user = User.find_by_username!(params[:username])
@projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)).order('namespace_id DESC') @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id))
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
@title = @user.name @title = @user.name
......
...@@ -63,28 +63,6 @@ ...@@ -63,28 +63,6 @@
%strong %strong
= link_to @admin_user.created_by.name, [:admin, @admin_user.created_by] = link_to @admin_user.created_by.name, [:admin, @admin_user.created_by]
%hr
%h5
Add User to Projects
%small
Read more about project permissions
%strong= link_to "here", help_permissions_path, class: "vlink"
%br
= form_tag team_update_admin_user_path(@admin_user), class: "bulk_import", method: :put do
.control-group
= label_tag :project_ids, "Projects", class: 'control-label'
.controls
= select_tag :project_ids, options_from_collection_for_select(@not_in_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span3'
.control-group
= label_tag :project_access, "Project Access", class: 'control-label'
.controls
= select_tag :project_access, options_for_select(Project.access_options), class: "project-access-select chosen span3"
.form-actions
= submit_tag 'Add', class: "btn btn-create"
.pull-right
%br
- if @admin_user.owned_groups.present? - if @admin_user.owned_groups.present?
.ui-box .ui-box
%h5.title Owned groups: %h5.title Owned groups:
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
.ui-box .ui-box
%h5.title %h5.title
Projects (#{@projects.total_count}) Projects (#{@projects.total_count})
.pull-right.light
%small Last activity
%ul.well-list %ul.well-list
- @projects.each do |project| - @projects.each do |project|
%li %li
...@@ -39,7 +41,7 @@ ...@@ -39,7 +41,7 @@
= truncate project.description, length: 80 = truncate project.description, length: 80
.pull-right.light .pull-right.light
%small Last activity #{project_last_activity(project)} %small #{project_last_activity(project)}
- if @projects.blank? - if @projects.blank?
%li %li
......
...@@ -27,6 +27,7 @@ FactoryGirl.define do ...@@ -27,6 +27,7 @@ FactoryGirl.define do
sequence(:name) { |n| "project#{n}" } sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
creator creator
namespace { creator.namespace }
end end
factory :redmine_project, parent: :project do factory :redmine_project, parent: :project do
......
...@@ -109,18 +109,4 @@ describe "Admin::Users" do ...@@ -109,18 +109,4 @@ describe "Admin::Users" do
end end
end end
end end
describe "Add new project" do
before do
@new_project = create(:project)
visit admin_user_path(@user)
end
it "should create new user" do
select @new_project.name, from: "project_ids"
expect { click_button "Add" }.to change { UsersProject.count }.by(1)
page.should have_content @new_project.name
current_path.should == admin_user_path(@user)
end
end
end end
...@@ -111,12 +111,8 @@ describe User do ...@@ -111,12 +111,8 @@ describe User do
@project_2 = create :project # Grant MASTER access to the user @project_2 = create :project # Grant MASTER access to the user
@project_3 = create :project # Grant DEVELOPER access to the user @project_3 = create :project # Grant DEVELOPER access to the user
UsersProject.add_users_into_projects( @project_2.team << [@user, :master]
[@project_2.id], [@user.id], UsersProject::MASTER @project_3.team << [@user, :developer]
)
UsersProject.add_users_into_projects(
[@project_3.id], [@user.id], UsersProject::DEVELOPER
)
end end
it { @user.authorized_projects.should include(@project) } it { @user.authorized_projects.should include(@project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment