mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
The default colors in event_types and difficulty levels are in capital letters and the ones that comes from the color picker were not. Now colors are capitalized before saving the track, level or type. A rake task has also been created to capitalize color from old tracks, levels or types.
21 lines
546 B
Ruby
21 lines
546 B
Ruby
namespace :data do
|
|
desc 'Catitalize tracks, event types and difficult levels colors'
|
|
|
|
task capitalize_colors: :environment do
|
|
capitalize_collection_colors(Track)
|
|
puts "Tracks' colors capitalized"
|
|
|
|
capitalize_collection_colors(DifficultyLevel)
|
|
puts "Difficulty levels' colors capitalized"
|
|
|
|
capitalize_collection_colors(EventType)
|
|
puts "Event types' colors capitalized"
|
|
end
|
|
|
|
def capitalize_collection_colors(model)
|
|
model.all.each do |item|
|
|
item.color = item.color.upcase
|
|
item.save!
|
|
end
|
|
end
|
|
end
|