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
end
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
end
......
......@@ -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)).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)
@title = @user.name
......
......@@ -63,28 +63,6 @@
%strong
= 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?
.ui-box
%h5.title Owned groups:
......
......@@ -24,6 +24,8 @@
.ui-box
%h5.title
Projects (#{@projects.total_count})
.pull-right.light
%small Last activity
%ul.well-list
- @projects.each do |project|
%li
......@@ -39,7 +41,7 @@
= truncate project.description, length: 80
.pull-right.light
%small Last activity #{project_last_activity(project)}
%small #{project_last_activity(project)}
- if @projects.blank?
%li
......
......@@ -27,6 +27,7 @@ FactoryGirl.define do
sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') }
creator
namespace { creator.namespace }
end
factory :redmine_project, parent: :project do
......
......@@ -109,18 +109,4 @@ describe "Admin::Users" do
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
......@@ -111,12 +111,8 @@ describe User do
@project_2 = create :project # Grant MASTER access to the user
@project_3 = create :project # Grant DEVELOPER access to the user
UsersProject.add_users_into_projects(
[@project_2.id], [@user.id], UsersProject::MASTER
)
UsersProject.add_users_into_projects(
[@project_3.id], [@user.id], UsersProject::DEVELOPER
)
@project_2.team << [@user, :master]
@project_3.team << [@user, :developer]
end
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