[refs #2249] Global name to description and unixname to name renames

This commit is contained in:
konstantin.grabar 2011-11-28 19:41:42 +04:00
parent cfceda9c53
commit 148a0fec28
30 changed files with 109 additions and 100 deletions

View File

@ -15,7 +15,7 @@ class AutoBuildListsController < ApplicationController
def create def create
@auto_build_list = AutoBuildList.new( @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, :pl_id => current_user.personal_platform.id,
:arch_id => Arch.find_by_name('i586').id, :arch_id => Arch.find_by_name('i586').id,
:project_id => params[:project_id]) :project_id => params[:project_id])

View File

@ -28,7 +28,7 @@ class PersonalRepositoriesController < ApplicationController
if params[:project_id] if params[:project_id]
@project = Project.find(params[:project_id]) @project = Project.find(params[:project_id])
# params[:project_id] = nil # params[:project_id] = nil
unless @repository.projects.find_by_unixname(@project.unixname) unless @repository.projects.find_by_name(@project.name)
@repository.projects << @project @repository.projects << @project
flash[:notice] = t('flash.repository.project_added') flash[:notice] = t('flash.repository.project_added')
else else

View File

@ -16,10 +16,10 @@ class PlatformsController < ApplicationController
format.json do format.json do
render :json => { render :json => {
:platforms => @platforms.map do |p| :platforms => @platforms.map do |p|
{:name => p.unixname, {:name => p.name,
:architectures => ['i586', 'x86_64'], :architectures => ['i586', 'x86_64'],
:repositories => p.repositories.map(&:unixname), :repositories => p.repositories.map(&:name),
:url => "http://#{request.host_with_port}/downloads/#{p.unixname}/repository/"} :url => "http://#{request.host_with_port}/downloads/#{p.name}/repository/"}
end end
} }
end end
@ -77,7 +77,7 @@ class PlatformsController < ApplicationController
def clone def clone
if request.post? 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) :owner_id => current_user.id, :owner_type => current_user.class.to_s)
if @cloned.persisted? if @cloned.persisted?
flash[:notice] = 'Клонирование успешно' flash[:notice] = 'Клонирование успешно'
@ -88,7 +88,7 @@ class PlatformsController < ApplicationController
else else
@cloned = Platform.new @cloned = Platform.new
@cloned.name = @platform.name + "_clone" @cloned.name = @platform.name + "_clone"
@cloned.unixname = @platform.unixname + "_clone" @cloned.description = @platform.description + "_clone"
end end
end end

View File

@ -64,9 +64,9 @@ class ProjectsController < ApplicationController
# TODO remove this? # TODO remove this?
def auto_build 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) 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 project.delay.auto_build # TODO don't queue duplicates
# p = params.delete_if{|k,v| k == 'controller' or k == 'action'} # p = params.delete_if{|k,v| k == 'controller' or k == 'action'}
@ -79,7 +79,7 @@ class ProjectsController < ApplicationController
def build def build
@arches = Arch.recent @arches = Arch.recent
@bpls = Platform.main @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 @project_versions = @project.collected_project_versions
end end
@ -101,7 +101,7 @@ class ProjectsController < ApplicationController
if !check_arches || !check_project_versions if !check_arches || !check_project_versions
@arches = Arch.recent @arches = Arch.recent
@bpls = Platform.main @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" render :action => "build"
else else

View File

@ -54,7 +54,7 @@ class RepositoriesController < ApplicationController
if params[:project_id] if params[:project_id]
@project = Project.find(params[:project_id]) @project = Project.find(params[:project_id])
# params[:project_id] = nil # params[:project_id] = nil
unless @repository.projects.find_by_unixname(@project.unixname) unless @repository.projects.find_by_name(@project.name)
@repository.projects << @project @repository.projects << @project
flash[:notice] = t('flash.repository.project_added') flash[:notice] = t('flash.repository.project_added')
else else

View File

