Sha256: 673524d0dcb67a11195418f30f80dcbeceddab0a176aa236a0f3a8f21b2254ea

Contents?: true

Size: 1.33 KB

Versions: 33

Compression:

Stored size: 1.33 KB

Contents

# -*- encoding : utf-8 -*-

class AccountRequestsToSignups < Card::Migration::Core
  def up
    newname = "Sign up"
    newname = "*signup" if Card.exists? newname

    # get old codename and name out of the way
    old_signup = Card[:signup]
    old_signup.name = "#{newname} - old"
    old_signup.codename = nil
    old_signup.save!

    Card::Codename.reset_cache

    # rename Account Request to "Sign up"
    new_signup = Card[:account_request]
    new_signup.name = newname
    new_signup.update_referers = true
    new_signup.codename = :signup
    new_signup.save!

    Card::Codename.reset_cache

    # move old "*signup+*thanks" to "Sign up+*type+*thanks"
    thanks = Card[:thanks]
    if (signup_thanks = Card["#{old_signup.name}+#{thanks.name}"])
      signup_thanks.name = "#{new_signup.name}+#{Card[:type].name}+#{thanks.name}"
      signup_thanks.update_referers = true
      signup_thanks.save!
    end

    # get rid of old signup card unless there is other data there (most likely +*subject and +*message)
    unless Card.search(return: :id, left_id: old_signup.id).first
      old_signup.delete!
    end

    # turn captcha off by default on signup
    rulename = [:signup, :type, :captcha].map { |code| Card[code].name } * "+"
    captcha_rule = Card.fetch rulename, new: {}
    captcha_rule.content = "0"
    captcha_rule.save!
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
card-1.94.1 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.94.0 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.13 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.12 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.11 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.10 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.9 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.8 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.7 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.6 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.5 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.4 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.3 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.2 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.1 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.93.0 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.92.2 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.92.1 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.92 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb
card-1.91 db/migrate_core_cards/20140317035504_account_requests_to_signups.rb