Skip to content

Commit 58da6ca

Browse files
committed
Add support for updating experience-cs projects
1 parent 1feb1c6 commit 58da6ca

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/tasks/projects.rake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,19 @@ namespace :projects do
5454
]
5555
projects.each do |attributes|
5656
identifier = attributes[:identifier]
57-
if Project.only_scratch(true).exists?(attributes.slice(:identifier, :locale))
57+
project = Project.only_scratch(true).find_by(attributes.slice(:identifier, :locale))
58+
if project.present?
5859
puts "Scratch project with identifier '#{identifier}' already exists"
60+
project.assign_attributes(attributes.except(:identifier, :locale))
61+
if project.changed?
62+
if project.save
63+
puts "Scratch project with identifier '#{identifier}' updated successfully"
64+
else
65+
puts "Scratch project with identifier '#{identifier}' update failed"
66+
end
67+
else
68+
puts "Scratch project with identifier '#{identifier}' has not changed"
69+
end
5970
elsif Project.create(attributes)
6071
puts "Scratch project with identifier '#{identifier}' created successfully"
6172
else

0 commit comments

Comments
 (0)