summaryrefslogtreecommitdiff
path: root/app/controllers/user_groups_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /app/controllers/user_groups_controller.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'app/controllers/user_groups_controller.rb')
-rw-r--r--app/controllers/user_groups_controller.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/app/controllers/user_groups_controller.rb b/app/controllers/user_groups_controller.rb
new file mode 100644
index 0000000..158abaa
--- /dev/null
+++ b/app/controllers/user_groups_controller.rb
@@ -0,0 +1,69 @@
+class UserGroupsController < ApplicationController
+ load_resource :tenant
+ load_resource :user
+ load_and_authorize_resource :user_group, :through => [:tenant, :user]
+
+ before_filter :set_and_authorize_parent
+ before_filter :spread_breadcrumbs
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ @user_group = @parent.user_groups.build
+ end
+
+ def create
+ @user_group = @parent.user_groups.build(params[:user_group])
+ if @user_group.save
+ redirect_to @user_group, :notice => t('user_groups.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @user_group.update_attributes(params[:user_group])
+ redirect_to @user_group, :notice => t('user_groups.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @user_group.destroy
+ redirect_to user_groups_url, :notice => t('user_groups.controller.successfuly_destroyed')
+ end
+
+ private
+
+ def set_and_authorize_parent
+ @parent = @user || @tenant
+ authorize! :read, @parent
+ end
+
+ def spread_breadcrumbs
+ if @tenant
+ add_breadcrumb t("user_groups.index.page_title"), tenant_user_groups_path(@tenant)
+ if @user_group && !@user_group.new_record?
+ add_breadcrumb @user_group, tenant_user_group_path(@tenant, @user_group)
+ end
+ end
+
+ if @user
+ add_breadcrumb t("users.index.page_title"), tenant_users_path(@parent)
+ add_breadcrumb @user, tenant_user_path(@user.current_tenant, @user)
+ add_breadcrumb t("user_groups.index.page_title"), user_user_groups_path(@user)
+ if @user_group && !@user_group.new_record?
+ add_breadcrumb @user_group, user_user_group_path(@user, @user_group)
+ end
+ end
+ end
+
+end