From 148a0fec2830b97928474caf3cdee8ce111fe2c0 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 28 Nov 2011 19:41:42 +0400 Subject: [PATCH] [refs #2249] Global name to description and unixname to name renames --- .../auto_build_lists_controller.rb | 2 +- .../personal_repositories_controller.rb | 2 +- app/controllers/platforms_controller.rb | 10 ++--- app/controllers/projects_controller.rb | 8 ++-- app/controllers/repositories_controller.rb | 2 +- app/controllers/rpc_controller.rb | 4 +- app/models/auto_build_list.rb | 2 +- app/models/build_list.rb | 6 +-- app/models/platform.rb | 44 +++++++++---------- app/models/private_user.rb | 4 +- app/models/product_build_list.rb | 2 +- app/models/project.rb | 16 +++---- app/models/repository.rb | 10 ++--- .../projects_list.html.haml | 4 +- app/views/platforms/_form.html.haml | 6 +-- app/views/platforms/clone.html.haml | 4 +- app/views/platforms/show.html.haml | 10 ++--- app/views/projects/_form.html.haml | 5 +-- app/views/projects/_list.html.haml | 2 +- .../projects/_own_projects_sidebar.html.haml | 4 +- app/views/projects/_project.html.haml | 4 +- app/views/projects/show.html.haml | 5 --- app/views/repositories/_form.html.haml | 4 +- .../repositories/projects_list.html.haml | 8 ++-- app/views/repositories/show.html.haml | 8 ++-- ...20111128140341_rename_name_and_unixname.rb | 19 ++++++++ lib/grack/base.rb | 6 +-- lib/modules/models/personal_repository.rb | 4 +- lib/tasks/import.rake | 2 +- lib/tasks/migrate_repos_task.rake | 2 +- 30 files changed, 109 insertions(+), 100 deletions(-) create mode 100644 db/migrate/20111128140341_rename_name_and_unixname.rb diff --git a/app/controllers/auto_build_lists_controller.rb b/app/controllers/auto_build_lists_controller.rb index 42724cfe5..4354b91d8 100644 --- a/app/controllers/auto_build_lists_controller.rb +++ b/app/controllers/auto_build_lists_controller.rb @@ -15,7 +15,7 @@ class AutoBuildListsController < ApplicationController def create @auto_build_list = AutoBuildList.new( - :bpl_id => Platform.find_by_unixname('mandriva2011').try(:id), + :bpl_id => Platform.find_by_name('mandriva2011').try(:id), :pl_id => current_user.personal_platform.id, :arch_id => Arch.find_by_name('i586').id, :project_id => params[:project_id]) diff --git a/app/controllers/personal_repositories_controller.rb b/app/controllers/personal_repositories_controller.rb index fb078858b..16490ed77 100644 --- a/app/controllers/personal_repositories_controller.rb +++ b/app/controllers/personal_repositories_controller.rb @@ -28,7 +28,7 @@ class PersonalRepositoriesController < ApplicationController if params[:project_id] @project = Project.find(params[:project_id]) # params[:project_id] = nil - unless @repository.projects.find_by_unixname(@project.unixname) + unless @repository.projects.find_by_name(@project.name) @repository.projects << @project flash[:notice] = t('flash.repository.project_added') else diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index b4f5c1291..618c24c20 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -16,10 +16,10 @@ class PlatformsController < ApplicationController format.json do render :json => { :platforms => @platforms.map do |p| - {:name => p.unixname, + {:name => p.name, :architectures => ['i586', 'x86_64'], - :repositories => p.repositories.map(&:unixname), - :url => "http://#{request.host_with_port}/downloads/#{p.unixname}/repository/"} + :repositories => p.repositories.map(&:name), + :url => "http://#{request.host_with_port}/downloads/#{p.name}/repository/"} end } end @@ -77,7 +77,7 @@ class PlatformsController < ApplicationController def clone if request.post? - @cloned = @platform.make_clone(:name => params[:platform]['name'], :unixname => params[:platform]['unixname'], + @cloned = @platform.make_clone(:name => params[:platform]['name'], :description => params[:platform]['description'], :owner_id => current_user.id, :owner_type => current_user.class.to_s) if @cloned.persisted? flash[:notice] = 'Клонирование успешно' @@ -88,7 +88,7 @@ class PlatformsController < ApplicationController else @cloned = Platform.new @cloned.name = @platform.name + "_clone" - @cloned.unixname = @platform.unixname + "_clone" + @cloned.description = @platform.description + "_clone" end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 27c264f37..95495c37e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -64,9 +64,9 @@ class ProjectsController < ApplicationController # TODO remove this? def auto_build - uname, unixname = params[:git_repo].split('/') + uname, name = params[:git_repo].split('/') owner = User.find_by_uname(uname) || Group.find_by_uname(uname) - project = Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_unixname!(unixname) + project = Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_name!(name) project.delay.auto_build # TODO don't queue duplicates # p = params.delete_if{|k,v| k == 'controller' or k == 'action'} @@ -79,7 +79,7 @@ class ProjectsController < ApplicationController def build @arches = Arch.recent @bpls = Platform.main - @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] } + @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.name}", rep.platform.id] } @project_versions = @project.collected_project_versions end @@ -101,7 +101,7 @@ class ProjectsController < ApplicationController if !check_arches || !check_project_versions @arches = Arch.recent @bpls = Platform.main - @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] } + @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.name}", rep.platform.id] } render :action => "build" else diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0d457cb91..f3dafb8f0 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -54,7 +54,7 @@ class RepositoriesController < ApplicationController if params[:project_id] @project = Project.find(params[:project_id]) # params[:project_id] = nil - unless @repository.projects.find_by_unixname(@project.unixname) + unless @repository.projects.find_by_name(@project.name) @repository.projects << @project flash[:notice] = t('flash.repository.project_added') else diff --git a/app/controllers/rpc_controller.rb b/app/controllers/rpc_controller.rb index 71d5023cf..9ce8e9d38 100644 --- a/app/controllers/rpc_controller.rb +++ b/app/controllers/rpc_controller.rb @@ -12,12 +12,12 @@ class RpcController < ApplicationController def platforms ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список платформ') - Platform.select('unixname').where("platform_type = ?", 'main').map(&:unixname) + Platform.select('name').where("platform_type = ?", 'main').map(&:name) end def user_projects ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список пользовательских проектов') - current_user.projects.map{|p| { :id => p.id, :unixname => p.unixname } } + current_user.projects.map{|p| { :id => p.id, :name => p.name } } end def project_versions id diff --git a/app/models/auto_build_list.rb b/app/models/auto_build_list.rb index f1b0224e4..9f607121d 100644 --- a/app/models/auto_build_list.rb +++ b/app/models/auto_build_list.rb @@ -5,6 +5,6 @@ class AutoBuildList < ActiveRecord::Base belongs_to :bpl, :class_name => 'Platform' def event_log_message - {:project => project.unixname}.inspect + {:project => project.name}.inspect end end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index a637f4b9a..e26efa029 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -125,7 +125,7 @@ class BuildList < ActiveRecord::Base end def event_log_message - {:project => project.unixname, :version => project_version, :arch => arch.name}.inspect + {:project => project.name, :version => project_version, :arch => arch.name}.inspect end private @@ -136,10 +136,10 @@ class BuildList < ActiveRecord::Base def place_build #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web - self.status = BuildServer.add_build_list project.name, project_version, pl.unixname, arch.name, (pl_id == bpl_id ? '' : bpl.unixname), update_type, build_requires, id + self.status = BuildServer.add_build_list project.name, project_version, pl.name, arch.name, (pl_id == bpl_id ? '' : bpl.name), update_type, build_requires, id self.status = BUILD_PENDING if self.status == 0 save end #handle_asynchronously :place_build -end \ No newline at end of file +end diff --git a/app/models/platform.rb b/app/models/platform.rb index 8665d7b95..c78f30200 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -1,5 +1,3 @@ -#require 'lib/build_server.rb' -class Platform < ActiveRecord::Base VISIBILITIES = ['open', 'hidden'] belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' @@ -13,8 +11,8 @@ class Platform < ActiveRecord::Base has_many :members, :through => :objects, :source => :object, :source_type => 'User' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' - validates :name, :presence => true, :uniqueness => true - validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ } + validates :description, :presence => true, :uniqueness => true + validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ } validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} @@ -45,11 +43,11 @@ class Platform < ActiveRecord::Base if pl.distrib_type == APP_CONFIG['distr_types'].first Arch.all.each do |arch| tail = "/#{arch.name}/main/release" - urpmi_commands[pl.name] << "urpmi.addmedia #{unixname} #{head}#{unixname}/repository/#{pl.unixname}#{tail}" + urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{head}#{name}/repository/#{pl.name}#{tail}" end else tail = '' - urpmi_commands[pl.name] << "urpmi.addmedia #{unixname} #{head}#{unixname}/repository/#{pl.unixname}#{tail}" + urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{head}#{name}/repository/#{pl.name}#{tail}" end end @@ -57,7 +55,7 @@ class Platform < ActiveRecord::Base end def path - build_path(unixname) + build_path(name) end def hidden? @@ -68,7 +66,7 @@ class Platform < ActiveRecord::Base platform_type == 'personal' end - def full_clone(attrs) # :name, :unixname, :owner + def full_clone(attrs) # :description, :name, :owner clone.tap do |c| c.attributes = attrs c.updated_at = nil; c.created_at = nil # :id = nil @@ -84,7 +82,7 @@ class Platform < ActiveRecord::Base p = full_clone(attrs) begin Thread.current[:skip] = true - p.save and xml_rpc_clone(attrs[:unixname]) + p.save and xml_rpc_clone(attrs[:name]) ensure Thread.current[:skip] = false end @@ -106,19 +104,19 @@ class Platform < ActiveRecord::Base end def mount_directory_for_rsync - FileUtils.rm_rf "#{ Rails.root.join('tmp', 'umount', self.unixname) }" if File.exist? "#{ Rails.root.join('tmp', 'umount', unixname) }" - FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', unixname) }" + FileUtils.rm_rf "#{ Rails.root.join('tmp', 'umount', self.name) }" if File.exist? "#{ Rails.root.join('tmp', 'umount', name) }" + FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', name) }" Arch.all.each do |arch| host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host] - url = "http://#{host}/downloads/#{unixname}/repository/" + url = "http://#{host}/downloads/#{name}/repository/" str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{url}\n" - File.open(Rails.root.join('tmp', 'mount', unixname, "#{unixname}.#{arch.name}.list"), 'w') {|f| f.write(str) } + File.open(Rails.root.join('tmp', 'mount', name, "#{name}.#{arch.name}.list"), 'w') {|f| f.write(str) } end end def umount_directory_for_rsync - FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', unixname) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', unixname) }" - FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', unixname) }" + FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', name) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', name) }" + FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }" end protected @@ -128,35 +126,35 @@ class Platform < ActiveRecord::Base end def xml_rpc_create - result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] + '/platforms' , distrib_type + result = BuildServer.add_platform name, APP_CONFIG['root_path'] + '/platforms' , distrib_type if result == BuildServer::SUCCESS return true else - raise "Failed to create platform #{name} with code #{result}. Path: #{build_path(unixname)}" + raise "Failed to create platform #{name} with code #{result}. Path: #{build_path(name)}" end end def xml_rpc_destroy - result = BuildServer.delete_platform unixname + result = BuildServer.delete_platform name if result == BuildServer::SUCCESS return true else - raise "Failed to delete platform #{unixname} with code #{result}." + raise "Failed to delete platform #{name} with code #{result}." end end - def xml_rpc_clone(new_unixname) - result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] + '/platforms' + def xml_rpc_clone(new_name) + result = BuildServer.clone_platform new_name, self.name, APP_CONFIG['root_path'] + '/platforms' if result == BuildServer::SUCCESS return true else - raise "Failed to clone platform #{name} with code #{result}. Path: #{build_path(unixname)} to platform #{new_unixname}" + raise "Failed to clone platform #{name} with code #{result}. Path: #{build_path(name)} to platform #{new_name}" end end def check_freezing if released_changed? - BuildServer.freeze_platform self.unixname + BuildServer.freeze_platform self.name end end end diff --git a/app/models/private_user.rb b/app/models/private_user.rb index 36e26a978..48afa84f9 100644 --- a/app/models/private_user.rb +++ b/app/models/private_user.rb @@ -8,7 +8,7 @@ class PrivateUser < ActiveRecord::Base validate :login, :uniqueness => true def event_log_message - {:platform => platform.unixname, :user => user.uname}.inspect + {:platform => platform.name, :user => user.uname}.inspect end class << self @@ -30,4 +30,4 @@ class PrivateUser < ActiveRecord::Base {:login => login, :pass => pass} end end -end \ No newline at end of file +end diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 758d0abde..09d936ea2 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -30,7 +30,7 @@ class ProductBuildList < ActiveRecord::Base return true else # return false - raise "Failed to create product_build_list #{id} inside platform #{product.platform.unixname} with code #{result}." + raise "Failed to create product_build_list #{id} inside platform #{product.platform.name} tar url #{tar_url} with code #{result}." end end end diff --git a/app/models/project.rb b/app/models/project.rb index 5e2e884c6..cc46d9c71 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -14,13 +14,13 @@ class Project < ActiveRecord::Base has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User' has_many :groups, :through => :relations, :source => :object, :source_type => 'Group' - validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true - validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ } + validates :description, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true + validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ } validates :owner, :presence => true # validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?} - #attr_accessible :category_id, :name, :unixname, :description, :visibility - attr_readonly :unixname + #attr_accessible :category_id, :name, :description, :visibility + attr_readonly :name scope :recent, order("name ASC") scope :by_name, lambda { |name| where('name like ?', '%' + name + '%') } @@ -72,7 +72,7 @@ class Project < ActiveRecord::Base end def git_repo_name - File.join owner.uname, unixname + File.join owner.uname, name end def public? @@ -93,16 +93,16 @@ class Project < ActiveRecord::Base end def xml_rpc_create(repository) - result = BuildServer.create_project unixname, repository.platform.unixname, repository.unixname, path + result = BuildServer.create_project name, repository.platform.name, repository.name, path if result == BuildServer::SUCCESS return true else - raise "Failed to create project #{unixname} (repo #{repository.unixname}) inside platform #{repository.platform.unixname} in path #{path} with code #{result}." + raise "Failed to create project #{name} (repo #{repository.name}) inside platform #{repository.platform.name} in path #{path} with code #{result}." end end def xml_rpc_destroy(repository) - result = BuildServer.delete_project unixname, repository.platform.unixname + result = BuildServer.delete_project name, repository.platform.name if result == BuildServer::SUCCESS return true else diff --git a/app/models/repository.rb b/app/models/repository.rb index 91b3b4a67..6d324bf21 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -10,8 +10,8 @@ class Repository < ActiveRecord::Base has_many :members, :through => :objects, :source => :object, :source_type => 'User' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' - validates :name, :uniqueness => {:scope => :platform_id}, :presence => true - validates :unixname, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-z0-9_]+$/ } + validates :description, :uniqueness => {:scope => :platform_id}, :presence => true + validates :name, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-z0-9_]+$/ } # validates :platform_id, :presence => true # if you uncomment this platform clone will not work scope :recent, order("name ASC") @@ -19,7 +19,7 @@ class Repository < ActiveRecord::Base before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy - attr_accessible :name, :unixname #, :platform_id + attr_accessible :description, :name #, :platform_id def full_clone(attrs) # owner clone.tap do |c| # dup @@ -34,7 +34,7 @@ class Repository < ActiveRecord::Base protected def xml_rpc_create - result = BuildServer.create_repo unixname, platform.unixname + result = BuildServer.create_repo name, platform.name if result == BuildServer::SUCCESS return true else @@ -43,7 +43,7 @@ class Repository < ActiveRecord::Base end def xml_rpc_destroy - result = BuildServer.delete_repo unixname, platform.unixname + result = BuildServer.delete_repo name, platform.name if result == BuildServer::SUCCESS return true else diff --git a/app/views/personal_repositories/projects_list.html.haml b/app/views/personal_repositories/projects_list.html.haml index 9f5b76a01..4766fcb0b 100644 --- a/app/views/personal_repositories/projects_list.html.haml +++ b/app/views/personal_repositories/projects_list.html.haml @@ -12,9 +12,9 @@ = @repository.name %p %b - = t("activerecord.attributes.repository.unixname") + = t("activerecord.attributes.repository.description") \: - = @repository.unixname + = @repository.description %p %b = t("activerecord.attributes.repository.platform") diff --git a/app/views/platforms/_form.html.haml b/app/views/platforms/_form.html.haml index 82504a52b..8b700e1ee 100644 --- a/app/views/platforms/_form.html.haml +++ b/app/views/platforms/_form.html.haml @@ -3,8 +3,8 @@ = f.text_field :name, :class => 'text_field' .group - = f.label :unixname, :class => :label - = f.text_field :unixname, :class => 'text_field' + = f.label :description, :class => :label + = f.text_field :description, :class => 'text_field' .group = f.label :distrib_type, :class => :label @@ -12,7 +12,7 @@ .group = f.label :parent, :class => :label - = f.collection_select :parent_platform_id, Platform.all, :id, :name, :include_blank => true + = f.collection_select :parent_platform_id, Platform.all, :id, :description, :include_blank => true .group = f.label :released, :class => :label diff --git a/app/views/platforms/clone.html.haml b/app/views/platforms/clone.html.haml index 635add63b..045e2956a 100644 --- a/app/views/platforms/clone.html.haml +++ b/app/views/platforms/clone.html.haml @@ -14,8 +14,8 @@ = f.text_field :name, :class => 'text_field' .group - = f.label :unixname, :class => :label - = f.text_field :unixname, :class => 'text_field' + = f.label :description, :class => :label + = f.text_field :description, :class => 'text_field' .group.navform.wat-cf %button.button{:type => "submit"} diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/show.html.haml index b150b967b..6b166ea7d 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/show.html.haml @@ -14,16 +14,16 @@ = @platform.name %p %b - = t("activerecord.attributes.platform.unixname") + = t("activerecord.attributes.platform.description") \: - = @platform.unixname + = @platform.description - if @platform.parent %p %b = t("activerecord.attributes.platform.parent") \: - if @platform.parent - = link_to @platform.parent.name, platform_path(@platform.parent) + = link_to @platform.parent.description, platform_path(@platform.parent) %p %b = t('layout.platforms.location') @@ -76,12 +76,12 @@ .inner %table.table %tr - %th.first= t("activerecord.attributes.repository.name") + %th.first= t("activerecord.attributes.repository.description") %th.last   - @platform.repositories.recent.each do |repository| %tr{:class => cycle("odd", "even")} %td - = link_to repository.name, platform_repository_path(@platform, repository) + = link_to repository.description, platform_repository_path(@platform, repository) %td.last = link_to t("layout.show"), platform_repository_path(@platform, repository) | diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 62c3f06c6..832d033bb 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -3,10 +3,7 @@ = f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true .group = f.label :name, t("activerecord.attributes.project.name"), :class => :label - = f.text_field :name, :class => 'text_field' -.group - = f.label :unixname, t("activerecord.attributes.project.unixname"), :class => :label - = f.text_field :unixname, :class => 'text_field', :disabled => f.object.try(:persisted?) + = f.text_field :name, :class => 'text_field', :disabled => f.object.try(:persisted?) .group = f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label = f.select :visibility, Project::VISIBILITIES diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml index 72ad96be9..8d8dad9ad 100644 --- a/app/views/projects/_list.html.haml +++ b/app/views/projects/_list.html.haml @@ -5,7 +5,7 @@ %th.last   - @projects.each do |project| %tr{:class => cycle("odd", "even")} - %td= link_to "#{project.name} (#{project.unixname})", project + %td= link_to "#{project.name} (#{project.name})", project %td= link_to "#{project.owner.name} (#{project.owner.uname})", project.owner %td = link_to t("layout.edit"), edit_project_path(project) if can? :update, project diff --git a/app/views/projects/_own_projects_sidebar.html.haml b/app/views/projects/_own_projects_sidebar.html.haml index 9d39991b6..653529375 100644 --- a/app/views/projects/_own_projects_sidebar.html.haml +++ b/app/views/projects/_own_projects_sidebar.html.haml @@ -5,7 +5,7 @@ %ul - @own_projects.each do |project| %li - = link_to project.unixname, project_path(project) + = link_to project.name, project_path(project) .block.notice %h3= t("layout.users.part_projects") .content @@ -13,4 +13,4 @@ %ul - @part_projects.each do |project| %li - = link_to project.owner.uname + '/' + project.unixname + ' (' + project.name + ')', project_path(project) + = link_to project.owner.uname + '/' + project.name + ' (' + project.name + ')', project_path(project) diff --git a/app/views/projects/_project.html.haml b/app/views/projects/_project.html.haml index 9be9a1ddd..6f6c7b68d 100644 --- a/app/views/projects/_project.html.haml +++ b/app/views/projects/_project.html.haml @@ -1,4 +1,4 @@ %tr{:class => cycle("odd", "even")} %td= link_to project.name, project_path(project) - %td= project.unixname - %td= project.description \ No newline at end of file + %td= project.name + %td= project.description diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 01b584cdb..3930d97a2 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -14,11 +14,6 @@ = t("activerecord.attributes.project.name") \: = @project.name - %p - %b - = t("activerecord.attributes.project.unixname") - \: - = @project.unixname %p %b = t("activerecord.attributes.project.owner") diff --git a/app/views/repositories/_form.html.haml b/app/views/repositories/_form.html.haml index e7e0aa710..e569a97e5 100644 --- a/app/views/repositories/_form.html.haml +++ b/app/views/repositories/_form.html.haml @@ -2,8 +2,8 @@ = f.label :name, t("activerecord.attributes.repository.name"), :class => :label = f.text_field :name, :class => 'text_field' .group - = f.label :unixname, t("activerecord.attributes.repository.unixname"), :class => :label - = f.text_field :unixname, :class => 'text_field' + = f.label :description, t("activerecord.attributes.repository.description"), :class => :label + = f.text_field :description, :class => 'text_field' .group.navform.wat-cf %button.button{:type => "submit"} diff --git a/app/views/repositories/projects_list.html.haml b/app/views/repositories/projects_list.html.haml index 80c9e55cf..4ec35da79 100644 --- a/app/views/repositories/projects_list.html.haml +++ b/app/views/repositories/projects_list.html.haml @@ -13,19 +13,19 @@ = @repository.name %p %b - = t("activerecord.attributes.repository.unixname") + = t("activerecord.attributes.repository.description") \: - = @repository.unixname + = @repository.description %p %b = t("activerecord.attributes.repository.platform") \: - = link_to @repository.platform.name, url_for(@repository.platform) + = link_to @repository.platform.description, url_for(@repository.platform) %p %b = t("activerecord.attributes.repository.owner") \: - = link_to @repository.owner.try(:name), url_for(@repository.owner) + = link_to @repository.owner.try(:description), url_for(@repository.owner) .wat-cf = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml index 3616143d2..c53a54ef3 100644 --- a/app/views/repositories/show.html.haml +++ b/app/views/repositories/show.html.haml @@ -13,19 +13,19 @@ = @repository.name %p %b - = t("activerecord.attributes.repository.unixname") + = t("activerecord.attributes.repository.description") \: - = @repository.unixname + = @repository.description %p %b = t("activerecord.attributes.repository.platform") \: - = link_to @repository.platform.name, url_for(@repository.platform) + = link_to @repository.platform.description, url_for(@repository.platform) %p %b = t("activerecord.attributes.repository.owner") \: - = link_to @repository.owner.try(:name), url_for(@repository.owner) + = link_to @repository.owner.try(:description), url_for(@repository.owner) .wat-cf = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") if can? :destroy, @repository diff --git a/db/migrate/20111128140341_rename_name_and_unixname.rb b/db/migrate/20111128140341_rename_name_and_unixname.rb new file mode 100644 index 000000000..545a115a8 --- /dev/null +++ b/db/migrate/20111128140341_rename_name_and_unixname.rb @@ -0,0 +1,19 @@ +class RenameNameAndUnixname < ActiveRecord::Migration + def self.up + rename_column :projects, :name, :description + rename_column :projects, :unixname, :name + rename_column :platforms, :name, :description + rename_column :platforms, :unixname, :name + rename_column :repositories, :name, :description + rename_column :repositories, :unixname, :name + end + + def self.down + rename_column :projects, :description, :name + rename_column :projects, :name, :unixname + rename_column :platforms, :description, :name + rename_column :platforms, :name, :unixname + rename_column :repositories, :description, :name + rename_column :repositories, :name, :unixname + end +end diff --git a/lib/grack/base.rb b/lib/grack/base.rb index cafacc5f3..1d77f2af4 100644 --- a/lib/grack/base.rb +++ b/lib/grack/base.rb @@ -33,10 +33,10 @@ module Grack def project @project ||= begin - uname, unixname = @env['PATH_INFO'].split('/')[1,2] - unixname.gsub! /\.git$/, '' + uname, name = @env['PATH_INFO'].split('/')[1,2] + name.gsub! /\.git$/, '' owner = User.find_by_uname(uname) || Group.find_by_uname(uname) - Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_unixname(unixname) + Project.where(:owner_id => owner.id, :owner_type => owner.class).find_by_name(name) end end diff --git a/lib/modules/models/personal_repository.rb b/lib/modules/models/personal_repository.rb index aa20e21e7..db0b41df5 100644 --- a/lib/modules/models/personal_repository.rb +++ b/lib/modules/models/personal_repository.rb @@ -12,7 +12,7 @@ module Modules pl = platforms.build pl.owner = self pl.name = "#{self.uname}_personal" - pl.unixname = "#{self.uname}_personal" + pl.name = "#{self.uname}_personal" pl.platform_type = 'personal' pl.distrib_type = APP_CONFIG['distr_types'].first pl.visibility = 'hidden' @@ -21,7 +21,7 @@ module Modules rep = pl.repositories.build rep.owner = pl.owner rep.name = 'main' - rep.unixname = 'main' + rep.name = 'main' rep.save! end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index c550fab17..1f08e4170 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -9,7 +9,7 @@ namespace :import do print "Import #{name}..." owner = User.find(1) # I am # owner = Group.find(1) # Core Team - p = Project.find_or_create_by_name_and_unixname(name, name) {|p| p.owner = owner} + p = Project.find_or_create_by_name_and_name(name, name) {|p| p.owner = owner} puts p.persisted? ? "Ok!" : "Fail!" end puts 'DONE' diff --git a/lib/tasks/migrate_repos_task.rake b/lib/tasks/migrate_repos_task.rake index 76127fac8..b5a64cef3 100644 --- a/lib/tasks/migrate_repos_task.rake +++ b/lib/tasks/migrate_repos_task.rake @@ -18,7 +18,7 @@ namespace :repositories do next end - project = main.projects.create(:name => project_name, :unixname => project_name) + project = main.projects.create(:name => project_name, :name => project_name) puts "Executing: 'rm -rf #{project.path}'" `rm -rf #{project.path}`