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
49bc5227
Commit
49bc5227
authored
1 year ago
by
Gyan Gupta
Browse files
Options
Downloads
Patches
Plain Diff
Added validation for wrong parent collection
parent
6b525f28
Branches
bug_fix/added_validation_parent_collection
No related tags found
1 merge request
!242
Added validation parent collection
Pipeline
#11816
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/models/crc_dataset.rb
+9
-1
9 additions, 1 deletion
hyrax/app/models/crc_dataset.rb
hyrax/app/models/dataset.rb
+4
-5
4 additions, 5 deletions
hyrax/app/models/dataset.rb
with
13 additions
and
6 deletions
hyrax/app/models/crc_dataset.rb
+
9
−
1
View file @
49bc5227
...
...
@@ -10,7 +10,7 @@ class CrcDataset < ActiveFedora::Base
# Change this to restrict which works can be added as a child.
# self.valid_child_concerns = []
validates
:title
,
presence:
{
message:
'Your CRC dataset must have a title.'
}
validate
:validate_parent_collection
after_save
:save_work_meta_json_file_to_s3
after_create
:set_default_source_and_tombstone_status
after_create
:register_ark
...
...
@@ -160,4 +160,12 @@ class CrcDataset < ActiveFedora::Base
self
.
save
end
def
validate_parent_collection
self
.
parent_collections
.
each
do
|
parent_collection
|
if
parent_collection
.
present?
&&
parent_collection
.
collection_type
.
title
!=
'CRC 1280'
self
.
errors
.
add
(
:base
,
"The CRC 1280 works can only be added to CRC 1280 collection"
)
end
end
end
end
This diff is collapsed.
Click to expand it.
hyrax/app/models/dataset.rb
+
4
−
5
View file @
49bc5227
...
...
@@ -130,11 +130,10 @@ class Dataset < ActiveFedora::Base
def
validate_parent_collection
parent_collection
=
self
.
parent_collection
s
.
first
if
parent_c
ollect
i
on
.
present?
&&
parent_collection
.
collection_type
.
title
==
'CRC 1280'
self
.
errors
.
add
(
"Collecton
#{
parent_collection
.
title
.
first
}
"
:
"Only CRC 1280 works allowed"
)
self
.
parent_collection
s
.
each
do
|
parent_collection
|
if
parent_collection
.
present?
&&
parent_collection
.
collection_type
.
title
==
'CRC 1280'
self
.
errors
.
add
(
:base
,
"C
ollecton
#{
parent_collection
.
title
.
first
}
, Only CRC 1280 works allowed"
)
end
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