@ -12,12 +12,12 @@ class RpcController < ApplicationController
def platforms def platforms
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список платформ') 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 end
def user_projects def user_projects
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список пользовательских проектов') 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 end
def project_versions id def project_versions id

View File

@ -5,6 +5,6 @@ class AutoBuildList < ActiveRecord::Base
belongs_to :bpl, :class_name => 'Platform' belongs_to :bpl, :class_name => 'Platform'
def event_log_message def event_log_message
{:project => project.unixname}.inspect {:project => project.name}.inspect
end end
end end

View File

@ -125,7 +125,7 @@ class BuildList < ActiveRecord::Base
end end
def event_log_message 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 end
private private
@ -136,7 +136,7 @@ class BuildList < ActiveRecord::Base
def place_build def place_build
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web #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 self.status = BUILD_PENDING if self.status == 0
save save
end end

View File

@ -1,5 +1,3 @@
#require 'lib/build_server.rb'
class Platform < ActiveRecord::Base
VISIBILITIES = ['open', 'hidden'] VISIBILITIES = ['open', 'hidden']
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' 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 :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :name, :presence => true, :uniqueness => true validates :description, :presence => true, :uniqueness => true
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ } validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} 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 if pl.distrib_type == APP_CONFIG['distr_types'].first
Arch.all.each do |arch| Arch.all.each do |arch|
tail = "/#{arch.name}/main/release" 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 end
else else
tail = '' 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
end end
@ -57,7 +55,7 @@ class Platform < ActiveRecord::Base
end end
def path def path
build_path(unixname) build_path(name)
end end
def hidden? def hidden?
@ -68,7 +66,7 @@ class Platform < ActiveRecord::Base
platform_type == 'personal' platform_type == 'personal'
end end
def full_clone(attrs) # :name, :unixname, :owner def full_clone(attrs) # :description, :name, :owner
clone.tap do |c| clone.tap do |c|
c.attributes = attrs c.attributes = attrs
c.updated_at = nil; c.created_at = nil # :id = nil c.updated_at = nil; c.created_at = nil # :id = nil
@ -84,7 +82,7 @@ class Platform < ActiveRecord::Base
p = full_clone(attrs) p = full_clone(attrs)
begin begin
Thread.current[:skip] = true Thread.current[:skip] = true
p.save and xml_rpc_clone(attrs[:unixname]) p.save and xml_rpc_clone(attrs[:name])
ensure ensure
Thread.current[:skip] = false Thread.current[:skip] = false
end end
@ -106,19 +104,19 @@ class Platform < ActiveRecord::Base
end end
def mount_directory_for_rsync 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.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', unixname) }" FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', name) }"
Arch.all.each do |arch| Arch.all.each do |arch|
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host] 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" 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
end end
def umount_directory_for_rsync def umount_directory_for_rsync
FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', unixname) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', 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', unixname) }" FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }"
end end
protected protected
@ -128,35 +126,35 @@ class Platform < ActiveRecord::Base
end end
def xml_rpc_create 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 if result == BuildServer::SUCCESS
return true return true
else 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
end end
def xml_rpc_destroy def xml_rpc_destroy
result = BuildServer.delete_platform unixname result = BuildServer.delete_platform name
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
else else
raise "Failed to delete platform #{unixname} with code #{result}." raise "Failed to delete platform #{name} with code #{result}."
end end
end end
def xml_rpc_clone(new_unixname) def xml_rpc_clone(new_name)
result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] + '/platforms' result = BuildServer.clone_platform new_name, self.name, APP_CONFIG['root_path'] + '/platforms'
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
else 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
end end
def check_freezing def check_freezing
if released_changed? if released_changed?
BuildServer.freeze_platform self.unixname BuildServer.freeze_platform self.name
end end
end end
end end

View File

