2011-03-11 16:15:06 +00:00
|
|
|
class RepositoriesController < ApplicationController
|
2011-03-11 16:08:41 +00:00
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :find_platform
|
2011-03-31 01:58:27 +01:00
|
|
|
before_filter :find_repository, :only => [:show, :destroy]
|
2011-03-11 16:08:41 +00:00
|
|
|
|
|
|
|
def show
|
2011-03-31 02:15:17 +01:00
|
|
|
@projects = @repository.projects.recent
|
2011-03-11 16:08:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@repository = @platform.repositories.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2011-03-31 01:58:27 +01:00
|
|
|
@repository.destroy
|
|
|
|
|
2011-03-31 03:00:21 +01:00
|
|
|
flash[:notice] = t("flash.repository.destroyed")
|
2011-03-31 01:58:27 +01:00
|
|
|
redirect_to platform_path(@platform)
|
2011-03-11 16:08:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2011-03-11 16:30:02 +00:00
|
|
|
@repository = @platform.repositories.new(params[:repository])
|
2011-03-11 16:08:41 +00:00
|
|
|
if @repository.save
|
2011-03-31 01:59:12 +01:00
|
|
|
flash[:notice] = t('flash.repository.saved')
|
2011-03-11 17:19:47 +00:00
|
|
|
redirect_to [@platform, @repository]
|
2011-03-11 16:08:41 +00:00
|
|
|
else
|
2011-03-31 01:59:12 +01:00
|
|
|
flash[:error] = t('flash.repository.save_error')
|
2011-03-11 16:08:41 +00:00
|
|
|
render :action => :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def find_platform
|
|
|
|
@platform = Platform.find params[:platform_id]
|
|
|
|
end
|
2011-03-31 01:58:27 +01:00
|
|
|
|
|
|
|
def find_repository
|
|
|
|
@repository = @platform.repositories.find(params[:id])
|
|
|
|
end
|
2011-03-11 16:08:41 +00:00
|
|
|
end
|