From fa3359b025515afe8e627c7743b1940ee982a9e8 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Mon, 17 Oct 2011 00:50:56 +0400 Subject: [PATCH] Some changes in representation --- app/controllers/platforms_controller.rb | 21 ++++++------ app/controllers/projects_controller.rb | 6 ++-- app/models/platform.rb | 45 +++++++++++++------------ app/models/project.rb | 4 +-- app/models/relation.rb | 2 +- app/views/platforms/index.html.haml | 43 +++++++++++------------ 6 files changed, 63 insertions(+), 58 deletions(-) diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index fb508a727..a2a7e35cc 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -6,7 +6,7 @@ class PlatformsController < ApplicationController before_filter :find_platform, :only => [:freeze, :unfreeze, :clone] def index - @platforms = Platform.all + @platforms = Platform.paginate(:page => params[:platform_page]) end def show @@ -20,15 +20,16 @@ class PlatformsController < ApplicationController end def create - @platform = Platform.new params[:platform] - if @platform.save - flash[:notice] = I18n.t("flash.platform.saved") - redirect_to @platform - else - flash[:error] = I18n.t("flash.platform.saved_error") - @platforms = Platform.all - render :action => :new - end + pp params +# @platform = Platform.new params[:platform] +# if @platform.save +# flash[:notice] = I18n.t("flash.platform.saved") +# redirect_to @platform +# else +# flash[:error] = I18n.t("flash.platform.saved_error") +# @platforms = Platform.all +# render :action => :new +# end end def freeze diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 76f69c1f7..773d9b533 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,7 +1,7 @@ class ProjectsController < ApplicationController before_filter :authenticate_user! - before_filter :find_platform - before_filter :find_repository +# before_filter :find_platform +# before_filter :find_repository before_filter :find_project, :only => [:show, :destroy, :build, :process_build] def new @@ -72,7 +72,7 @@ class ProjectsController < ApplicationController end def find_project - @project = @repository.projects.find params[:id] + @project = Project.find params[:id] end def check_arches diff --git a/app/models/platform.rb b/app/models/platform.rb index 5921ddd55..6099d97ff 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -11,9 +11,9 @@ class Platform < ActiveRecord::Base validates :name, :presence => true, :uniqueness => true validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false - before_create :xml_rpc_create - before_destroy :xml_rpc_destroy - before_update :check_freezing +# before_create :xml_rpc_create +# before_destroy :xml_rpc_destroy +# before_update :check_freezing def path @@ -55,30 +55,33 @@ class Platform < ActiveRecord::Base end def xml_rpc_create - result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] - if result == BuildServer::SUCCESS - return true - else - raise "Failed to create platform #{name}. Path: #{build_path(unixname)}" - end + return true +# result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] +# if result == BuildServer::SUCCESS +# return true +# else +# raise "Failed to create platform #{name}. Path: #{build_path(unixname)}" +# end end def xml_rpc_destroy - result = BuildServer.delete_platform unixname - if result == BuildServer::SUCCESS - return true - else - raise "Failed to delete platform #{unixname}." - end + return true +# result = BuildServer.delete_platform unixname +# if result == BuildServer::SUCCESS +# return true +# else +# raise "Failed to delete platform #{unixname}." +# end end def xml_rpc_clone(new_unixname) - result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] - if result == BuildServer::SUCCESS - return true - else - raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}" - end + return true +# result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] +# if result == BuildServer::SUCCESS +# return true +# else +# raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}" +# end end def check_freezing diff --git a/app/models/project.rb b/app/models/project.rb index c1fcf68e5..aaaa0e2c1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -17,8 +17,8 @@ class Project < ActiveRecord::Base scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} } #before_create :create_directory, :create_git_repo - before_create :xml_rpc_create - before_destroy :xml_rpc_destroy +# before_create :xml_rpc_create +# before_destroy :xml_rpc_destroy # Redefining a method from Project::HasRepository module to reflect current situation def git_repo_path diff --git a/app/models/relation.rb b/app/models/relation.rb index c351cffcb..53cf77a69 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -1,5 +1,5 @@ class Relation < ActiveRecord::Base belongs_to :target, :polymorphic => true belongs_to :object, :polymorphic => true - belongs_to :role + belongs_to :role, :autosave => true end diff --git a/app/views/platforms/index.html.haml b/app/views/platforms/index.html.haml index 61bfbfdac..4af4c9181 100644 --- a/app/views/platforms/index.html.haml +++ b/app/views/platforms/index.html.haml @@ -1,21 +1,22 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.platforms.list"), platforms_path - %li= link_to t("layout.platforms.new"), new_platform_path - .content - %h2.title - = t("layout.platforms.list_header") - .inner - %table.table - %tr - %th.first= t("activerecord.attributes.platform.name") - %th.last   - - @platforms.each do |platform| - %tr{:class => cycle("odd", "even")} - %td - = link_to platform.name, platform_path(platform) - %td.last - #{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-bar.wat-cf - .actions +=render :partial => 'list', :object => @platforms +/.block +/ .secondary-navigation +/ %ul.wat-cf +/ %li.first.active= link_to t("layout.platforms.list"), platforms_path +/ %li= link_to t("layout.platforms.new"), new_platform_path +/ .content +/ %h2.title +/ = t("layout.platforms.list_header") +/ .inner +/ %table.table +/ %tr +/ %th.first= t("activerecord.attributes.platform.name") +/ %th.last   +/ - @platforms.each do |platform| +/ %tr{:class => cycle("odd", "even")} +/ %td +/ = link_to platform.name, platform_path(platform) +/ %td.last +/ #{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-bar.wat-cf +/ .actions