@ -8,7 +8,7 @@ class PrivateUser < ActiveRecord::Base
validate :login, :uniqueness => true validate :login, :uniqueness => true
def event_log_message def event_log_message
{:platform => platform.unixname, :user => user.uname}.inspect {:platform => platform.name, :user => user.uname}.inspect
end end
class << self class << self

View File

@ -30,7 +30,7 @@ class ProductBuildList < ActiveRecord::Base
return true return true
else else
# return false # 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 end
end end

View File

@ -14,13 +14,13 @@ class Project < ActiveRecord::Base
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User' has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group' has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true validates :description, :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 :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-\+\.]+$/ }
validates :owner, :presence => true validates :owner, :presence => true
# validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?} # 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_accessible :category_id, :name, :description, :visibility
attr_readonly :unixname attr_readonly :name
scope :recent, order("name ASC") scope :recent, order("name ASC")
scope :by_name, lambda { |name| where('name like ?', '%' + name + '%') } scope :by_name, lambda { |name| where('name like ?', '%' + name + '%') }
@ -72,7 +72,7 @@ class Project < ActiveRecord::Base
end end
def git_repo_name def git_repo_name
File.join owner.uname, unixname File.join owner.uname, name
end end
def public? def public?
@ -93,16 +93,16 @@ class Project < ActiveRecord::Base
end end
def xml_rpc_create(repository) 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 if result == BuildServer::SUCCESS
return true return true
else 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
end end
def xml_rpc_destroy(repository) 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 if result == BuildServer::SUCCESS
return true return true
else else

View File

@ -10,8 +10,8 @@ class Repository < ActiveRecord::Base
has_many :members, :through => :objects, :source => :object, :source_type => 'User' has_many :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :name, :uniqueness => {:scope => :platform_id}, :presence => true validates :description, :uniqueness => {:scope => :platform_id}, :presence => true
validates :unixname, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-z0-9_]+$/ } 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 # validates :platform_id, :presence => true # if you uncomment this platform clone will not work
scope :recent, order("name ASC") scope :recent, order("name ASC")
@ -19,7 +19,7 @@ class Repository < ActiveRecord::Base
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy before_destroy :xml_rpc_destroy
attr_accessible :name, :unixname #, :platform_id attr_accessible :description, :name #, :platform_id
def full_clone(attrs) # owner def full_clone(attrs) # owner
clone.tap do |c| # dup clone.tap do |c| # dup
@ -34,7 +34,7 @@ class Repository < ActiveRecord::Base
protected protected
def xml_rpc_create def xml_rpc_create
result = BuildServer.create_repo unixname, platform.unixname result = BuildServer.create_repo name, platform.name
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
else else
@ -43,7 +43,7 @@ class Repository < ActiveRecord::Base
end end
def xml_rpc_destroy def xml_rpc_destroy
result = BuildServer.delete_repo unixname, platform.unixname result = BuildServer.delete_repo name, platform.name
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
else else

View File

@ -12,9 +12,9 @@
= @repository.name = @repository.name
%p %p
%b %b
= t("activerecord.attributes.repository.unixname") = t("activerecord.attributes.repository.description")
\: \:
= @repository.unixname = @repository.description
%p %p
%b %b
= t("activerecord.attributes.repository.platform") = t("activerecord.attributes.repository.platform")

View File

@ -3,8 +3,8 @@
= f.text_field :name, :class => 'text_field' = f.text_field :name, :class => 'text_field'
.group .group
= f.label :unixname, :class => :label = f.label :description, :class => :label
= f.text_field :unixname, :class => 'text_field' = f.text_field :description, :class => 'text_field'
.group .group
= f.label :distrib_type, :class => :label = f.label :distrib_type, :class => :label
@ -12,7 +12,7 @@
.group .group
= f.label :parent, :class => :label = 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 .group
= f.label :released, :class => :label = f.label :released, :class => :label

View File

