summaryrefslogtreecommitdiff
path: root/app/controllers/hunt_groups_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:05:14 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:05:14 +0100
commiteaad37485fe59d0306c37cc038dda6d210052910 (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /app/controllers/hunt_groups_controller.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
parentb80bd744ad873f6fc43018bc4bfb90677de167bd (diff)
Merge branch 'develop'
Diffstat (limited to 'app/controllers/hunt_groups_controller.rb')
-rw-r--r--app/controllers/hunt_groups_controller.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/app/controllers/hunt_groups_controller.rb b/app/controllers/hunt_groups_controller.rb
new file mode 100644
index 0000000..13a556a
--- /dev/null
+++ b/app/controllers/hunt_groups_controller.rb
@@ -0,0 +1,55 @@
+class HuntGroupsController < ApplicationController
+ load_and_authorize_resource :tenant
+ load_and_authorize_resource :hunt_group, :through => [:tenant]
+
+ before_filter :spread_breadcrumbs
+
+ def index
+ end
+
+ def show
+ end
+
+ def new
+ i = @tenant.hunt_groups.count
+ loop do
+ i += 1
+ break unless @tenant.hunt_groups.where(:name => "#{t('hunt_groups.name')} #{i}").count > 0
+ end
+ @hunt_group = @tenant.hunt_groups.build(:name => "#{t('hunt_groups.name')} #{i}")
+ end
+
+ def create
+ @hunt_group = @tenant.hunt_groups.build(params[:hunt_group])
+ if @hunt_group.save
+ redirect_to tenant_hunt_group_path(@tenant, @hunt_group), :notice => t('hunt_groups.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ end
+
+ def update
+ @hunt_group = HuntGroup.find(params[:id])
+ if @hunt_group.update_attributes(params[:hunt_group])
+ redirect_to tenant_hunt_group_path(@tenant, @hunt_group), :notice => t('hunt_groups.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @hunt_group.destroy
+ redirect_to tenant_hunt_groups_path(@tenant), :notice => t('hunt_groups.controller.successfuly_destroyed')
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("hunt_groups.index.page_title"), tenant_hunt_groups_path(@tenant)
+ if @hunt_group && !@hunt_group.new_record?
+ add_breadcrumb @hunt_group, tenant_hunt_group_path(@tenant, @hunt_group)
+ end
+ end
+end