Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
59d43bea
Commit
59d43bea
authored
Nov 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sort functionality for group/project members
parent
f54ddbf1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
12 deletions
+28
-12
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+4
-10
app/models/member.rb
app/models/member.rb
+20
-0
app/models/user.rb
app/models/user.rb
+4
-2
No files found.
app/controllers/groups/group_members_controller.rb
View file @
59d43bea
...
...
@@ -6,19 +6,13 @@ class Groups::GroupMembersController < Groups::ApplicationController
def
index
@project
=
@group
.
projects
.
find
(
params
[
:project_id
])
if
params
[
:project_id
]
@members
=
@group
.
group_members
@members
=
@members
.
non_invite
unless
can?
(
current_user
,
:admin_group
,
@group
)
if
params
[
:search
].
present?
@members
=
@members
.
joins
(
:user
).
merge
(
User
.
search
(
params
[
:search
]))
end
if
params
[
:sort
].
present?
@members
=
@members
.
joins
(
:user
).
merge
(
User
.
sort
(
@sort
=
params
[
:sort
]))
end
@members
=
@members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@members
=
@members
.
sort
(
@sort
=
params
[
:sort
])
if
params
[
:sort
].
present?
@members
=
@members
.
page
(
params
[
:page
]).
per
(
50
)
@requesters
=
AccessRequestsFinder
.
new
(
@group
).
execute
(
current_user
)
@group_member
=
@group
.
group_members
.
new
...
...
app/models/member.rb
View file @
59d43bea
...
...
@@ -57,6 +57,11 @@ class Member < ActiveRecord::Base
scope
:owners
,
->
{
active
.
where
(
access_level:
OWNER
)
}
scope
:owners_and_masters
,
->
{
active
.
where
(
access_level:
[
OWNER
,
MASTER
])
}
scope
:order_name_asc
,
->
{
joins
(
:user
).
merge
(
User
.
order_name_asc
)
}
scope
:order_name_desc
,
->
{
joins
(
:user
).
merge
(
User
.
order_name_desc
)
}
scope
:order_recent_sign_in
,
->
{
joins
(
:user
).
merge
(
User
.
order_recent_sign_in
)
}
scope
:order_oldest_sign_in
,
->
{
joins
(
:user
).
merge
(
User
.
order_oldest_sign_in
)
}
before_validation
:generate_invite_token
,
on: :create
,
if:
->
(
member
)
{
member
.
invite_email
.
present?
}
after_create
:send_invite
,
if: :invite?
,
unless: :importing?
...
...
@@ -72,6 +77,21 @@ class Member < ActiveRecord::Base
default_value_for
:notification_level
,
NotificationSetting
.
levels
[
:global
]
class
<<
self
def
search
(
query
)
joins
(
:user
).
merge
(
User
.
search
(
query
))
end
def
sort
(
method
)
case
method
.
to_s
when
'recent_sign_in'
then
order_recent_sign_in
when
'oldest_sign_in'
then
order_oldest_sign_in
when
'last_joined'
then
order_created_desc
when
'oldest_joined'
then
order_created_asc
else
order_by
(
method
)
end
end
def
access_for_user_ids
(
user_ids
)
where
(
user_id:
user_ids
).
has_access
.
pluck
(
:user_id
,
:access_level
).
to_h
end
...
...
app/models/user.rb
View file @
59d43bea
...
...
@@ -178,6 +178,8 @@ class User < ActiveRecord::Base
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 members WHERE user_id IS NOT NULL AND requested_at IS NULL)'
)
}
scope
:todo_authors
,
->
(
user_id
,
state
)
{
where
(
id:
Todo
.
where
(
user_id:
user_id
,
state:
state
).
select
(
:author_id
))
}
scope
:order_recent_sign_in
,
->
{
reorder
(
last_sign_in_at: :desc
)
}
scope
:order_oldest_sign_in
,
->
{
reorder
(
last_sign_in_at: :asc
)
}
def
self
.
with_two_factor
joins
(
"LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"
).
...
...
@@ -205,8 +207,8 @@ class User < ActiveRecord::Base
def
sort
(
method
)
case
method
.
to_s
when
'recent_sign_in'
then
reorder
(
last_sign_in_at: :desc
)
when
'oldest_sign_in'
then
reorder
(
last_sign_in_at: :asc
)
when
'recent_sign_in'
then
order_recent_sign_in
when
'oldest_sign_in'
then
order_oldest_sign_in
else
order_by
(
method
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment