Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
48629b5c39ee
Commit
48629b5c
authored
Nov 29, 2012
by
Dmitriy Zaporozhets
Browse files
Fix group duplication on dashboard and project order in group
parent
5404f0de06fb
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/controllers/groups_controller.rb
View file @
48629b5c
...
...
@@ -54,10 +54,12 @@
end
def
projects
@projects
||=
if
can?
(
current_user
,
:manage_group
,
@group
)
@group
.
projects
.
all
else
current_user
.
projects_sorted_by_activity
.
where
(
namespace_id:
@group
.
id
)
@projects
||=
begin
if
can?
(
current_user
,
:manage_group
,
@group
)
@group
.
projects
else
current_user
.
projects
.
where
(
namespace_id:
@group
.
id
)
end
.
sorted_by_activity
.
all
end
end
...
...
app/models/project.rb
View file @
48629b5c
...
...
@@ -73,7 +73,7 @@
scope
:public_only
,
where
(
private_flag:
false
)
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
:
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
def
active
...
...
@@ -285,4 +285,9 @@
merge_requests
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
app/models/user.rb
View file @
48629b5c
...
...
@@ -127,7 +127,8 @@
def
accessed_groups
@accessed_groups
||=
begin
groups
=
Group
.
where
(
id:
self
.
projects
.
pluck
(
:namespace_id
)).
all
groups
+
self
.
groups
groups
=
groups
+
self
.
groups
groups
.
uniq
end
end
end
app/roles/account.rb
View file @
48629b5c
...
...
@@ -80,7 +80,7 @@
end
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
def
namespaces
...
...
Write
Preview
Supports
Markdown
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