@ -14,8 +14,8 @@
= f.text_field :name, :class => 'text_field' = f.text_field :name, :class => 'text_field'
.group .group
= f.label :unixname, :class => :label = f.label :description, :class => :label
= f.text_field :unixname, :class => 'text_field' = f.text_field :description, :class => 'text_field'
.group.navform.wat-cf .group.navform.wat-cf
%button.button{:type => "submit"} %button.button{:type => "submit"}

View File

@ -14,16 +14,16 @@
= @platform.name = @platform.name
%p %p
%b %b
= t("activerecord.attributes.platform.unixname") = t("activerecord.attributes.platform.description")
\: \:
= @platform.unixname = @platform.description
- if @platform.parent - if @platform.parent
%p %p
%b %b
= t("activerecord.attributes.platform.parent") = t("activerecord.attributes.platform.parent")
\: \:
- if @platform.parent - if @platform.parent
= link_to @platform.parent.name, platform_path(@platform.parent) = link_to @platform.parent.description, platform_path(@platform.parent)
%p %p
%b %b
= t('layout.platforms.location') = t('layout.platforms.location')
@ -76,12 +76,12 @@
.inner .inner
%table.table %table.table
%tr %tr
%th.first= t("activerecord.attributes.repository.name") %th.first= t("activerecord.attributes.repository.description")
%th.last &nbsp; %th.last &nbsp;
- @platform.repositories.recent.each do |repository| - @platform.repositories.recent.each do |repository|
%tr{:class => cycle("odd", "even")} %tr{:class => cycle("odd", "even")}
%td %td
= link_to repository.name, platform_repository_path(@platform, repository) = link_to repository.description, platform_repository_path(@platform, repository)
%td.last %td.last
= link_to t("layout.show"), platform_repository_path(@platform, repository) = link_to t("layout.show"), platform_repository_path(@platform, repository)
| |

View File

@ -3,10 +3,7 @@
= f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true = f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true
.group .group
= f.label :name, t("activerecord.attributes.project.name"), :class => :label = f.label :name, t("activerecord.attributes.project.name"), :class => :label
= f.text_field :name, :class => 'text_field' = f.text_field :name, :class => 'text_field', :disabled => f.object.try(:persisted?)
.group
= f.label :unixname, t("activerecord.attributes.project.unixname"), :class => :label
= f.text_field :unixname, :class => 'text_field', :disabled => f.object.try(:persisted?)
.group .group
= f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label = f.label :visibility, t("activerecord.attributes.project.visibility"), :class => :label
= f.select :visibility, Project::VISIBILITIES = f.select :visibility, Project::VISIBILITIES

View File

@ -5,7 +5,7 @@
%th.last &nbsp; %th.last &nbsp;
- @projects.each do |project| - @projects.each do |project|
%tr{:class => cycle("odd", "even")} %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 "#{project.owner.name} (#{project.owner.uname})", project.owner
%td %td
= link_to t("layout.edit"), edit_project_path(project) if can? :update, project = link_to t("layout.edit"), edit_project_path(project) if can? :update, project

View File

@ -5,7 +5,7 @@
%ul %ul
- @own_projects.each do |project| - @own_projects.each do |project|
%li %li
= link_to project.unixname, project_path(project) = link_to project.name, project_path(project)
.block.notice .block.notice
%h3= t("layout.users.part_projects") %h3= t("layout.users.part_projects")
.content .content
@ -13,4 +13,4 @@
%ul %ul
- @part_projects.each do |project| - @part_projects.each do |project|
%li %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)

View File

@ -1,4 +1,4 @@
%tr{:class => cycle("odd", "even")} %tr{:class => cycle("odd", "even")}
%td= link_to project.name, project_path(project) %td= link_to project.name, project_path(project)
%td= project.unixname %td= project.name
%td= project.description %td= project.description

View File

@ -14,11 +14,6 @@
= t("activerecord.attributes.project.name") = t("activerecord.attributes.project.name")
\: \:
= @project.name = @project.name
%p
%b
= t("activerecord.attributes.project.unixname")
\:
= @project.unixname
%p %p
%b %b
= t("activerecord.attributes.project.owner") = t("activerecord.attributes.project.owner")

