Last active
August 29, 2015 14:16
-
-
Save wethu/9f986d262c0a95473f3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =begin | |
| Use script/runner to execute this file, eg: | |
| ~/g2 > script/runner script/publish_update.rb | |
| =end | |
| ActiveRecord::Base.transaction do | |
| # Add codes for buy pages to enable here: | |
| # BuyPage.code_like('S09').collect(&:code) | |
| # buy_page_codes = ["612-L25", "CAL-2015", "801-S05"] #cheeky faith, 2015 calendar, 801 sheer vision | |
| # buy_page_codes = ["219-M43-317", "219-M43-332", "219-M43", "317-M43", "332-M43", "421-M43-317", "421-M43-332", "421-M43", "613-L35"] #megamesh #infinite | |
| buy_page_codes = ["219-S05-312"] | |
| buy_page_codes.each do |buy_page_code| | |
| buy_page = BuyPage.find_by_code!(buy_page_code) | |
| puts "Enabling buy page: #{buy_page_code} (#{buy_page})" | |
| case buy_page | |
| when BikiniBuyPage | |
| [] # items are enabled via separates | |
| when ClothingSetBuyPage | |
| [] # items are enabled via separates | |
| when ClothingBuyPage | |
| buy_page.items | |
| when PackBuyPage | |
| buy_page.pack.pack_items.collect(&:item) | |
| when ItemBuyPage | |
| [buy_page.item] | |
| else | |
| raise("Buy page type not handled: #{buy_page.inspect}") | |
| end.each do |item| | |
| # Intercept any item codes to skip here... | |
| # eg: next if item.code[/^612-L05-01/] # 612 white | |
| # next if item.code[/^801-S05-13/] # lilac | |
| # next if item.code[/^801-S05-35/] # sky | |
| skip_items = [ | |
| /^334-S05-46/, # lemon | |
| /^334-S05-21/, # orange | |
| /^334-S05-35/, # sky | |
| /^334-S05-38/, # neon pink | |
| /^334-S05-93/, # neon orange | |
| /^334-S05-60/ # this confuses me as its needed on a separate buy page.. | |
| ] | |
| # Skip if the above patterns match the item's code | |
| if skip_items | |
| regex = Regexp.union(skip_items) | |
| next if item.code(regex) | |
| end | |
| puts " Enabling item: #{item.code} (#{item})" | |
| item.remove_manually_disable! | |
| item.send(:update_enabled!) | |
| end | |
| buy_page.update_attribute(:enabled, true) | |
| end | |
| # Normally everything below can be left... | |
| #Resetting buy page items_json | |
| BuyPage.update_all({:items_json => nil}, :code => buy_page_codes) | |
| # Enabling model gallery | |
| WwModelGallery.find(:first, :order => "created_at desc").update_attribute(:enabled, true) | |
| # Enabling blog | |
| # Blog.last.update_attribute(:enabled, true) | |
| # Enabling wallpaper | |
| Wallpaper.last.update_attribute(:enabled, true) | |
| # Enabling the 2011 calendar | |
| # Item.find_by_code!('CAL-2011').update_attribute(:enabled, true) | |
| # BuyPage.find_by_code('CAL-2011').update_attribute(:enabled, true) | |
| # Disabling current update | |
| Update.update_all(:enabled => false) | |
| SplashPage.update_all(:enabled => false) | |
| HomePage.update_all(:enabled => false) | |
| # Enabling current update | |
| update = Update.last | |
| update.update_attribute(:enabled, true) | |
| update.splash_pages.update_all(:enabled => true) | |
| update.home_pages.update_all(:enabled => true) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment