cirandas.net

ref: master

plugins/networks/controllers/networks_plugin_admin_controller.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class NetworksPluginAdminController < AdminController

  include NetworksPlugin::TranslationHelper

  helper NetworksPlugin::TranslationHelper

  before_filter :load_networks, :only => [:index, :create]

  def index
    @network = NetworksPlugin::Network.new
  end

  def admin
    redirect_to :action => :index
  end

  def create
    if request.post?
      @network = self.environment.networks.build params[:network]
      @network.identifier = @network.name.to_slug
      @network.enabled = true
      if @network.save
        @network.add_admin user
        redirect_to :action => :index
      else
        render :action => :index
      end
    end
  end

  protected

  def load_networks
    @networks = environment.networks.visible
  end

end