BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f96ce407
Commit
f96ce407
authored
Feb 26, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve implementation to check read access to forks and add pagination.
parent
baa5f7fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
forks_controller.rb
app/controllers/projects/forks_controller.rb
+16
-6
index.html.haml
app/views/projects/forks/index.html.haml
+6
-8
No files found.
app/controllers/projects/forks_controller.rb
View file @
f96ce407
...
...
@@ -4,12 +4,22 @@ class Projects::ForksController < Projects::ApplicationController
before_action
:authorize_download_code!
def
index
@sort
=
params
[
:sort
]
||
'id_desc'
@all_forks
=
project
.
forks
.
includes
(
:creator
).
order_by
(
@sort
)
@public_forks
,
@protected_forks
=
@all_forks
.
partition
do
|
project
|
can?
(
current_user
,
:read_project
,
project
)
end
base_query
=
project
.
forks
.
includes
(
:creator
)
@forks
=
if
current_user
base_query
.
where
(
'projects.visibility_level IN (?) OR projects.id IN (?)'
,
Project
::
PUBLIC
,
current_user
.
authorized_projects
.
pluck
(
:id
))
else
base_query
.
where
(
'projects.visibility_level = ?'
,
Project
::
PUBLIC
)
end
@total_forks_count
=
base_query
.
size
@private_forks_count
=
@total_forks_count
-
@forks
.
size
@public_forks_count
=
@total_forks_count
-
@private_forks_count
@sort
=
params
[
:sort
]
||
'id_desc'
@forks
=
@forks
.
order_by
(
@sort
).
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
def
new
...
...
app/views/projects/forks/index.html.haml
View file @
f96ce407
.top-area
.nav-text
-
public_count
=
@public_forks
.
size
-
protected_count
=
@protected_forks
.
size
-
full_count_title
=
"
#{
public_count
}
public and
#{
protected_count
}
private"
==
#{
pluralize
(
@all_forks
.
size
,
'fork'
)
}
:
#{
full_count_title
}
-
full_count_title
=
"
#{
@public_forks_count
}
public and
#{
@private_forks_count
}
private"
==
#{
pluralize
(
@total_forks_count
,
'fork'
)
}
:
#{
full_count_title
}
.nav-controls
=
search_field_tag
:filter_projects
,
nil
,
placeholder:
'Search forks'
,
class:
'projects-list-filter project-filter-form-field form-control input-short'
,
...
...
@@ -41,17 +39,17 @@
.projects-list-holder
-
if
@
public_
forks
.
blank?
-
if
@forks
.
blank?
%ul
.content-list
%li
.nothing-here-block
No forks to show
-
else
=
render
'shared/projects/list'
,
projects:
@
public_
forks
,
use_creator_avatar:
true
,
=
render
'shared/projects/list'
,
projects:
@forks
,
use_creator_avatar:
true
,
forks:
true
,
show_last_commit_as_description:
true
-
if
protected
_count
>
0
-
if
@private_forks
_count
>
0
%ul
.projects-list.private-forks-notice
%li
.project-row
=
icon
(
'lock fw'
,
base:
'circle'
,
class:
'fa-lg private-fork-icon'
)
%strong
=
pluralize
(
protected
_count
,
'private fork'
)
%strong
=
pluralize
(
@private_forks
_count
,
'private fork'
)
%span
you have no access to.
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