summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/group_memberships_controller.rb51
-rw-r--r--app/controllers/group_permissions_controller.rb48
-rw-r--r--app/controllers/groups_controller.rb49
3 files changed, 148 insertions, 0 deletions
diff --git a/app/controllers/group_memberships_controller.rb b/app/controllers/group_memberships_controller.rb
new file mode 100644
index 0000000..df9f6b3
--- /dev/null
+++ b/app/controllers/group_memberships_controller.rb
@@ -0,0 +1,51 @@
+class GroupMembershipsController < ApplicationController
+ load_and_authorize_resource :group
+ load_and_authorize_resource :group_membership, :through => [:group]
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ end
+
+ def create
+ if params[:group_membership][:item_type].blank?
+ params[:group_membership][:item_type] = @group.group_memberships.first.item_type
+ end
+ @group_membership = @group.group_memberships.new(params[:group_membership])
+ if @group_membership.save
+ redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @group_membership.update_attributes(params[:group_membership])
+ redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group_membership.destroy
+ redirect_to action: "index", :notice => t('group_memberships.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("groups.index.page_title"), groups_path
+ add_breadcrumb @group, group_path(@group)
+ add_breadcrumb t("group_memberships.index.page_title"), group_group_memberships_path(@group)
+ if @group_membership && !@group_membership.new_record?
+ add_breadcrumb @group_membership, group_group_membership_path(@group, @group_membership)
+ end
+ end
+end
diff --git a/app/controllers/group_permissions_controller.rb b/app/controllers/group_permissions_controller.rb
new file mode 100644
index 0000000..3abdc51
--- /dev/null
+++ b/app/controllers/group_permissions_controller.rb
@@ -0,0 +1,48 @@
+class GroupPermissionsController < ApplicationController
+ load_and_authorize_resource :group
+ load_and_authorize_resource :group_permission, :through => [:group]
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ end
+
+ def create
+ @group_permission = @group.group_permissions.new(params[:group_permission])
+ if @group_permission.save
+ redirect_to action: "index", :notice => t('group_permissions.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ if @group_permission.update_attributes(params[:group_permission])
+ redirect_to action: "index", :notice => t('group_permissions.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group_permission.destroy
+ redirect_to action: "index", :notice => t('group_permissions.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("groups.index.page_title"), groups_path
+ add_breadcrumb @group, group_path(@group)
+ add_breadcrumb t("group_permissions.index.page_title"), group_group_permissions_path(@group)
+ if @group_permission && !@group_permission.new_record?
+ add_breadcrumb @group_permission, group_group_permission_path(@group, @group_permission)
+ end
+ end
+end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
new file mode 100644
index 0000000..1ab7a4f
--- /dev/null
+++ b/app/controllers/groups_controller.rb
@@ -0,0 +1,49 @@
+class GroupsController < ApplicationController
+ def index
+ @groups = Group.all
+ end
+
+ def show
+ @group = Group.find(params[:id])
+ end
+
+ def new
+ @group = Group.new
+ end
+
+ def create
+ @group = Group.new(params[:group])
+ if @group.save
+ redirect_to @group, :notice => t('groups.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @group = Group.find(params[:id])
+ end
+
+ def update
+ @group = Group.find(params[:id])
+ if @group.update_attributes(params[:group])
+ redirect_to @group, :notice => t('groups.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @group = Group.find(params[:id])
+ @group.destroy
+ redirect_to groups_url, :notice => t('groups.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("groups.index.page_title"), groups_path
+ if @group && !@group.new_record?
+ add_breadcrumb @group, @group
+ end
+ end
+end