summaryrefslogtreecommitdiff
path: root/app/controllers/switchboards_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-10 08:45:30 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-10 08:45:30 +0100
commite2a03b5d20253d7a1eb10b8c110d9feec79e995f (patch)
treecc36cbb2572e549ce59388654d358cb1e2771ecd /app/controllers/switchboards_controller.rb
parent595a48a91f8549b20109942e0b80df4f891d5999 (diff)
parent21d0843117c0962bd962fc50fccaf276a5b3067f (diff)
Fixed a merging conflict.
Merge branch 'switchboard' into develop Conflicts: app/models/sip_account.rb
Diffstat (limited to 'app/controllers/switchboards_controller.rb')
-rw-r--r--app/controllers/switchboards_controller.rb65
1 files changed, 65 insertions, 0 deletions
diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb
new file mode 100644
index 0000000..8f21d5e
--- /dev/null
+++ b/app/controllers/switchboards_controller.rb
@@ -0,0 +1,65 @@
+class SwitchboardsController < ApplicationController
+ load_and_authorize_resource :user
+ authorize_resource :switchboard, :through => :user
+
+ def index
+ @switchboards = @user.switchboards
+ spread_breadcrumbs
+ end
+
+ def show
+ @switchboard = @user.switchboards.find(params[:id])
+ spread_breadcrumbs
+ end
+
+ def new
+ @switchboard = @user.switchboards.build
+ spread_breadcrumbs
+ end
+
+ def create
+ @switchboard = @user.switchboards.build(switchboard_params)
+ spread_breadcrumbs
+ if @switchboard.save
+ redirect_to user_switchboards_path(@user), :notice => t('switchboards.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @switchboard = @user.switchboards.find(params[:id])
+ spread_breadcrumbs
+ end
+
+ def update
+ @switchboard = @user.switchboards.find(params[:id])
+ spread_breadcrumbs
+ if @switchboard.update_attributes(switchboard_params)
+ redirect_to [@user, @switchboard], :notice => t('switchboards.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @switchboard = @user.switchboards.find(params[:id])
+ @switchboard.destroy
+ spread_breadcrumbs
+ redirect_to user_switchboards_path(@user), :notice => t('switchboards.controller.successfuly_destroyed')
+ end
+
+ private
+ def switchboard_params
+ params.require(:switchboard).permit(:name)
+ end
+
+ def spread_breadcrumbs
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant)
+ add_breadcrumb @user, tenant_user_path(@user.current_tenant, @user)
+ add_breadcrumb t("switchboards.index.page_title"), user_switchboards_path(@user)
+ if @switchboard && !@switchboard.new_record?
+ add_breadcrumb @switchboard, user_switchboard_path(@user, @switchboard)
+ end
+ end
+end