2011-03-10 11:35:46 +00:00
|
|
|
class ProjectsController < ApplicationController
|
2011-03-10 13:38:50 +00:00
|
|
|
before_filter :authenticate_user!
|
|
|
|
before_filter :find_platform
|
2011-03-11 16:08:41 +00:00
|
|
|
before_filter :find_repository
|
2011-03-31 02:56:20 +01:00
|
|
|
before_filter :find_project, :only => [:show, :destroy]
|
2011-03-10 13:38:50 +00:00
|
|
|
|
|
|
|
def new
|
2011-03-11 16:30:02 +00:00
|
|
|
@project = @repository.projects.new
|
2011-03-10 13:38:50 +00:00
|
|
|
end
|
|
|
|
|
2011-03-10 14:20:09 +00:00
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2011-03-10 13:38:50 +00:00
|
|
|
def create
|
2011-03-11 16:30:02 +00:00
|
|
|
@project = @repository.projects.new params[:project]
|
2011-03-10 13:38:50 +00:00
|
|
|
if @project.save
|
|
|
|
flash[:notice] = t('flash.project.saved')
|
2011-03-11 16:30:02 +00:00
|
|
|
redirect_to [@platform, @repository]
|
2011-03-10 13:38:50 +00:00
|
|
|
else
|
|
|
|
flash[:error] = t('flash.project.save_error')
|
|
|
|
render :action => :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-31 02:56:20 +01:00
|
|
|
def destroy
|
|
|
|
@project.destroy
|
|
|
|
|
|
|
|
redirect_to platform_repository_path(@platform, @repository)
|
|
|
|
end
|
|
|
|
|
2011-03-10 13:38:50 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def find_platform
|
|
|
|
@platform = Platform.find params[:platform_id]
|
|
|
|
end
|
2011-03-10 14:20:09 +00:00
|
|
|
|
2011-03-11 16:08:41 +00:00
|
|
|
def find_repository
|
2011-03-11 16:30:02 +00:00
|
|
|
@repository = @platform.repositories.find(params[:repository_id])
|
2011-03-11 16:08:41 +00:00
|
|
|
end
|
|
|
|
|
2011-03-10 14:20:09 +00:00
|
|
|
def find_project
|
2011-03-11 16:08:41 +00:00
|
|
|
@project = @repository.projects.find params[:id]
|
2011-03-10 14:20:09 +00:00
|
|
|
end
|
2011-03-10 11:35:46 +00:00
|
|
|
end
|