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
a500d074
Commit
a500d074
authored
8 years ago
by
Israel Barreto Sant'Anna
Browse files
Options
Downloads
Patches
Plain Diff
Preventing user from duplicating learning object on collection (Fix
#37
)
Signed-off-by:
Israel Barreto Sant'Anna
<
ibsa14@inf.ufpr.br
>
parent
2846cc76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/collections_controller.rb
+11
-2
11 additions, 2 deletions
app/controllers/collections_controller.rb
with
11 additions
and
2 deletions
app/controllers/collections_controller.rb
+
11
−
2
View file @
a500d074
...
...
@@ -96,7 +96,9 @@ class CollectionsController < ApplicationController
@collection
=
nil
if
@collection
==
'all'
@collections
=
current_user
.
associated_collections
@collections
.
select!
{
|
c
|
c
.
id
!=
@collection
.
id
}
unless
@collection
.
blank?
@collections
.
select!
do
|
c
|
(
!
@collection
.
blank?
&&
c
.
id
!=
@collection
.
id
)
||
!
include_learning_objects?
(
c
)
end
@type
=
params
[
:type
]
unless
@type
.
blank?
...
...
@@ -138,7 +140,7 @@ class CollectionsController < ApplicationController
next
unless
collection
.
user_own?
(
current_user
)
@learning_objects
.
each
do
|
learning_object
|
collection
.
learning_objects
<<
learning_object
collection
.
learning_objects
<<
learning_object
unless
collection
.
learning_objects
.
include?
learning_object
end
collection
.
save
end
...
...
@@ -171,6 +173,13 @@ class CollectionsController < ApplicationController
private
def
include_learning_objects?
(
collection
)
@learning_objects
.
each
do
|
lo
|
return
true
if
collection
.
learning_objects
.
include?
lo
end
false
end
def
check_collection_privacy!
(
collection
)
if
collection
.
private?
&&
!
collection
.
user_own?
(
current_user
)
redirect_to
:root
,
notice:
'Está é uma coleção privada.'
...
...
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