Skip to content
Browse files

Merge pull request #31 from alphagov/add_tag

Create sub_category for tag_id of disabilities
  • Loading branch information...
2 parents 525e98b + d1e0bb5 commit 34e99b2696e0d0a70c8a21b4fb3a135b2e2e2516 @alext alext committed Oct 15, 2012
Showing with 25 additions and 0 deletions.
  1. +25 −0 lib/tasks/add_disabled_sub_category.rake
View
25 lib/tasks/add_disabled_sub_category.rake
@@ -0,0 +1,25 @@
+# NOTE: This is to specifically create a disabilities sub category
+# then tag all content with disabilities with this new sub category
+
+namespace :migrate do
+ desc "Create sub category and tag all content with disabilities tag_id with new sub cat"
+ task :create_sub_category_and_tag => :environment do |t, args|
+ tag = Tag.where(tag_id: "disabilities").first
+ if tag.nil?
+ raise "Wa? No frakkin' tag with tag_id #{args[:tag_id]}"
+ end
+
+ sub_cat = Tag.new({tag_id: "disabilities/disabled-people",
+ parent_id: "disabilities", description: "Includes your rights, benefits and the Equality Act",
+ tag_type: "section", title: "Disabled people"})
+ sub_cat.save!
+ puts "Created: #{sub_cat.inspect}"
+
+ artefacts = Artefact.any_in(tag_ids: [tag.tag_id])
+ artefacts.each do |a|
+ a.tag_ids = a.tag_ids.append(sub_cat.tag_id)
+ puts "Updating #{a.slug} with #{a.tag_ids}"
+ a.save!
+ end
+ end
+end

0 comments on commit 34e99b2

Please sign in to comment.
Something went wrong with that request. Please try again.