Some changes in representation

This commit is contained in:
George Vinogradov 2011-10-17 00:50:56 +04:00
parent e672c20d3f
commit fa3359b025
6 changed files with 63 additions and 58 deletions

View File

@ -6,7 +6,7 @@ class PlatformsController < ApplicationController
before_filter :find_platform, :only => [:freeze, :unfreeze, :clone] before_filter :find_platform, :only => [:freeze, :unfreeze, :clone]
def index def index
@platforms = Platform.all @platforms = Platform.paginate(:page => params[:platform_page])
end end
def show def show
@ -20,15 +20,16 @@ class PlatformsController < ApplicationController
end end
def create def create
@platform = Platform.new params[:platform] pp params
if @platform.save # @platform = Platform.new params[:platform]
flash[:notice] = I18n.t("flash.platform.saved") # if @platform.save
redirect_to @platform # flash[:notice] = I18n.t("flash.platform.saved")
else # redirect_to @platform
flash[:error] = I18n.t("flash.platform.saved_error") # else
@platforms = Platform.all # flash[:error] = I18n.t("flash.platform.saved_error")
render :action => :new # @platforms = Platform.all
end # render :action => :new
# end
end end
def freeze def freeze

View File

@ -1,7 +1,7 @@
class ProjectsController < ApplicationController class ProjectsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_platform # before_filter :find_platform
before_filter :find_repository # before_filter :find_repository
before_filter :find_project, :only => [:show, :destroy, :build, :process_build] before_filter :find_project, :only => [:show, :destroy, :build, :process_build]
def new def new
@ -72,7 +72,7 @@ class ProjectsController < ApplicationController
end end
def find_project def find_project
@project = @repository.projects.find params[:id] @project = Project.find params[:id]
end end
def check_arches def check_arches

View File

@ -11,9 +11,9 @@ class Platform < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true validates :name, :presence => true, :uniqueness => true
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
before_create :xml_rpc_create # before_create :xml_rpc_create
before_destroy :xml_rpc_destroy # before_destroy :xml_rpc_destroy
before_update :check_freezing # before_update :check_freezing
def path def path
@ -55,30 +55,33 @@ class Platform < ActiveRecord::Base
end end
def xml_rpc_create def xml_rpc_create
result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] return true
if result == BuildServer::SUCCESS # result = BuildServer.add_platform unixname, APP_CONFIG['root_path']
return true # if result == BuildServer::SUCCESS
else # return true
raise "Failed to create platform #{name}. Path: #{build_path(unixname)}" # else
end # raise "Failed to create platform #{name}. Path: #{build_path(unixname)}"
# end
end end
def xml_rpc_destroy def xml_rpc_destroy
result = BuildServer.delete_platform unixname return true
if result == BuildServer::SUCCESS # result = BuildServer.delete_platform unixname
return true # if result == BuildServer::SUCCESS
else # return true
raise "Failed to delete platform #{unixname}." # else
end # raise "Failed to delete platform #{unixname}."
# end
end end
def xml_rpc_clone(new_unixname) def xml_rpc_clone(new_unixname)
result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] return true
if result == BuildServer::SUCCESS # result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path']
return true # if result == BuildServer::SUCCESS
else # return true
raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}" # else
end # raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}"
# end
end end
def check_freezing def check_freezing

View File

@ -17,8 +17,8 @@ class Project < ActiveRecord::Base
scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} } scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} }
#before_create :create_directory, :create_git_repo #before_create :create_directory, :create_git_repo
before_create :xml_rpc_create # before_create :xml_rpc_create
before_destroy :xml_rpc_destroy # before_destroy :xml_rpc_destroy
# Redefining a method from Project::HasRepository module to reflect current situation # Redefining a method from Project::HasRepository module to reflect current situation
def git_repo_path def git_repo_path

View File

@ -1,5 +1,5 @@
class Relation < ActiveRecord::Base class Relation < ActiveRecord::Base
belongs_to :target, :polymorphic => true belongs_to :target, :polymorphic => true
belongs_to :object, :polymorphic => true belongs_to :object, :polymorphic => true
belongs_to :role belongs_to :role, :autosave => true
end end

View File

@ -1,21 +1,22 @@
.block =render :partial => 'list', :object => @platforms
.secondary-navigation /.block
%ul.wat-cf / .secondary-navigation
%li.first.active= link_to t("layout.platforms.list"), platforms_path / %ul.wat-cf
%li= link_to t("layout.platforms.new"), new_platform_path / %li.first.active= link_to t("layout.platforms.list"), platforms_path
.content / %li= link_to t("layout.platforms.new"), new_platform_path
%h2.title / .content
= t("layout.platforms.list_header") / %h2.title
.inner / = t("layout.platforms.list_header")
%table.table / .inner
%tr / %table.table
%th.first= t("activerecord.attributes.platform.name") / %tr
%th.last &nbsp; / %th.first= t("activerecord.attributes.platform.name")
- @platforms.each do |platform| / %th.last &nbsp;
%tr{:class => cycle("odd", "even")} / - @platforms.each do |platform|
%td / %tr{:class => cycle("odd", "even")}
= link_to platform.name, platform_path(platform) / %td
%td.last / = link_to platform.name, platform_path(platform)
#{link_to t("layout.show"), platform_path(platform)} | #{link_to t("layout.delete"), platform_path(platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete")} / %td.last
.actions-bar.wat-cf / #{link_to t("layout.show"), platform_path(platform)} | #{link_to t("layout.delete"), platform_path(platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete")}
.actions / .actions-bar.wat-cf
/ .actions