rosa-build/app/controllers/groups_controller.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

2011-10-16 21:39:45 +01:00
# coding: UTF-8
class GroupsController < ApplicationController
before_filter :authenticate_user!
before_filter :find_group, :only => [:show, :edit, :update, :destroy]
2011-10-31 21:55:56 +00:00
before_filter :check_global_access, :only => [:index, :new, :create]
2011-10-16 21:39:45 +01:00
def index
@groups = Group.paginate(:page => params[:group_page])
2011-10-16 21:39:45 +01:00
end
def show
2011-10-31 18:14:25 +00:00
can_perform? @group if @group
2011-10-16 21:39:45 +01:00
@platforms = @group.platforms.paginate(:page => params[:platform_page], :per_page => 10)
@repositories = @group.repositories.paginate(:page => params[:repository_page], :per_page => 10)
@projects = @group.projects.paginate(:page => params[:project_page], :per_page => 10)
end
def new
@group = Group.new
end
def edit
2011-10-31 18:14:25 +00:00
can_perform? @group if @group
end
2011-10-16 21:39:45 +01:00
def create
@group = Group.new params[:group]
@group.owner = current_user
@group.members << current_user
if @group.save
flash[:notice] = t('flash.group.saved')
redirect_to edit_group_path(@group)
else
flash[:error] = t('flash.group.save_error')
render :action => :new
end
end
def update
2011-10-31 18:14:25 +00:00
can_perform? @group if @group
if @group.update_attributes(params[:group])
flash[:notice] = t('flash.group.saved')
redirect_to groups_path
else
flash[:error] = t('flash.group.save_error')
render :action => :edit
end
end
def destroy
2011-10-31 18:14:25 +00:00
can_perform? @group if @group
@group.destroy
flash[:notice] = t("flash.group.destroyed")
redirect_to groups_path
end
protected
2011-10-16 21:39:45 +01:00
def find_group
@group = Group.find(params[:id])
end
end