Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
RDMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
researchdata
RDMS
Commits
ad43d686
Commit
ad43d686
authored
1 year ago
by
Gyan Gupta
Browse files
Options
Downloads
Patches
Plain Diff
allow only crc works in CRC 1280 collection
parent
15c541d9
Branches
fix/restrict-dataset-to-add-in-crc-collection
No related tags found
1 merge request
!238
Allow only crc works in CRC 1280 collection
Pipeline
#11717
failed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hyrax/app/controllers/hyrax/dashboard/collection_members_controller.rb
+9
-0
9 additions, 0 deletions
...trollers/hyrax/dashboard/collection_members_controller.rb
hyrax/app/models/dataset.rb
+10
-0
10 additions, 0 deletions
hyrax/app/models/dataset.rb
with
19 additions
and
0 deletions
hyrax/app/controllers/hyrax/dashboard/collection_members_controller.rb
+
9
−
0
View file @
ad43d686
...
...
@@ -70,6 +70,15 @@ module Hyrax
current_ability
.
can?
(
:deposit
,
@collection
)
return
t
(
'hyrax.dashboard.my.action.add_to_collection_only'
)
unless
member_action
==
"add"
# should never happen
if
batch_ids
.
present?
batch_ids
.
each
do
|
batch_id
|
work
=
ActiveFedora
::
Base
.
find
(
batch_id
)
if
work
.
class
==
Dataset
&&
@collection
.
collection_type
.
title
==
'CRC 1280'
return
"Collecton
#{
@collection
.
title
.
first
}
, Only CRC 1280 works allowed"
end
end
end
end
def
success_return_path
...
...
This diff is collapsed.
Click to expand it.
hyrax/app/models/dataset.rb
+
10
−
0
View file @
ad43d686
...
...
@@ -13,6 +13,7 @@ class Dataset < ActiveFedora::Base
after_save
:save_work_meta_json_file_to_s3
after_create
:set_default_tombstone_status
after_create
:register_ark
validate
:validate_parent_collection
# ------ properties from core metadata ------
# property date_modified - not displayed (filled in by the system)
...
...
@@ -127,4 +128,13 @@ class Dataset < ActiveFedora::Base
self
.
save
end
def
validate_parent_collection
parent_collection
=
self
.
parent_collections
.
first
if
parent_collection
.
present?
&&
parent_collection
.
collection_type
.
title
==
'CRC 1280'
self
.
errors
.
add
(
"Collecton
#{
parent_collection
.
title
.
first
}
"
:
"Only CRC 1280 works allowed"
)
end
end
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