Unverified Commit 8210d813 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Replace old references of users_project & users_group


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent de57579852b2
......@@ -3,8 +3,8 @@ class Profiles::NotificationsController < ApplicationController
def show
@notification = current_user.notification
@users_projects = current_user.project_members
@users_groups = current_user.group_members
@project_members = current_user.project_members
@group_members = current_user.group_members
end
def update
......
......@@ -6,7 +6,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
def index
@group = @project.group
@users_projects = @project.project_members.order('access_level DESC')
@project_members = @project.project_members.order('access_level DESC')
end
def new
......
......@@ -79,8 +79,8 @@ class Project < ActiveRecord::Base
has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet"
has_many :hooks, dependent: :destroy, class_name: "ProjectHook"
has_many :protected_branches, dependent: :destroy
has_many :users_projects, dependent: :destroy
has_many :users, through: :users_projects
has_many :project_members, dependent: :destroy, as: :source, class_name: 'ProjectMember'
has_many :users, through: :project_members
has_many :deploy_keys_projects, dependent: :destroy
has_many :deploy_keys, through: :deploy_keys_projects
has_many :users_star_projects, dependent: :destroy
......@@ -353,12 +353,12 @@ def owner
def team_member_by_name_or_email(name = nil, email = nil)
user = users.where("name like ? or email like ?", name, email).first
users_projects.where(user: user) if user
project_members.where(user: user) if user
end
# Get Team Member record by user id
def team_member_by_id(user_id)
users_projects.find_by(user_id: user_id)
project_members.find_by(user_id: user_id)
end
def name_with_namespace
......@@ -555,7 +555,7 @@ def reset_events_cache
end
def project_member(user)
users_projects.where(user_id: user).first
project_members.where(user_id: user).first
end
def default_branch
......
......@@ -91,13 +91,13 @@ class User < ActiveRecord::Base
# Projects
has_many :groups_projects, through: :groups, source: :projects
has_many :personal_projects, through: :namespace, source: :projects
has_many :projects, through: :users_projects
has_many :projects, through: :project_members
has_many :created_projects, foreign_key: :creator_id, class_name: 'Project'
has_many :users_star_projects, dependent: :destroy
has_many :starred_projects, through: :users_star_projects, source: :project
has_many :snippets, dependent: :destroy, foreign_key: :author_id, class_name: "Snippet"
has_many :users_projects, dependent: :destroy
has_many :project_members, dependent: :destroy
has_many :issues, dependent: :destroy, foreign_key: :author_id
has_many :notes, dependent: :destroy, foreign_key: :author_id
has_many :merge_requests, dependent: :destroy, foreign_key: :author_id
......@@ -177,7 +177,7 @@ class User < ActiveRecord::Base
scope :in_team, ->(team){ where(id: team.member_ids) }
scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) }
scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all }
scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') }
scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM project_members)') }
scope :ldap, -> { where(provider: 'ldap') }
scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active }
......
......@@ -101,7 +101,7 @@
%i.icon-edit
%ul.well-list
- @group_members.each do |member|
= render 'users_groups/users_group', member: member, show_controls: false
= render 'group_members/users_group', member: member, show_controls: false
.panel-footer
= paginate @group_members, param_name: 'group_members_page', theme: 'gitlab'
......
= form_for @users_group, url: group_users_groups_path(@group), html: { class: 'form-horizontal users-group-form' } do |f|
= form_for @users_group, url: group_group_members_path(@group), html: { class: 'form-horizontal users-group-form' } do |f|
.form-group
= f.label :user_ids, "People", class: 'control-label'
.col-sm-10= users_select_tag(:user_ids, multiple: true, class: 'input-large')
......
......@@ -32,7 +32,7 @@
(#{@members.total_count})
%ul.well-list
- @members.each do |member|
= render 'users_groups/users_group', member: member, show_roles: show_roles, show_controls: true
= render 'group_members/users_group', member: member, show_roles: show_roles, show_controls: true
= paginate @members, theme: 'gitlab'
:coffeescript
......
......@@ -39,13 +39,13 @@
.col-md-6
%h4 Groups:
%ul.bordered-list
- @users_groups.each do |users_group|
- @group_members.each do |users_group|
- notification = Notification.new(users_group)
= render 'settings', type: 'group', membership: users_group, notification: notification
.col-md-6
%h4 Projects:
%ul.bordered-list
- @users_projects.each do |users_project|
- @project_members.each do |users_project|
- notification = Notification.new(users_project)
= render 'settings', type: 'project', membership: users_project, notification: notification
......@@ -8,7 +8,7 @@
%i.icon-edit
%ul.well-list
- @group.group_members.order('access_level DESC').limit(20).each do |member|
= render 'users_groups/users_group', member: member, show_controls: false
= render 'group_members/users_group', member: member, show_controls: false
- if group_users_count > 20
%li
and #{group_users_count - 20} more. For full list visit #{link_to 'group members page', members_group_path(@group)}
......@@ -11,6 +11,6 @@
%p.light
Read more about project permissions
%strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink"
= render "team", members: @users_projects
= render "team", members: @project_members
- if @group
= render "group_members"
......@@ -17,7 +17,7 @@ namespace :gitlab do
check_database_config_exists
check_database_is_not_sqlite
check_migrations_are_up
check_orphaned_users_groups
check_orphaned_group_members
check_gitlab_config_exists
check_gitlab_config_not_outdated
check_log_writable
......@@ -194,7 +194,7 @@ namespace :gitlab do
end
end
def check_orphaned_users_groups
def check_orphaned_group_members
print "Database contains orphaned GroupMembers? ... "
if GroupMember.where("user_id not in (select id from users)").count > 0
puts "yes".red
......
# == Schema Information
#
# Table name: users_groups
# Table name: group_members
#
# id :integer not null, primary key
# group_access :integer not null
......
# == Schema Information
#
# Table name: users_groups
# Table name: group_members
#
# id :integer not null, primary key
# group_access :integer not null
......
......@@ -20,7 +20,7 @@
describe "Associations" do
it { should have_many :projects }
it { should have_many :users_groups }
it { should have_many :group_members }
end
it { should validate_presence_of :name }
......
# == Schema Information
#
# Table name: users_projects
# Table name: project_members
#
# id :integer not null, primary key
# user_id :integer not null
......
......@@ -38,7 +38,7 @@
it { should have_many(:merge_requests).dependent(:destroy) }
it { should have_many(:issues).dependent(:destroy) }
it { should have_many(:milestones).dependent(:destroy) }
it { should have_many(:users_projects).dependent(:destroy) }
it { should have_many(:project_members).dependent(:destroy) }
it { should have_many(:notes).dependent(:destroy) }
it { should have_many(:snippets).class_name('ProjectSnippet').dependent(:destroy) }
it { should have_many(:deploy_keys_projects).dependent(:destroy) }
......
......@@ -52,7 +52,7 @@
describe "Associations" do
it { should have_one(:namespace) }
it { should have_many(:snippets).class_name('Snippet').dependent(:destroy) }
it { should have_many(:users_projects).dependent(:destroy) }
it { should have_many(:project_members).dependent(:destroy) }
it { should have_many(:groups) }
it { should have_many(:keys).dependent(:destroy) }
it { should have_many(:events).class_name('Event').dependent(:destroy) }
......
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