Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
b58deb9a
Commit
b58deb9a
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
fix institutional collections user validations
parent
8699fcd9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/collections_controller.rb
+7
-7
7 additions, 7 deletions
app/controllers/collections_controller.rb
app/models/collection.rb
+5
-0
5 additions, 0 deletions
app/models/collection.rb
with
12 additions
and
7 deletions
app/controllers/collections_controller.rb
+
7
−
7
View file @
b58deb9a
...
...
@@ -39,7 +39,7 @@ class CollectionsController < ApplicationController
check_collection_privacy!
@collection
@user
=
@collection
.
owner
@own
=
user_signed_in?
?
@collection
.
own
er
?
(
current_user
)
:
false
@own
=
user_signed_in?
?
@collection
.
user_
own?
(
current_user
)
:
false
end
@reviews
=
Review
.
includes
(
:user
).
where
(
reviewable:
@collection
)
...
...
@@ -95,7 +95,7 @@ class CollectionsController < ApplicationController
# list all
@collection
=
nil
if
@collection
==
'all'
@collections
=
Collection
.
from_user
(
current_user
)
@collections
=
current_user
.
associated_collections
@collections
.
select!
{
|
c
|
c
.
id
!=
@collection
.
id
}
unless
@collection
.
blank?
unless
params
[
:type
].
blank?
...
...
@@ -132,7 +132,7 @@ class CollectionsController < ApplicationController
# POST /collections/1/learning_object
def
add_learning_object
@collections
.
each
do
|
collection
|
next
unless
collection
.
own
er
?
(
current_user
)
next
unless
collection
.
user_
own?
(
current_user
)
@learning_objects
.
each
do
|
learning_object
|
collection
.
learning_objects
<<
learning_object
...
...
@@ -146,7 +146,7 @@ class CollectionsController < ApplicationController
# DELETE /collections/1/learning_object
def
remove_learning_object
@collections
.
each
do
|
collection
|
next
unless
collection
.
own
er
?
(
current_user
)
next
unless
collection
.
user_
own?
(
current_user
)
@learning_objects
.
each
do
|
learning_object
|
collection
.
learning_objects
.
destroy
(
learning_object
)
...
...
@@ -169,8 +169,8 @@ class CollectionsController < ApplicationController
private
def
check_collection_privacy!
(
collection
)
if
collection
.
private?
redirect_to
:root
,
notice:
'Está é uma coleção privada.'
unless
collection
.
owner?
(
current_user
)
if
collection
.
private?
&&
!
collection
.
user_own?
(
current_user
)
redirect_to
:root
,
notice:
'Está é uma coleção privada.'
end
end
...
...
@@ -179,7 +179,7 @@ class CollectionsController < ApplicationController
end
def
set_collections
if
params
[
:id
]
==
"
all
"
||
params
[
:id
].
blank?
if
params
[
:id
]
==
'
all
'
||
params
[
:id
].
blank?
@collections
=
[
'all'
]
else
@collections
=
(
params
[
:id
].
class
==
String
)
?
[
Collection
.
find
(
params
[
:id
])]
:
params
[
:id
].
map
{
|
id
|
Collection
.
find
id
}
...
...
This diff is collapsed.
Click to expand it.
app/models/collection.rb
+
5
−
0
View file @
b58deb9a
...
...
@@ -58,6 +58,11 @@ class Collection < ActiveRecord::Base
owner
==
candidate
end
def
user_own?
(
user
)
return
false
unless
user
.
is_a?
User
owner?
(
user
)
||
owner
.
users
.
include?
(
user
)
end
def
private?
privacy
==
'private'
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment