Finishing migration to new hierarchy

This commit is contained in:
Alexey Nayden 2011-03-11 19:30:02 +03:00
parent 716cc97330
commit 9609a682a6
6 changed files with 35 additions and 9 deletions

View File

@ -5,17 +5,17 @@ class ProjectsController < ApplicationController
before_filter :find_project, :only => [:show]
def new
@project = @platform.projects.new
@project = @repository.projects.new
end
def show
end
def create
@project = @platform.projects.new params[:project]
@project = @repository.projects.new params[:project]
if @project.save
flash[:notice] = t('flash.project.saved')
redirect_to @platform
redirect_to [@platform, @repository]
else
flash[:error] = t('flash.project.save_error')
render :action => :new
@ -29,7 +29,7 @@ class ProjectsController < ApplicationController
end
def find_repository
@repository = @platform.find parmas[:repository_id]
@repository = @platform.repositories.find(params[:repository_id])
end
def find_project

View File

@ -35,10 +35,10 @@ class RepositoriesController < ApplicationController
end
def create
@repository = @platform.repositories.new params[:id]
@repository = @platform.repositories.new(params[:repository])
if @repository.save
flash[:notice] = ''
redirect_to @repository
redirect_to @platform, @repository
else
flash[:error] = ''
render :action => :new

View File

@ -3,7 +3,7 @@ class Repository < ActiveRecord::Base
has_many :projects, :dependent => :destroy
validate :name, :presence => true, :uniqueness => true
validate :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
validate :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }
before_create :create_directory

View File

@ -1,5 +1,5 @@
%h1= t('layout.projects.new')
= form_for [@platform, @project] do |f|
= form_for [@platform, @repository, @project] do |f|
%p
= f.label :name
= f.text_field :name
@ -8,4 +8,4 @@
= f.text_field :unixname
%p
= f.submit t('layout.create')
= link_to t('layout.cancel'), platform_path(@platform)
= link_to t('layout.cancel'), platform_repository_path(@platform, @repository)

View File

@ -0,0 +1,12 @@
%h1= t('layout.repositories.new_header')
= form_for [@platform, @repository] do |f|
%p
= f.label :name
= f.text_field :name
%p
= f.label :unixname
= f.text_field :unixname
%p
= f.submit t('layout.create')
= link_to t('layout.cancel'), platform_repositories_path(@platform)

View File

@ -0,0 +1,14 @@
%h1
= t('layout.repositories.show')
= @repository.name
= link_to t('layout.repositories.back_to_the_list'), platform_path(@platform)
.location
= t('layout.repositories.location')
= @repository.path
%h2= t('layout.repositories.projects')
- @projects.each do |project|
= div_for project do
= link_to project.name, [@platform, @repository, project]
= link_to t('layout.projects.new'), new_platform_repository_project_path(@platform, @repository)