ActiveAdmin.register Bot do
  menu :priority => 4



  index do
    column :id
    column :botnick do |b|
      link_to b.botnick, "bots/" + b.id.to_s
    end
    column :owner
    column :activate
    column :created_at
    column :updated_at
    default_actions
  end


  show :title => :botnick do

    attributes_table do
      row :id
      row :botnick
      row :owner
      row :activate
      row :created_at
      row :updated_at
    end

    panel "This Bot's Channels" do

      span link_to("add a channel to this bot", "/admin/channels/new?bot_id=" + bot.id.to_s + "&botnick=" + bot.botnick.to_s)

      table do

        @channels = Channel.find_all_by_bot_id(bot.id)
        th :Name
        th :Activate
        th :Actions
        @channels.each do |c|

          tr do
            td c.name
            td c.activate
            td do
              span link_to("view", "/admin/channels/" + c.id.to_s)
              span link_to("edit", "/admin/channels/" + c.id.to_s + "/edit")
              span link_to("delete", "/admin/channels/" + c.id.to_s, :method => 'delete', :data => { :confirm => 'You sure?' })
            end
          end
        end
      end

    end

    active_admin_comments

  end

  sidebar :help do
    ul do
      li "Owner: It is nice to read some contact infos like an email address in the owners field. To make life for spamcrawlers harder, use an obfuscation method for the address, like: foo {at] bar dot domain"
    end
  end


end
