Groups are now workgroups. First part of moving groups-logic into admin-namespace.
This commit is contained in:
parent
461dfa8531
commit
2d5dc03b90
31 changed files with 616 additions and 37 deletions
67
app/controllers/admin/workgroups_controller.rb
Normal file
67
app/controllers/admin/workgroups_controller.rb
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
class Admin::WorkgroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
||||
@per_page = params[:per_page].to_i
|
||||
else
|
||||
@per_page = 20
|
||||
end
|
||||
|
||||
# if the search field is used
|
||||
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
|
||||
|
||||
@workgroups = Workgroup.paginate(:conditions => conditions, :page => params[:page],
|
||||
:per_page => @per_page, :order => 'name')
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.js { render :partial => "workgroups" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@workgroup = Workgroup.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@workgroup = Workgroup.new(params[:workgroup])
|
||||
|
||||
if @workgroup.save
|
||||
flash[:notice] = 'Workgroup was successfully created.'
|
||||
redirect_to([:admin, @workgroup])
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
|
||||
if @workgroup.update_attributes(params[:workgroup])
|
||||
flash[:notice] = 'Workgroup was successfully updated.'
|
||||
redirect_to([:admin, @workgroup])
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
@workgroup.destroy
|
||||
|
||||
redirect_to(admin_workgroups_url)
|
||||
end
|
||||
|
||||
def memberships
|
||||
@group = Workgroup.find(params[:id])
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue