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
iv
gitlab-ce
Commits
1d889a79
Commit
1d889a79
authored
Nov 29, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix group duplication on dashboard and project order in group
parent
ff9a2e2a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
7 deletions
+15
-7
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+6
-4
app/models/project.rb
app/models/project.rb
+6
-1
app/models/user.rb
app/models/user.rb
+2
-1
app/roles/account.rb
app/roles/account.rb
+1
-1
No files found.
app/controllers/groups_controller.rb
View file @
1d889a79
...
@@ -54,10 +54,12 @@ class GroupsController < ApplicationController
...
@@ -54,10 +54,12 @@ class GroupsController < ApplicationController
end
end
def
projects
def
projects
@projects
||=
if
can?
(
current_user
,
:manage_group
,
@group
)
@projects
||=
begin
@group
.
projects
.
all
if
can?
(
current_user
,
:manage_group
,
@group
)
else
@group
.
projects
current_user
.
projects_sorted_by_activity
.
where
(
namespace_id:
@group
.
id
)
else
current_user
.
projects
.
where
(
namespace_id:
@group
.
id
)
end
.
sorted_by_activity
.
all
end
end
end
end
...
...
app/models/project.rb
View file @
1d889a79
...
@@ -73,7 +73,7 @@ class Project < ActiveRecord::Base
...
@@ -73,7 +73,7 @@ class Project < ActiveRecord::Base
scope
:public_only
,
where
(
private_flag:
false
)
scope
:public_only
,
where
(
private_flag:
false
)
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:
authorized_for
,
->
(
user
)
{
joins
(
:users_projects
)
{
where
(
user_id:
user
.
id
)
}
}
scope
:
sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
class
<<
self
class
<<
self
def
active
def
active
...
@@ -285,4 +285,9 @@ class Project < ActiveRecord::Base
...
@@ -285,4 +285,9 @@ class Project < ActiveRecord::Base
merge_requests
merge_requests
end
end
end
end
def
self
.
authorized_for
user
projects
=
includes
(
:users_projects
,
:namespace
)
projects
=
projects
.
where
(
"users_projects.user_id = :user_id or projects.owner_id = :user_id or namespaces.owner_id = :user_id"
,
user_id:
user
.
id
)
end
end
end
app/models/user.rb
View file @
1d889a79
...
@@ -127,7 +127,8 @@ class User < ActiveRecord::Base
...
@@ -127,7 +127,8 @@ class User < ActiveRecord::Base
def
accessed_groups
def
accessed_groups
@accessed_groups
||=
begin
@accessed_groups
||=
begin
groups
=
Group
.
where
(
id:
self
.
projects
.
pluck
(
:namespace_id
)).
all
groups
=
Group
.
where
(
id:
self
.
projects
.
pluck
(
:namespace_id
)).
all
groups
+
self
.
groups
groups
=
groups
+
self
.
groups
groups
.
uniq
end
end
end
end
end
end
app/roles/account.rb
View file @
1d889a79
...
@@ -80,7 +80,7 @@ module Account
...
@@ -80,7 +80,7 @@ module Account
end
end
def
projects_sorted_by_activity
def
projects_sorted_by_activity
projects
.
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
projects
.
sorted_by_activity
end
end
def
namespaces
def
namespaces
...
...
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