2014-03-23 00:22:25 +00:00
|
|
|
class GroupersController < ApplicationController
|
|
|
|
def create
|
2020-03-18 03:38:17 +00:00
|
|
|
@grouper = Grouper.new(Grouper.params(params, cuser))
|
2014-03-23 00:22:25 +00:00
|
|
|
raise AccessError unless @grouper.can_create? cuser
|
|
|
|
|
|
|
|
if @grouper.save
|
|
|
|
flash[:notice] = t(:groups_user_add)
|
|
|
|
else
|
|
|
|
flash[:error] = @grouper.errors.full_messages.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to_back
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@grouper = Grouper.find params[:id]
|
|
|
|
raise AccessError unless @grouper.can_update? cuser
|
|
|
|
|
2020-03-18 03:38:17 +00:00
|
|
|
if @grouper.update_attributes(Grouper.params(params, cuser))
|
2014-03-23 00:22:25 +00:00
|
|
|
flash[:notice] = t(:groups_user_update)
|
|
|
|
else
|
|
|
|
flash[:error] = @grouper.errors.full_messages.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to_back
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@grouper = Grouper.find params[:id]
|
|
|
|
raise AccessError unless @grouper.can_destroy? cuser
|
|
|
|
|
|
|
|
@grouper.destroy
|
|
|
|
redirect_to_back
|
|
|
|
end
|
|
|
|
end
|