Sha256: 7f7aba26de39292ebd63ad193ba62d9655026b270bdd0e902e07b618fece0134

Contents?: true

Size: 874 Bytes

Versions: 4

Compression:

Stored size: 874 Bytes

Contents

format :html do

  view :type do |args|
    args.merge!(:type_class=>'no-edit') if card.cards_of_type_exist?
    super args
  end

  view :type_formgroup do |args|
    if card.cards_of_type_exist?
      %{<div>Sorry, this card must remain a Cardtype so long as there are <strong>#{ card.name }</strong> cards.</div>}
    else
      super args
    end  
  end
end


include Basic


def follow_label
  default_follow_set_card.follow_label
end

def followed_by? user_id = nil
  default_follow_set_card.all_members_followed_by? user_id
end

def default_follow_set_card
  Card.fetch("#{name}+*type") 
end


def cards_of_type_exist?
  !new_card? and Auth.as_bot { Card.count_by_wql :type_id=>id } > 0
end

event :check_for_cards_of_type, :after=>:validate_delete do
  if cards_of_type_exist?
    errors.add :cardtype, "can't alter this type; #{name} cards still exist"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
card-1.15.2 mod/05_standard/set/type/cardtype.rb
card-1.15.1 mod/05_standard/set/type/cardtype.rb
card-1.15.0 mod/05_standard/set/type/cardtype.rb
card-1.15.pre2 mod/05_standard/set/type/cardtype.rb