View File

@ -2,8 +2,8 @@
= f.label :name, t("activerecord.attributes.repository.name"), :class => :label = f.label :name, t("activerecord.attributes.repository.name"), :class => :label
= f.text_field :name, :class => 'text_field' = f.text_field :name, :class => 'text_field'
.group .group
= f.label :unixname, t("activerecord.attributes.repository.unixname"), :class => :label = f.label :description, t("activerecord.attributes.repository.description"), :class => :label
= f.text_field :unixname, :class => 'text_field' = f.text_field :description, :class => 'text_field'
.group.navform.wat-cf .group.navform.wat-cf
%button.button{:type => "submit"} %button.button{:type => "submit"}

View File

@ -13,19 +13,19 @@
= @repository.name = @repository.name
%p %p
%b %b
= t("activerecord.attributes.repository.unixname") = t("activerecord.attributes.repository.description")
\: \:
= @repository.unixname = @repository.description
%p %p
%b %b
= t("activerecord.attributes.repository.platform") = t("activerecord.attributes.repository.platform")
\: \:
= link_to @repository.platform.name, url_for(@repository.platform) = link_to @repository.platform.description, url_for(@repository.platform)
%p %p
%b %b
= t("activerecord.attributes.repository.owner") = 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 .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") = 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")

View File

@ -13,19 +13,19 @@
= @repository.name = @repository.name
%p %p
%b %b
= t("activerecord.attributes.repository.unixname") = t("activerecord.attributes.repository.description")
\: \:
= @repository.unixname = @repository.description
%p %p
%b %b
= t("activerecord.attributes.repository.platform") = t("activerecord.attributes.repository.platform")
\: \:
= link_to @repository.platform.name, url_for(@repository.platform) = link_to @repository.platform.description, url_for(@repository.platform)
%p %p
%b %b
= t("activerecord.attributes.repository.owner") = 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 .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 = 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

View File

@ -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

View File

@ -33,10 +33,10 @@ module Grack
def project def project
@project ||= begin @project ||= begin
uname, unixname = @env['PATH_INFO'].split('/')[1,2] uname, name = @env['PATH_INFO'].split('/')[1,2]
unixname.gsub! /\.git$/, '' name.gsub! /\.git$/, ''
owner = User.find_by_uname(uname) || Group.find_by_uname(uname) 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
end end

View File

@ -12,7 +12,7 @@ module Modules
pl = platforms.build pl = platforms.build
pl.owner = self pl.owner = self
pl.name = "#{self.uname}_personal" pl.name = "#{self.uname}_personal"
pl.unixname = "#{self.uname}_personal" pl.name = "#{self.uname}_personal"
pl.platform_type = 'personal' pl.platform_type = 'personal'
pl.distrib_type = APP_CONFIG['distr_types'].first pl.distrib_type = APP_CONFIG['distr_types'].first
pl.visibility = 'hidden' pl.visibility = 'hidden'
@ -21,7 +21,7 @@ module Modules
rep = pl.repositories.build rep = pl.repositories.build
rep.owner = pl.owner rep.owner = pl.owner
rep.name = 'main' rep.name = 'main'
rep.unixname = 'main' rep.name = 'main'
rep.save! rep.save!
end end

View File

@ -9,7 +9,7 @@ namespace :import do
print "Import #{name}..." print "Import #{name}..."
owner = User.find(1) # I am owner = User.find(1) # I am
# owner = Group.find(1) # Core Team # 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!" puts p.persisted? ? "Ok!" : "Fail!"
end end
puts 'DONE' puts 'DONE'

View File

@ -18,7 +18,7 @@ namespace :repositories do
next next
end 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}'" puts "Executing: 'rm -rf #{project.path}'"
`rm -rf #{project.path}` `rm -rf #{project.path}`