Paul Klumpp 12 rokov pred
rodič
commit
4dba095c07

+ 22 - 3
app/admin/bots.rb

@@ -28,10 +28,29 @@ ActiveAdmin.register Bot do
     end
 
     panel "This Bot's Channels" do
-      table_for(bot.channels)  do
-        column :name
-        column :activate
+
+      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', :confirm => "You sure?")
+            end
+          end
+        end
       end
+
     end
 
     active_admin_comments

+ 4 - 1
app/admin/channels.rb

@@ -18,7 +18,10 @@ ActiveAdmin.register Channel do
       row :id
       row :name
       row :bot do |c|
-        link_to "ID:" +  c.bot_id.to_s + " N:" + Bot.find(c.bot_id).botnick, "../bots/" + c.bot_id.to_s
+        Bot.find(c.bot_id) do |bot|
+          span(link_to("ID:" +  c.bot_id.to_s + " N:" + bot.botnick, "../bots/" + c.bot_id.to_s).to_s + " | " +
+                   link_to("add a channel to this bot", "/admin/channels/new?bot_id=" + bot.id.to_s + "&botnick=" + bot.botnick.to_s))
+        end
       end
       row :activate
       row :created_at

+ 6 - 6
app/admin/dashboards.rb

@@ -14,11 +14,11 @@ ActiveAdmin::Dashboards.build do
 
       panel "Botnick: " + bot.botnick do
 
-        span link_to("view this bot", "admin/bots/" + bot.id.to_s)
+        span link_to("view this bot", "/admin/bots/" + bot.id.to_s)
         span "|"
-        span link_to("edit this bot", "admin/bots/" + bot.id.to_s + "/edit")
+        span link_to("edit this bot", "/admin/bots/" + bot.id.to_s + "/edit")
         span "|"
-        span link_to("add a channel to this bot", "admin/channels/new?bot_id=" + bot.id.to_s + "&botnick=" + bot.botnick.to_s)
+        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)
@@ -31,9 +31,9 @@ ActiveAdmin::Dashboards.build 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', :confirm => "You sure?")
+                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', :confirm => "You sure?")
               end
             end
           end

+ 1 - 1
app/models/channel.rb

@@ -8,7 +8,7 @@ class Channel < ActiveRecord::Base
   validates :name,
             :uniqueness => true,
             :presence => true,
-            :format => { :with => /\A#.+\z/, :message => "Channel name must begin with #" }
+            :format => { :with => /\A#\S+\z/, :message => "Channel name must begin with # and no whitespace in name allowed" }
 
   validates_presence_of :bot_id
   validates_presence_of :bot_id, :on => :update