2010-03-22 01:58:37 +01:00
|
|
|
class Admin::WorkgroupsController < Admin::BaseController
|
2011-06-10 12:18:55 +02:00
|
|
|
inherit_resources
|
2009-01-13 19:01:56 +01:00
|
|
|
|
2011-06-10 12:18:55 +02:00
|
|
|
def index
|
2012-09-30 21:15:55 +02:00
|
|
|
@workgroups = Workgroup.order('name ASC')
|
2011-06-10 12:18:55 +02:00
|
|
|
# if somebody uses the search field:
|
2012-09-30 21:15:55 +02:00
|
|
|
@workgroups = @workgroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].blank?
|
2009-01-13 19:01:56 +01:00
|
|
|
|
2012-10-15 21:19:17 +02:00
|
|
|
@workgroups = @workgroups.page(params[:page]).per(@per_page)
|
2009-01-13 19:01:56 +01:00
|
|
|
end
|
|
|
|
|
2011-06-10 13:22:15 +02:00
|
|
|
def destroy
|
|
|
|
@workgroup = Workgroup.find(params[:id])
|
|
|
|
@workgroup.destroy
|
2013-06-06 02:13:40 +02:00
|
|
|
redirect_to admin_workgroups_url, notice: t('admin.workgroups.destroy.notice')
|
2011-06-10 13:22:15 +02:00
|
|
|
rescue => error
|
2014-02-20 15:04:53 +01:00
|
|
|
redirect_to admin_workgroups_url, alert: t('admin.workgroups.destroy.error', error: error.message)
|
2009-01-13 19:01:56 +01:00
|
|
|
end
|
|
|
|
end
|