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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
50f5f2e8
Commit
50f5f2e8
authored
Feb 02, 2019
by
Camil Staps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove private profiles from starrers view of projects
parent
66032506
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
app/controllers/projects/starrers_controller.rb
app/controllers/projects/starrers_controller.rb
+5
-2
app/finders/users_star_projects_finder.rb
app/finders/users_star_projects_finder.rb
+13
-1
app/models/users_star_project.rb
app/models/users_star_project.rb
+1
-0
app/views/projects/starrers/index.html.haml
app/views/projects/starrers/index.html.haml
+2
-3
No files found.
app/controllers/projects/starrers_controller.rb
View file @
50f5f2e8
...
@@ -9,8 +9,11 @@ class Projects::StarrersController < Projects::ApplicationController
...
@@ -9,8 +9,11 @@ class Projects::StarrersController < Projects::ApplicationController
def
index
def
index
@sort
=
params
[
:sort
].
presence
||
sort_value_name
@sort
=
params
[
:sort
].
presence
||
sort_value_name
@starrers
=
UsersStarProjectsFinder
.
new
(
params
).
execute
@starrers
=
UsersStarProjectsFinder
.
new
(
params
,
@project
,
current_user:
@current_user
).
execute
@starrers
=
@starrers
.
by_project
(
@project
)
@total_count
=
@project
.
starrers
.
size
@public_count
=
@starrers
.
size
@private_count
=
@total_count
-
@public_count
@starrers
=
@starrers
.
sort_by_attribute
(
@sort
).
page
(
params
[
:page
])
@starrers
=
@starrers
.
sort_by_attribute
(
@sort
).
page
(
params
[
:page
])
end
end
...
...
app/finders/users_star_projects_finder.rb
View file @
50f5f2e8
...
@@ -5,13 +5,17 @@ class UsersStarProjectsFinder
...
@@ -5,13 +5,17 @@ class UsersStarProjectsFinder
attr_accessor
:params
attr_accessor
:params
def
initialize
(
params
=
{})
def
initialize
(
params
=
{}
,
project
,
current_user:
nil
)
@params
=
params
@params
=
params
@project
=
project
@current_user
=
current_user
end
end
def
execute
def
execute
stars
=
UsersStarProject
.
all
.
order_id_desc
stars
=
UsersStarProject
.
all
.
order_id_desc
stars
=
by_project
(
stars
)
stars
=
by_search
(
stars
)
stars
=
by_search
(
stars
)
stars
=
filter_visible_profiles
(
stars
)
stars
stars
end
end
...
@@ -21,4 +25,12 @@ class UsersStarProjectsFinder
...
@@ -21,4 +25,12 @@ class UsersStarProjectsFinder
def
by_search
(
items
)
def
by_search
(
items
)
params
[
:search
].
present?
?
items
.
search
(
params
[
:search
])
:
items
params
[
:search
].
present?
?
items
.
search
(
params
[
:search
])
:
items
end
end
def
by_project
(
items
)
items
.
by_project
(
@project
)
end
def
filter_visible_profiles
(
items
)
items
.
with_visible_profile
(
@current_user
)
end
end
end
app/models/users_star_project.rb
View file @
50f5f2e8
...
@@ -15,6 +15,7 @@ class UsersStarProject < ApplicationRecord
...
@@ -15,6 +15,7 @@ class UsersStarProject < ApplicationRecord
scope
:order_user_name_asc
,
->
{
joins
(
:user
).
reorder
(
'"users"."name" ASC'
)
}
scope
:order_user_name_asc
,
->
{
joins
(
:user
).
reorder
(
'"users"."name" ASC'
)
}
scope
:order_user_name_desc
,
->
{
joins
(
:user
).
reorder
(
'"users"."name" DESC'
)
}
scope
:order_user_name_desc
,
->
{
joins
(
:user
).
reorder
(
'"users"."name" DESC'
)
}
scope
:by_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:by_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:with_visible_profile
,
->
(
user
)
{
joins
(
:user
).
where
(
'"users"."private_profile" IS NULL OR "users"."private_profile" = ? OR "users"."id" = ?'
,
false
,
user
.
id
)
}
class
<<
self
class
<<
self
def
sort_by_attribute
(
method
)
def
sort_by_attribute
(
method
)
...
...
app/views/projects/starrers/index.html.haml
View file @
50f5f2e8
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
.top-area.adjust
.top-area.adjust
.nav-text
.nav-text
%span
.flex-project-title
-
full_count_title
=
"
#{
@public_count
}
public and
#{
@private_count
}
private"
=
_
(
"Starrers of <strong>%{project_name}</strong>"
).
html_safe
%
{
project_name:
sanitize_project_name
(
@project
.
name
)
}
#{
pluralize
(
@total_count
,
'starrer'
)
}
:
#{
full_count_title
}
%span
.badge.badge-pill
=
@starrers
.
total_count
-
if
@starrers
.
size
>
0
||
params
[
:search
].
present?
-
if
@starrers
.
size
>
0
||
params
[
:search
].
present?
.nav-controls
.nav-controls
=
form_tag
request
.
original_url
,
method: :get
,
class:
'form-inline user-search-form flex-users-form'
do
=
form_tag
request
.
original_url
,
method: :get
,
class:
'form-inline user-search-form flex-users-form'
do
...
...
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