Merge branch 'itima_web_refactoring'

Conflicts:
	Gemfile
	Gemfile.lock
	app/models/user.rb
	app/views/layouts/application.html.haml
	config/locales/ru.yml
	config/routes.rb
	db/schema.rb
This commit is contained in:
George Vinogradov 2011-10-19 18:09:58 +04:00
commit ff36b1fdd3
78 changed files with 1539 additions and 143 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ public/stylesheets/compiled/*
public/assets/* public/assets/*
config/initializers/local.rb config/initializers/local.rb
public/system/* public/system/*
.rvmrc

View File

@ -51,6 +51,10 @@ group :development do
gem 'capistrano_colors', :require => false gem 'capistrano_colors', :require => false
end end
group :development, :test do
gem 'mysql2', '<= 0.2.9'
end
group :test do group :test do
gem 'rspec-rails', '~> 2.6.1' gem 'rspec-rails', '~> 2.6.1'
gem 'factory_girl_rails', '~> 1.2.0' gem 'factory_girl_rails', '~> 1.2.0'

View File

@ -105,6 +105,7 @@ GEM
multi_json (1.0.3) multi_json (1.0.3)
multi_xml (0.4.1) multi_xml (0.4.1)
multipart-post (1.1.3) multipart-post (1.1.3)
mysql2 (0.2.9)
net-ldap (0.2.2) net-ldap (0.2.2)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
@ -154,7 +155,7 @@ GEM
oa-oauth (= 0.3.0) oa-oauth (= 0.3.0)
oa-openid (= 0.3.0) oa-openid (= 0.3.0)
orm_adapter (0.0.5) orm_adapter (0.0.5)
paperclip (2.4.3) paperclip (2.4.4)
activerecord (>= 2.3.0) activerecord (>= 2.3.0)
activesupport (>= 2.3.2) activesupport (>= 2.3.2)
cocaine (>= 0.0.2) cocaine (>= 0.0.2)
@ -186,10 +187,10 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (~> 0.14.4) thor (~> 0.14.4)
raindrops (0.7.0) raindrops (0.8.0)
rake (0.9.2) rake (0.9.2)
rbx-require-relative (0.0.5) rbx-require-relative (0.0.5)
rdoc (3.10) rdoc (3.11)
json (~> 1.4) json (~> 1.4)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
@ -256,6 +257,7 @@ DEPENDENCIES
haml-rails (~> 0.3.4) haml-rails (~> 0.3.4)
hpricot hpricot
jammit jammit
mysql2 (<= 0.2.9)
oa-openid (~> 0.3.0) oa-openid (~> 0.3.0)
omniauth (~> 0.3.0) omniauth (~> 0.3.0)
paperclip (~> 2.3) paperclip (~> 2.3)

View File

@ -1,7 +1,45 @@
# coding: UTF-8
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
layout :layout_by_resource layout :layout_by_resource
private
def checkright(role_id)
@role=Role.find(role_id)
if @role.name.downcase!="admin"
@c = self.controller_name
@a = self.action_name
case @c
when "projects"
case @a
when "new", "show", "create"
@right=1,2
when "build", "process_build"
@right=3
end
when "repositories"
case @a
when "show"
@right=4
when "add_project", "remove_project"
@right=5
when "new", "create"
@right=6
end
when "platforms"
case @a
when "edit", "update", "freeze", "unfreeze"
@right=7
end
else return true
end
Permission.where(:role_id => @role.id, :right_id => @right).first
@ok=false if @permission.nil?
if not @ok
flash[:notice] = t('layout.not_access')
redirect_to(:back)
end
end
end
protected protected
def layout_by_resource def layout_by_resource
if devise_controller? if devise_controller?

View File

@ -0,0 +1,50 @@
# coding: UTF-8
class GroupsController < ApplicationController
before_filter :authenticate_user!
before_filter :find_group, :only => [:show, :edit, :update, :destroy]
def index
@groups = Group.paginate(:page => params[:page], :per_page => 15)
end
def show
@platforms = @group.platforms.paginate(:page => params[:platform_page], :per_page => 10)
@repositories = @group.repositories.paginate(:page => params[:repository_page], :per_page => 10)
@projects = @group.projects.paginate(:page => params[:project_page], :per_page => 10)
end
def edit
end
def destroy
@user.destroy
flash[:notice] = t("flash.group.destroyed")
redirect_to groups_path
end
def new
@group = Group.new
end
def create
@group = Group.new params[:group]
@group.owner = current_user
@group.members << current_user
if @group.save
flash[:notice] = t('flash.group.saved')
redirect_to edit_group_path(@group)
else
flash[:error] = t('flash.group.save_error')
render :action => :new
end
end
private
def find_group
@group = Group.find(params[:id])
end
end

View File

@ -4,14 +4,16 @@ class PlatformsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_platform, :only => [:freeze, :unfreeze, :clone] before_filter :find_platform, :only => [:freeze, :unfreeze, :clone]
before_filter :get_paths, :only => [:new, :create]
def index def index
@platforms = Platform.all @platforms = Platform.paginate(:page => params[:platform_page])
end end
def show def show
@platform = Platform.find params[:id], :include => :repositories @platform = Platform.find params[:id], :include => :repositories
@repositories = @platform.repositories @repositories = @platform.repositories
@members = @platform.members.uniq
end end
def new def new
@ -21,6 +23,9 @@ class PlatformsController < ApplicationController
def create def create
@platform = Platform.new params[:platform] @platform = Platform.new params[:platform]
@platform.owner = get_acter
if @platform.save if @platform.save
flash[:notice] = I18n.t("flash.platform.saved") flash[:notice] = I18n.t("flash.platform.saved")
redirect_to @platform redirect_to @platform
@ -72,6 +77,21 @@ class PlatformsController < ApplicationController
end end
protected protected
def get_paths
if params[:user_id]
@user = User.find params[:user_id]
@platforms_path = user_platforms_path @user
@new_platform_path = new_user_platform_path @user
elsif params[:group_id]
@group = Group.find params[:group_id]
@platforms_path = group_platforms_path @group
@new_platform_path = new_group_platform_path @group
else
@platforms_path = platforms_path
@new_platform_path = new_platform_path
end
end
def find_platform def find_platform
@platform = Platform.find params[:id] @platform = Platform.find params[:id]
end end

View File

@ -1,11 +1,12 @@
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]
before_filter :get_paths, :only => [:new, :create]
def new def new
@project = @repository.projects.new @project = Project.new
end end
def show def show
@ -44,10 +45,12 @@ class ProjectsController < ApplicationController
end end
def create def create
@project = @repository.projects.new params[:project] @project = Project.new params[:project]
@project.owner = get_acter
if @project.save if @project.save
flash[:notice] = t('flash.project.saved') flash[:notice] = t('flash.project.saved')
redirect_to [@platform, @repository] redirect_to @project.owner
else else
flash[:error] = t('flash.project.save_error') flash[:error] = t('flash.project.save_error')
render :action => :new render :action => :new
@ -63,6 +66,21 @@ class ProjectsController < ApplicationController
protected protected
def get_paths
if params[:user_id]
@user = User.find params[:user_id]
@projects_path = user_projects_path @user
@new_project_path = new_user_project_path @user
elsif params[:group_id]
@group = Group.find params[:group_id]
@projects_path = group_projects_path @group
@new_projects_path = new_group_project_path @group
else
@projects_path = projects_path
@new_projects_path = new_project_path
end
end
def find_platform def find_platform
@platform = Platform.find params[:platform_id] @platform = Platform.find params[:platform_id]
end end
@ -72,7 +90,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

@ -1,18 +1,24 @@
class RepositoriesController < ApplicationController class RepositoriesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_platform #before_filter :find_platform, :except => [:index, :new, :create]
before_filter :find_repository, :only => [:show, :destroy] before_filter :find_repository, :only => [:show, :destroy, :add_project, :remove_project]
before_filter :get_paths, :only => [:show, :new, :create, :add_project, :remove_project]
before_filter :find_platforms, :only => [:new, :create]
def index
@repositories = Repository.paginate(:page => params[:repository_page])
end
def show def show
if params[:query] if params[:query]
@projects = @repository.projects.recent.by_name(params[:query]).paginate :page => params[:page], :per_page => 30 @projects = @repository.projects.recent.by_name(params[:query]).paginate :page => params[:project_page], :per_page => 30
else else
@projects = @repository.projects.recent.paginate :page => params[:page], :per_page => 30 @projects = @repository.projects.recent.paginate :page => params[:project_page], :per_page => 30
end end
end end
def new def new
@repository = @platform.repositories.new @repository = Repository.new
end end
def destroy def destroy
@ -23,23 +29,91 @@ class RepositoriesController < ApplicationController
end end
def create def create
@repository = @platform.repositories.new(params[:repository]) @repository = Repository.new(params[:repository])
@repository.owner = get_acter
if @repository.save if @repository.save
flash[:notice] = t('flash.repository.saved') flash[:notice] = t('flash.repository.saved')
redirect_to [@platform, @repository] redirect_to @repositories_path
else else
flash[:error] = t('flash.repository.save_error') flash[:error] = t('flash.repository.save_error')
render :action => :new render :action => :new
end end
end end
def add_project
if params[:project_id]
@project = Project.find(params[:project_id])
params[:project_id] = nil
unless @repository.projects.include? @project
@repository.projects << @project
# if @repository.save
flash[:notice] = t('flash.repository.project_added')
redirect_to platform_repository_path(@repository.platform, @repository)
# else
# flash[:error] = t('flash.repository.project_not_added')
# redirect_to url_for(:action => :add_project)
# end
else
flash[:error] = t('flash.repository.project_not_added')
redirect_to url_for(:action => :add_project)
end
else
@projects = (Project.all - @repository.projects).paginate(:page => params[:project_page])
render 'projects_list'
end
end
def remove_project
if params[:project_id]
@project = Project.find(params[:project_id])
params[:project_id] = nil
if @repository.projects.include? @project
@repository.projects.delete @project
# if @repository.save
flash[:notice] = t('flash.repository.project_removed')
redirect_to platform_repository_path(@repository.platform, @repository)
# else
# flash[:error] = t('flash.repository.project_not_removed')
# redirect_to url_for(:action => :remove_project)
# end
else
redirect_to url_for(:action => :remove_project)
end
else
redirect_to platform_repository_path(@repository.platform, @repository)
end
end
protected protected
def find_platform def get_paths
if params[:user_id]
@user = User.find params[:user_id]
@repositories_path = user_repositories_path @user
@new_repository_path = new_user_repository_path @user
elsif params[:group_id]
@group = Group.find params[:group_id]
@repositories_path = group_repositories_path @group
@new_repository_path = new_group_repository_path @group
elsif params[:platform_id]
@platform = Platform.find params[:platform_id] @platform = Platform.find params[:platform_id]
@repositories_path = platform_repositories_path @platform
@new_repository_path = new_platform_repository_path @platform
else
@repositories_path = repositories_path
@new_repository_path = new_repository_path
end
end
def find_platform
@platform = @repository.platform
end
def find_platforms
@platforms = Platform.all
end end
def find_repository def find_repository
@repository = @platform.repositories.find(params[:id]) @repository = Repository.find(params[:id])
end end
end end

View File

@ -0,0 +1,60 @@
class RolesController < ApplicationController
before_filter :find_role, :only => [:show, :edit, :update, :destroy]
def index
@roles = Role.all
end
def show
@permissions = Permission.where(:role_id => @role.id)
end
def new
@role = Role.new
end
def edit
end
def create
@role = Role.new(params[:role])
if @role.save
for right in params[:right][:id]
Permission.create(:role_id => @role.id, :right_id => right)
end
flash[:notice] = t('flash.role.saved')
redirect_to roles_path
else
flash[:error] = t('flash.role.save_error')
render :action => :new
end
end
def update
if @role.update_attributes(params[:role])
if params[:right][:id]
Permission.destroy_all(:role_id => @role.id)
for right in params[:right][:id]
Permission.create(:role_id => @role.id, :right_id => right)
end
end
flash[:notice] = t('flash.role.saved')
redirect_to roles_path
else
flash[:error] = t('flash.role.save_error')
render :action => :edit
end
end
def destroy
@role.destroy
Permission.destroy_all(:role_id => params[:id])
flash[:notice] = t("flash.role.destroyed")
redirect_to roles_path
end
protected
def find_role
@role = Role.find(params[:id])
end
end

View File

@ -6,6 +6,11 @@ class UsersController < ApplicationController
end end
def show def show
puts params.inspect
@groups = @user.groups.uniq
@platforms = @user.platforms.paginate(:page => params[:platform_page], :per_page => 10)
@repositories = @user.repositories.paginate(:page => params[:repository_page], :per_page => 10)
@projects = @user.projects.paginate(:page => params[:project_page], :per_page => 10)
end end
def new def new

61
app/models/group.rb Normal file
View File

@ -0,0 +1,61 @@
class Group < ActiveRecord::Base
validates :name, :uname, :owner_id, :presence => true
validates :name, :uname, :uniqueness => true
validates :uname, :format => { :with => /^[a-zA-Z0-9_]+$/ }, :allow_nil => false, :allow_blank => false
belongs_to :owner, :class_name => 'User'
has_many :own_projects, :as => :owner, :class_name => 'Project'
has_many :objects, :as => :target, :class_name => 'Relation'
has_many :targets, :as => :object, :class_name => 'Relation'
has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
before_save :create_dir
after_destroy :remove_dir
def roles_of(user)
objects.where(:object_id => user.id, :object_type => user.class).map {|rel| rel.role}.reject {|r| r.nil?}
end
def add_role(user, role)
roles = objects.where(:object_id => user.id, :object_type => user.class).map {|rel| rel.role}.reject {|r| r.nil?}
unless roles.include? role
rel = Relation.create(:object_type => user.class.to_s, :object_id => user.id,
:target_type => self.class.to_s, :target_id => id)
rel.role = role
rel.save
end
end
def path
build_path(uname)
end
protected
def build_path(dir)
File.join(APP_CONFIG['root_path'], 'groups', dir)
end
def create_dir
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} already exists" if exists
if new_record?
FileUtils.mkdir_p(path)
elsif uname_changed?
FileUtils.mv(build_path(uname_was), build_path(uname))
end
end
def remove_dir
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} didn't exists" unless exists
FileUtils.rm_rf(path)
end
end

33
app/models/permission.rb Normal file
View File

@ -0,0 +1,33 @@
class Permission < ActiveRecord::Base
belongs_to :role
def name
Permission.right(self.right_id)
end
def self.get_rights_list
res=[]
for k in 1..8
res << [Permission.right(k), k]
end
return res
end
def self.right(n)
case n
when 1
"Проекты - Чтение"
when 2
"Проекты - Чтение/Запись"
when 3
"Проекты - Сборка"
when 4
"Репозиторий - Просмотр"
when 5
"Репозиторий - Изменение состава пакетов"
when 6
"Платформа - Создание/Удаление репозиториев"
when 7
"Платформа - Изменение параметров платформы"
when 8
"Платформа - Сборка"
end
end
end

View File

@ -1,15 +1,25 @@
#require 'lib/build_server.rb' #require 'lib/build_server.rb'
class Platform < ActiveRecord::Base class Platform < ActiveRecord::Base
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
belongs_to :owner, :polymorphic => true
has_many :repositories, :dependent => :destroy has_many :repositories, :dependent => :destroy
has_many :products, :dependent => :destroy has_many :products, :dependent => :destroy
validates :name, :presence => true, :uniqueness => true has_many :objects, :as => :target, :class_name => 'Relation'
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false has_many :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
before_create :xml_rpc_create validates :name, :presence => true, :uniqueness => true
before_destroy :xml_rpc_destroy validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }, :allow_nil => false, :allow_blank => false
before_update :check_freezing
#after_create :make_owner_rel
before_save :create_directory
before_save :make_owner_rel
after_destroy :remove_directory
# before_create :xml_rpc_create
# before_destroy :xml_rpc_destroy
# before_update :check_freezing
def path def path
@ -30,10 +40,24 @@ class Platform < ActiveRecord::Base
released? ? "#{self[:name]} #{I18n.t("layout.platforms.released_suffix")}" : self[:name] released? ? "#{self[:name]} #{I18n.t("layout.platforms.released_suffix")}" : self[:name]
end end
def roles_of(user)
objects.where(:object_id => user.id, :object_type => user.class).map {|rel| rel.role}.reject {|r| r.nil?}
end
def add_role(user, role)
roles = objects.where(:object_id => user.id, :object_type => user.class).map {|rel| rel.role}.reject {|r| r.nil?}
unless roles.include? role
rel = Relation.create(:object_type => user.class.to_s, :object_id => user.id,
:target_type => self.class.to_s, :target_id => id)
rel.role = role
rel.save
end
end
protected protected
def build_path(dir) def build_path(dir)
File.join(APP_CONFIG['root_path'], dir) File.join(APP_CONFIG['root_path'], 'platforms', dir)
end end
def git_path(dir) def git_path(dir)
@ -50,31 +74,47 @@ class Platform < ActiveRecord::Base
end end
end end
def xml_rpc_create def remove_directory
result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] exists = File.exists?(path) && File.directory?(path)
if result == BuildServer::SUCCESS raise "Directory #{path} didn't exists" unless exists
return true FileUtils.rm_rf(path)
else
raise "Failed to create platform #{name}. Path: #{build_path(unixname)}"
end end
def make_owner_rel
unless members.include? owner or groups.include? owner
members << owner if owner.instance_of? User
groups << owner if owner.instance_of? Group
end
end
def xml_rpc_create
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 end
def xml_rpc_destroy def xml_rpc_destroy
result = BuildServer.delete_platform unixname
if result == BuildServer::SUCCESS
return true return true
else # result = BuildServer.delete_platform unixname
raise "Failed to delete platform #{unixname}." # if result == BuildServer::SUCCESS
end # return true
# else
# 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']
if result == BuildServer::SUCCESS
return true return true
else # result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path']
raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}" # if result == BuildServer::SUCCESS
end # return true
# else
# 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

@ -1,18 +1,33 @@
class Project < ActiveRecord::Base class Project < ActiveRecord::Base
belongs_to :repository belongs_to :owner, :polymorphic => true
has_many :build_lists, :dependent => :destroy has_many :build_lists, :dependent => :destroy
validates :name, :uniqueness => {:scope => :repository_id}, :presence => true, :allow_nil => false, :allow_blank => false has_many :project_to_repositories
validates :unixname, :uniqueness => {:scope => :repository_id}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false has_many :repositories, :through => :project_to_repositories
has_many :relations, :as => :target
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, :allow_nil => false, :allow_blank => false
validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }, :allow_nil => false, :allow_blank => false
# validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
include Project::HasRepository include Project::HasRepository
scope :recent, order("name ASC") scope :recent, order("name ASC")
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_save :create_directory#, :create_git_repo
before_create :xml_rpc_create before_save :make_owner_rel
before_destroy :xml_rpc_destroy after_destroy :remove_directory
# before_create :xml_rpc_create
# before_destroy :xml_rpc_destroy
def members
collaborators + groups
end
# 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
@ -41,8 +56,15 @@ class Project < ActiveRecord::Base
protected protected
def make_owner_rel
unless groups.include? owner or collaborators.include? owner
collaborators << owner if owner.instance_of? User
groups << owner if owner.instance_of? Group
end
end
def build_path(dir) def build_path(dir)
File.join(repository.path, dir) File.join(APP_CONFIG['root_path'], 'projects', dir)
end end
def create_directory def create_directory
@ -55,6 +77,12 @@ class Project < ActiveRecord::Base
end end
end end
def remove_directory
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} didn't exists" unless exists
FileUtils.rm_rf(path)
end
def xml_rpc_create def xml_rpc_create
result = BuildServer.create_project unixname, repository.platform.unixname, repository.unixname result = BuildServer.create_project unixname, repository.platform.unixname, repository.unixname
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS

View File

@ -0,0 +1,32 @@
class ProjectToRepository < ActiveRecord::Base
belongs_to :project
belongs_to :repository
before_save :create_link
after_destroy :remove_link
def path
build_path(project.unixname)
end
protected
def build_path(dir)
File.join(repository.path, dir)
end
def create_link
exists = File.exists?(path) && File.directory?(path)
raise "Symlink #{path} already exists" if exists
if new_record?
FileUtils.ln_s(project.path, path)
end
end
def remove_link
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} didn't exists" unless exists
FileUtils.rm_rf(path)
end
end

5
app/models/relation.rb Normal file
View File

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

View File

@ -1,14 +1,26 @@
class Repository < ActiveRecord::Base class Repository < ActiveRecord::Base
belongs_to :platform belongs_to :platform
has_many :projects, :dependent => :destroy belongs_to :owner, :polymorphic => true
validates :name, :uniqueness => {:scope => :platform_id}, :presence => true has_many :projects, :through => :project_to_repositories #, :dependent => :destroy
validates :unixname, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ } has_many :project_to_repositories, :validate => true
has_many :objects, :as => :target, :class_name => 'Relation'
has_many :members, :through => :objects, :source => :object, :source_type => 'User'
has_many :groups, :through => :objects, :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 :platform_id, :presence => true
scope :recent, order("name ASC") scope :recent, order("name ASC")
before_create :xml_rpc_create before_save :create_directory
before_destroy :xml_rpc_destroy before_save :make_owner_rel
after_destroy :remove_directory
# before_create :xml_rpc_create
# before_destroy :xml_rpc_destroy
def path def path
build_path(unixname) build_path(unixname)
@ -24,6 +36,13 @@ class Repository < ActiveRecord::Base
protected protected
def make_owner_rel
unless members.include? owner
members << owner if owner.instance_of? User
groups << owner if owner.instance_of? Group
end
end
def build_path(dir) def build_path(dir)
File.join(platform.path, dir) File.join(platform.path, dir)
end end
@ -39,6 +58,12 @@ class Repository < ActiveRecord::Base
end end
end end
def remove_directory
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} didn't exists" unless exists
FileUtils.rm_rf(path)
end
def xml_rpc_create def xml_rpc_create
result = BuildServer.create_repo unixname, platform.unixname result = BuildServer.create_repo unixname, platform.unixname
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS

4
app/models/role.rb Normal file
View File

@ -0,0 +1,4 @@
class Role < ActiveRecord::Base
has_many :permissions
has_many :relations
end

View File

@ -3,11 +3,36 @@ class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :omniauthable, # :token_authenticatable, :encryptable, :timeoutable devise :database_authenticatable, :registerable, :omniauthable, # :token_authenticatable, :encryptable, :timeoutable
:recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable :recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable
has_many :targets, :as => :object, :class_name => 'Relation'
has_many :own_projects, :as => :owner, :class_name => 'Project'
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group'
has_many :groups, :through => :targets, :source => :target, :source_type => 'Group', :autosave => true
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true
has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true
devise :database_authenticatable,
:recoverable, :rememberable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :uname
validates :uname, :presence => true, :uniqueness => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }, :allow_nil => false, :allow_blank => false
validates :nickname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => /^[a-zA-Z0-9_]+$/i validates :nickname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => /^[a-zA-Z0-9_]+$/i
attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :nickname, :name, :ssh_key attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :nickname, :name, :ssh_key
attr_readonly :nickname attr_readonly :nickname
before_save :create_dir
after_destroy :remove_dir
def path
build_path(uname)
end
protected
attr_accessor :login attr_accessor :login
@ -46,4 +71,24 @@ class User < ActiveRecord::Base
clean_up_passwords clean_up_passwords
result result
end end
def build_path(dir)
File.join(APP_CONFIG['root_path'], 'users', dir)
end
def create_dir
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} already exists" if exists
if new_record?
FileUtils.mkdir_p(path)
elsif uname_changed?
FileUtils.mv(build_path(uname_was), build_path(uname))
end
end
def remove_dir
exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} didn't exists" unless exists
FileUtils.rm_rf(path)
end
end end

View File

@ -0,0 +1,13 @@
.group
= f.label :name, t("activerecord.attributes.group.name"), :class => :label
= f.text_field :name, :class => 'text_field'
.group
= f.label :uname, t("activerecord.attributes.group.uname"), :class => :label
= f.text_field :uname, :class => 'text_field'
.group.navform.wat-cf
%button.button{:type => "submit"}
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
= t("layout.save")
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), users_path, :class => "text_button_padding link_button"

View File

@ -0,0 +1,24 @@
.content
%h2.title
= t("layout.groups.list_header")
.inner
%table.table
%tr
%th.first ID
%th= t("activerecord.attributes.group.name")
%th= t("activerecord.attributes.group.owner")
%th.last &nbsp;
- @groups.each do |group|
%tr{:class => cycle("odd", "even")}
%td
= group.id
%td
= link_to group.name, group_path(group)
%td
= link_to group.owner.name, user_path(group.owner)
%td.last
#{link_to t("layout.show"), group_path(group)} | #{link_to t("layout.edit"), edit_group_path(group)} | #{link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete")}
.actions-bar.wat-cf
.actions
- if !!paginate
= paginate

View File

@ -0,0 +1,5 @@
.block.notice
%h3= t("layout.groups.members")
.content
- @group.members.uniq.each do |member|
%p= link_to member.name + " (#{@group.roles_of(member).map{|r| r.name}.join(', ')})", user_path(member)

View File

@ -0,0 +1,12 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.groups.list"), groups_path
%li= link_to t("layout.groups.new"), new_group_path
%li.active= link_to t("layout.groups.edit"), edit_group_path
.content
%h2.title= t("layout.groups.edit_header")
.inner
= form_for @group, :url => group_path(@group), :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,7 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.groups.list"), users_path
%li= link_to t("layout.groups.new"), new_group_path
=render :partial => 'list', :object => @groups, :locals => {:paginate => will_paginate(@groups)}
-# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,11 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.groups.list"), groups_path
%li.active= link_to t("layout.groups.new"), new_group_path
.content
%h2.title= t("layout.groups.new_header")
.inner
= form_for :group, :url => groups_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}
-# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,78 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.groups.list"), groups_path
%li= link_to t("layout.groups.new"), new_group_path
%li.active= link_to t("layout.groups.show"), group_path
.content
.inner
%p
%b
Id
\:
= @group.id
%p
%b
= t("activerecord.attributes.group.name")
\:
= @group.name
%p
%b
= t("activerecord.attributes.group.owner")
\:
= link_to @group.owner.name, user_path(@group.owner)
%p
%b
= t("activerecord.attributes.group.created_at")
\:
= @group.created_at
.wat-cf
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_group_path(@group), :class => "button"
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), group_path(@group), :method => "delete", :class => "button", :confirm => t("layout.groups.confirm_delete")
.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_group_platform_path(@group)
.content
%h2.title
= t("layout.platforms.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'platforms/list', :object => @platforms
.actions-bar.wat-cf
.actions
= will_paginate @platforms, :param_name => :platform_page
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.repositories.list"), repositories_path
%li= link_to t("layout.repositories.new"), new_group_repository_path(@group)
.content
%h2.title
= t("layout.repositories.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'repositories/list', :object => @repositories
.actions-bar.wat-cf
.actions
= will_paginate @repositories, :param_name => :repository_page
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_group_project_path(@group)
.content
%h2.title
= t("layout.projects.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'projects/list', :object => @projects
.actions-bar.wat-cf
.actions
= will_paginate @projects, :param_name => :project_page
- content_for :sidebar, render(:partial => 'sidebar')

View File

@ -14,10 +14,16 @@
%ul.wat-cf %ul.wat-cf
%li= link_to current_user.nickname, edit_user_registration_path %li= link_to current_user.nickname, edit_user_registration_path
%li= link_to t('layout.logout'), destroy_user_session_path, :method => :delete, :class => "logout" %li= link_to t('layout.logout'), destroy_user_session_path, :method => :delete, :class => "logout"
/ %li
/ = t("layout.logged_in_as") + ' ' + current_user.name
/ &nbsp; | &nbsp;
/ = link_to t('layout.logout'), destroy_user_session_path, :class => "logout"
#main-navigation #main-navigation
%ul.wat-cf %ul.wat-cf
%li{:class => controller.controller_path == 'users' ? 'active' : '' } %li{:class => controller.controller_path == 'users' ? 'active' : '' }
%a{:href => users_path}= t("layout.menu.users") %a{:href => users_path}= t("layout.menu.users")
%li{:class => controller.controller_path == 'groups' ? 'active' : '' }
%a{:href => groups_path}= t("layout.menu.groups")
%li{:class => controller.controller_path == 'platforms' ? 'active' : '' } %li{:class => controller.controller_path == 'platforms' ? 'active' : '' }
%a{:href => platforms_path}= t("layout.menu.platforms") %a{:href => platforms_path}= t("layout.menu.platforms")
#wrapper.wat-cf #wrapper.wat-cf

View File

@ -19,4 +19,4 @@
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
= t("layout.save") = t("layout.save")
%span.text_button_padding= t("layout.or") %span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), platforms_path, :class => "text_button_padding link_button" = link_to t("layout.cancel"), @platforms_path, :class => "text_button_padding link_button"

View File

@ -0,0 +1,10 @@
%table.table
%tr
%th.first= t("activerecord.attributes.platform.name")
%th.last &nbsp;
- @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")}

View File

@ -0,0 +1,5 @@
.block.notice
%h3= t("layout.groups.members")
.content
- @platform.members.uniq.each do |member|
%p= link_to member.name + " (#{@platform.roles_of(member).map{|r| r.name}.join(', ')})", user_path(member)

View File

@ -7,15 +7,29 @@
%h2.title %h2.title
= t("layout.platforms.list_header") = t("layout.platforms.list_header")
.inner .inner
%table.table = render :partial => 'shared/search_form'
%tr = render :partial => 'platforms/list', :object => @platforms
%th.first= t("activerecord.attributes.platform.name")
%th.last &nbsp;
- @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-bar.wat-cf
.actions .actions
= will_paginate @platforms, :param_name => :platform_page
/.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 &nbsp;
/ - @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

View File

@ -1,11 +1,11 @@
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to "#{t("layout.platforms.list")}", platforms_path %li.first= link_to "#{t("layout.platforms.list")}", @platforms_path
%li.active= link_to "#{t("layout.platforms.new")}", new_platform_path %li.active= link_to "#{t("layout.platforms.new")}", @new_platform_path
.content .content
%h2.title %h2.title
= t("layout.platforms.new_header") = t("layout.platforms.new_header")
.inner .inner
= form_for :platform, :url => platforms_path, :html => { :class => :form } do |f| = form_for :platform, :url => @platforms_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f} = render :partial => "form", :locals => {:f => f}

View File

@ -29,6 +29,31 @@
\: \:
= @platform.path = @platform.path
%p
%b
= t('layout.platforms.owner')
\:
= link_to @platform.owner.name, url_for(@platform.owner)
%p
%b
= t('layout.platforms.visibility')
\:
= @platform.visibility
%p
%b
= t('layout.platforms.platform_type')
\:
= @platform.platform_type
%p
%b
= t('layout.platforms.distrib_type')
\:
= @platform.distrib_type
.wat-cf .wat-cf
-#= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_platform_path(@platform), :class => "button" -#= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_platform_path(@platform), :class => "button"
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_path(@platform), :method => "delete", :class => "button", :confirm => t("layout.platforms.confirm_delete") = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_path(@platform), :method => "delete", :class => "button", :confirm => t("layout.platforms.confirm_delete")
@ -83,5 +108,4 @@
#{link_to t("layout.show"), platform_product_path(@platform, product)} | #{link_to t("layout.delete"), platform_product_path(@platform, product), :method => :delete, :confirm => t("layout.products.confirm_delete")} #{(product.can_clone? ? "| #{link_to t("layout.products.clone"), clone_platform_product_path(@platform, product)}" : "").html_safe } #{link_to t("layout.show"), platform_product_path(@platform, product)} | #{link_to t("layout.delete"), platform_product_path(@platform, product), :method => :delete, :confirm => t("layout.products.confirm_delete")} #{(product.can_clone? ? "| #{link_to t("layout.products.clone"), clone_platform_product_path(@platform, product)}" : "").html_safe }
.actions-bar.wat-cf .actions-bar.wat-cf
.actions .actions
-#- content_for :sidebar do - content_for :sidebar, render(:partial => 'sidebar')

View File

@ -10,4 +10,4 @@
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
= t("layout.save") = t("layout.save")
%span.text_button_padding= t("layout.or") %span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), platform_repository_path(@platform, @repository), :class => "text_button_padding link_button" = link_to t("layout.cancel"), @projects_path, :class => "text_button_padding link_button"

View File

@ -0,0 +1,10 @@
%table.table
%tr
%th.first= t("activerecord.attributes.project.name")
%th.last &nbsp;
- @projects.each do |project|
%tr{:class => cycle("odd", "even")}
%td
= link_to project.name, project_path(project)
%td.last
#{link_to t("layout.show"), project_path(project)} | #{link_to t("layout.delete"), project_path(project), :method => :delete, :confirm => t("layout.projects.confirm_delete")}

View File

@ -1,14 +1,14 @@
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" %li.first= link_to t("layout.projects.list"), @projects_path#url_for(get_acter) + "#projects"
%li.active= link_to t("layout.projects.new"), new_platform_repository_project_path(@platform, @repository) %li.active= link_to t("layout.projects.new"), @new_project_path#new_platform_repository_project_path(@platform, @repository)
-#%li= link_to "git-repo", platform_repository_project_repo_path(@platform, @repository, @project) -#%li= link_to "git-repo", platform_repository_project_repo_path(@platform, @repository, @project)
-#%li= link_to t("layout.projects.build"), build_platform_repository_project_path(@platform, @repository, @project) -#%li= link_to t("layout.projects.build"), build_platform_repository_project_path(@platform, @repository, @project)
.content .content
%h2.title= t("layout.projects.new_header") %h2.title= t("layout.projects.new_header")
.inner .inner
= form_for [@platform, @repository, @project], :html => { :class => :form } do |f| = form_for :project, :url => @projects_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f} = render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render(:partial => 'sidebar') -# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -1,11 +1,11 @@
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" %li.first= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_platform_repository_project_path(@platform, @repository) %li= link_to t("layout.projects.new"), new_project_path
%li.active= link_to t("layout.projects.show"), platform_repository_project_path(@platform, @repository, @project) %li.active= link_to t("layout.projects.show"), project_path(@project)
%li= link_to "git-repo", platform_repository_project_repo_path(@platform, @repository, @project) %li= link_to "git-repo", '#'#platform_repository_project_repo_path(@platform, @repository, @project)
%li= link_to t("layout.projects.build"), build_platform_repository_project_path(@platform, @repository, @project) %li= link_to t("layout.projects.build"), '#'#build_platform_repository_project_path(@platform, @repository, @project)
.content .content
.inner .inner
@ -21,21 +21,31 @@
= @project.unixname = @project.unixname
%p %p
%b %b
= t("activerecord.attributes.project.repository") = t("activerecord.attributes.project.owner")
\: \:
= @project.repository.name = link_to @project.owner.name, url_for(@project.owner)
%p
%b
= t("activerecord.attributes.project.visibility")
\:
= @project.visibility
/ %p
/ %b
/ = t("activerecord.attributes.project.repository")
/ \:
/ = @project.repository.name
.wat-cf .wat-cf
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_repository_project_path(@platform, @repository, @project), :method => "delete", :class => "button", :confirm => t("layout.projects.confirm_delete") = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_path(@project), :method => "delete", :class => "button", :confirm => t("layout.projects.confirm_delete")
%a{ :name => "build_lists"} %a{ :name => "build_lists"}
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first.active= link_to t("layout.build_lists.current"), platform_repository_project_path(@platform, @repository, @project) + "#build_lists" %li.first.active= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists"
%li= link_to t("layout.build_lists.all"), platform_repository_project_build_lists_path(@platform, @repository, @project) %li= link_to t("layout.build_lists.all"), project_build_lists_path(@project)
.content .content
= render :partial => "build_lists/build_lists", :object => @current_build_lists = render :partial => "build_lists/build_lists", :object => @current_build_lists
- content_for :sidebar, render(:partial => 'sidebar') -# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -5,10 +5,14 @@
= f.label :unixname, t("activerecord.attributes.repository.unixname"), :class => :label = f.label :unixname, t("activerecord.attributes.repository.unixname"), :class => :label
= f.text_field :unixname, :class => 'text_field' = f.text_field :unixname, :class => 'text_field'
.group
= f.label :parent, :class => :label
= f.select :platform_id, @platforms.map { |p| [p.name, p.id] }, :include_blank => true
.group.navform.wat-cf .group.navform.wat-cf
%button.button{:type => "submit"} %button.button{:type => "submit"}
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
= t("layout.save") = t("layout.save")
%span.text_button_padding= t("layout.or") %span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), platform_path(@platform) + "#repositories", :class => "text_button_padding link_button" = link_to t("layout.cancel"), @repositories_path + "#repositories", :class => "text_button_padding link_button"

View File

@ -0,0 +1,10 @@
%table.table
%tr
%th.first= t("activerecord.attributes.repository.name")
%th.last &nbsp;
- @repositories.each do |repository|
%tr{:class => cycle("odd", "even")}
%td
= link_to repository.name, repository_path(repository)
%td.last
#{link_to t("layout.show"), repository_path(repository)} | #{link_to t("layout.delete"), repository_path(repository), :method => :delete, :confirm => t("layout.repositories.confirm_delete")}

View File

@ -0,0 +1,11 @@
%table.table
%tr
%th.first= t("activerecord.attributes.project.name")
%th.last &nbsp;
- @projects.each do |project|
%tr{:class => cycle("odd", "even")}
%td
= link_to project.owner.name + '/' + project.name, project_path(project)
%td.last
#{link_to t("layout.show"), project_path(project)} | #{link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id)}

View File

@ -0,0 +1,10 @@
%table.table
%tr
%th.first= t("activerecord.attributes.project.name")
%th.last &nbsp;
- @projects.each do |project|
%tr{:class => cycle("odd", "even")}
%td
= link_to project.name, project_path(project)
%td.last
#{link_to t("layout.show"), project_path(project)} | #{link_to t("layout.delete"), url_for (:action => :remove_project, :project_id => project.id), :confirm => t("layout.projects.confirm_delete")}

View File

@ -0,0 +1,14 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.repositories.list"), repositories_path
%li= link_to t("layout.repositories.new"), new_repository_path
.content
%h2.title
= t("layout.repositories.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'list', :object => @repositories
.actions-bar.wat-cf
.actions
= will_paginate @repositories, :param_name => :repository_page

View File

@ -1,11 +1,11 @@
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to t("layout.repositories.list"), platform_path(@platform) + "#platforms" %li.first= link_to t("layout.repositories.list"), @repositories_path + "#platforms"
%li.active= link_to t("layout.repositories.new"), new_platform_repository_path(@platform) %li.active= link_to t("layout.repositories.new"), @new_repository_path
.content .content
%h2.title= t("layout.repositories.new_header") %h2.title= t("layout.repositories.new_header")
.inner .inner
= form_for [@platform, @repository], :html => { :class => :form } do |f| = form_for :repository, :url => @repositories_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f} = render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render(:partial => 'sidebar') -# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,60 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.repositories.list"), @repositories_path + "#repositories"
%li= link_to t("layout.repositories.new"), @new_repository_path
%li.active= link_to t("layout.repositories.show"), repository_path(@repository)
.content
.inner
%p
%b
= t("activerecord.attributes.repository.name")
\:
= @repository.name
%p
%b
= t("activerecord.attributes.repository.unixname")
\:
= @repository.unixname
%p
%b
= t("activerecord.attributes.repository.platform")
\:
= link_to @repository.platform.name, url_for(@repository.platform)
%p
%b
= t("activerecord.attributes.repository.owner")
\:
= link_to @repository.owner.name, url_for(@repository.owner)
%p
%b
= t("activerecord.attributes.repository.visibility")
\:
= @repository.visibility
%p
%b
= t("activerecord.attributes.repository.platform")
\:
= link_to @repository.platform.name, platform_path(@platform)
.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")
%a{ :name => "projects" }
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.projects.list"), repository_path(@repository) + "#projects"
%li.active= link_to t("layout.projects.add"), url_for(:controller => :repositories, :action => :add_project)
.content
%h2.title
= t("layout.projects.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'proj_list', :object => @projects
.actions-bar.wat-cf
.actions
= will_paginate @projects, :param_name => :project_page
-# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -1,9 +1,9 @@
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to t("layout.repositories.list"), platform_path(@platform) + "#repositories" %li.first= link_to t("layout.repositories.list"), @repositories_path + "#repositories"
%li= link_to t("layout.repositories.new"), new_platform_repository_path(@platform) %li= link_to t("layout.repositories.new"), @new_repository_path
%li.active= link_to t("layout.repositories.show"), platform_repository_path(@platform, @repository) %li.active= link_to t("layout.repositories.show"), repository_path(@repository)
.content .content
.inner .inner
%p %p
@ -16,42 +16,44 @@
= t("activerecord.attributes.repository.unixname") = t("activerecord.attributes.repository.unixname")
\: \:
= @repository.unixname = @repository.unixname
%p
%b
= t("activerecord.attributes.repository.platform")
\:
= link_to @repository.platform.name, url_for(@repository.platform)
%p
%b
= t("activerecord.attributes.repository.owner")
\:
= link_to @repository.owner.name, url_for(@repository.owner)
%p
%b
= t("activerecord.attributes.repository.visibility")
\:
= @repository.visibility
%p %p
%b %b
= t("activerecord.attributes.repository.platform") = t("activerecord.attributes.repository.platform")
\: \:
= link_to @repository.platform.name, platform_path(@platform) = link_to @repository.platform.name, platform_path(@platform)
.wat-cf .wat-cf
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_repository_path(@platform, @repository), :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")
%a{ :name => "projects" } %a{ :name => "projects" }
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first.active= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" %li.first.active= link_to t("layout.projects.list"), repository_path(@repository) + "#projects"
%li= link_to t("layout.projects.new"), new_platform_repository_project_path(@platform, @repository) %li= link_to t("layout.projects.add"), url_for(:controller => :repositories, :action => :add_project)
.content .content
%h2.title %h2.title
= t("layout.projects.list_header") = t("layout.projects.list_header")
.inner .inner
= form_tag platform_repository_path(@platform, @repository), :method => :get do = render :partial => 'shared/search_form'
.group = render :partial => 'proj_list1', :object => @projects
= label_tag :query, t("layout.search_by_name"), :class => :label
= text_field_tag :query
%button.search{:type => "submit"}
= t("layout.search")
%table.table
%tr
%th.first= t("activerecord.attributes.project.name")
%th.last &nbsp;
- @projects.each do |project|
%tr{:class => cycle("odd", "even")}
%td
= link_to project.name, platform_repository_project_path(@platform, @repository, project)
%td.last
#{link_to t("layout.show"), platform_repository_project_path(@platform, @repository, project)} | #{link_to t("layout.delete"), platform_repository_project_path(@platform, @repository, project), :method => :delete, :confirm => t("layout.projects.confirm_delete")}
.actions-bar.wat-cf .actions-bar.wat-cf
.actions .actions
= will_paginate @projects = will_paginate @projects, :param_name => :project_page
- content_for :sidebar, render(:partial => 'sidebar')
-# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,15 @@
.group
= f.label :name, t("activerecord.attributes.role.name"), :class => :label
= f.text_field :name, :class => 'text_field'
.group
%label.label Разрешения
- rights = Permission.get_rights_list
- rights_selected = Permission.where(:role_id => @role.id).map { |perm| perm.right_id }
= select_tag("right[id]", options_for_select(rights, rights_selected), :size => 10, :multiple => true)
.group.navform.wat-cf
%button.button{:type => "submit"}
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
= t("layout.save")
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), roles_path, :class => "text_button_padding link_button"

View File

View File

@ -0,0 +1,12 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.roles.list"), roles_path
%li= link_to t("layout.roles.new"), new_role_path
%li.active= link_to t("layout.roles.edit"), edit_role_path
.content
%h2.title= t("layout.roles.edit_header")
.inner
= form_for @role, :url => role_path(@role), :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,30 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.roles.list"), roles_path
%li= link_to t("layout.roles.new"), new_role_path
.content
%h2.title
= t("layout.roles.list_header")
.inner
-unless @roles.empty?
%table.table
%tr
%th.first ID
%th= t("activerecord.attributes.role.name")
%th.last &nbsp;
- @roles.each do |role|
%tr{:class => cycle("odd", "even")}
%td
= role.id
%td
= link_to role.name, role_path(role)
%td.last
#{link_to t("layout.show"), role_path(role)} | #{link_to t("layout.edit"), edit_role_path(role)} | #{link_to t("layout.delete"), role_path(role), :method => :delete, :confirm => t("layout.roles.confirm_delete")}
.actions-bar.wat-cf
.actions
-else
.inner
%label.label Роли отсутствуют,
= link_to "создать новую роль", new_role_path
- content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,11 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.roles.list"), roles_path
%li.active= link_to t("layout.roles.new"), new_role_path
.content
%h2.title= t("layout.roles.new_header")
.inner
= form_for :role, :url => roles_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,38 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.roles.list"), roles_path
%li= link_to t("layout.roles.new"), new_role_path
%li.active= link_to t("layout.roles.show"), role_path
.content
.inner
%p
%b
Id
\:
= @role.id
%p
%b
= t("activerecord.attributes.role.name")
\:
= @role.name
%p
%b
= t("activerecord.models.permission")
\:
-unless @permissions.empty?
%table.table
%tr
%th.first ID
%th= t("activerecord.attributes.right.name")
- @permissions.each do |permission|
%tr{:class => cycle("odd", "even")}
%td
= permission.right_id
%td
= permission.name
.wat-cf
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_role_path(@role), :class => "button"
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), role_path(@role), :method => "delete", :class => "button", :confirm => t("layout.users.confirm_delete")
- content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,6 @@
= form_tag '#', :method => :get do#platform_repository_path(@platform, @repository), :method => :get do
.group
= label_tag :query, t("layout.search_by_name"), :class => :label
= text_field_tag :query
%button.search{:type => "submit"}
= t("layout.search")

View File

@ -0,0 +1,25 @@
.block
.content
%h2.title
= t("layout.groups.list_header")
.inner
%table.table
%tr
%th.first ID
%th= t("activerecord.attributes.group.name")
%th= t("activerecord.attributes.user.roles")
%th.last &nbsp;
- @groups.each do |group|
%tr{:class => cycle("odd", "even")}
%td
= group.id
%td
= link_to group.name, group_path(group)
%td
= group.roles_of(@user).map {|r| r.name}.join(', ')
%td.last
#{link_to t("layout.show"), group_path(group)} | #{link_to t("layout.edit"), edit_group_path(group)} | #{link_to t("layout.delete"), group_path(group), :method => :delete, :confirm => t("layout.groups.confirm_delete")}
.actions-bar.wat-cf
.actions
- if paginate
= paginate

View File

@ -0,0 +1,5 @@
.block.notice
%h3= t("layout.users.groups")
.content
- @groups.each do |group|
%p= link_to group.name + " (#{group.roles_of(@user).map{|r| r.name}.join(', ')})", group_path(group)

View File

@ -25,4 +25,4 @@
#{link_to t("layout.show"), user_path(user)} | #{link_to t("layout.edit"), edit_user_path(user)} | #{link_to t("layout.delete"), user_path(user), :method => :delete, :confirm => t("layout.users.confirm_delete")} #{link_to t("layout.show"), user_path(user)} | #{link_to t("layout.edit"), edit_user_path(user)} | #{link_to t("layout.delete"), user_path(user), :method => :delete, :confirm => t("layout.users.confirm_delete")}
.actions-bar.wat-cf .actions-bar.wat-cf
.actions .actions
- content_for :sidebar, render(:partial => 'sidebar') -# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -8,4 +8,4 @@
.inner .inner
= form_for :user, :url => users_path, :html => { :class => :form } do |f| = form_for :user, :url => users_path, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f} = render :partial => "form", :locals => {:f => f}
- content_for :sidebar, render(:partial => 'sidebar') -# content_for :sidebar, render(:partial => 'sidebar')

View File

@ -30,4 +30,49 @@
= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_user_path(@user), :class => "button" = link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_user_path(@user), :class => "button"
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), user_path(@user), :method => "delete", :class => "button", :confirm => t("layout.users.confirm_delete") = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), user_path(@user), :method => "delete", :class => "button", :confirm => t("layout.users.confirm_delete")
.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_user_platform_path(@user)
.content
%h2.title
= t("layout.platforms.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'platforms/list', :object => @platforms
.actions-bar.wat-cf
.actions
= will_paginate @platforms, :param_name => :platform_page
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.repositories.list"), repositories_path
%li= link_to t("layout.repositories.new"), new_user_repository_path(@user)
.content
%h2.title
= t("layout.repositories.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'repositories/list', :object => @repositories
.actions-bar.wat-cf
.actions
= will_paginate @repositories, :param_name => :repository_page
.block
.secondary-navigation
%ul.wat-cf
%li.first.active= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_user_project_path(@user)
.content
%h2.title
= t("layout.projects.list_header")
.inner
= render :partial => 'shared/search_form'
= render :partial => 'projects/list', :object => @projects
.actions-bar.wat-cf
.actions
= will_paginate @projects, :param_name => :project_page
- content_for :sidebar, render(:partial => 'sidebar') - content_for :sidebar, render(:partial => 'sidebar')

View File

@ -0,0 +1,4 @@
# Load extensions to existing classes.
Dir["lib/ext/**/*.rb"].each do |fn|
require File.expand_path( fn )
end

View File

@ -20,6 +20,7 @@ ru:
true_: Да true_: Да
false_: Нет false_: Нет
publish: Опубликовать publish: Опубликовать
add: Добавить
weekdays: weekdays:
Monday: Понедельник Monday: Понедельник
@ -33,6 +34,7 @@ ru:
menu: menu:
users: Пользователи users: Пользователи
platforms: Платформы platforms: Платформы
groups: Группы
sessions: sessions:
sign_in_header: Вход в систему sign_in_header: Вход в систему
@ -57,6 +59,10 @@ ru:
released_suffix: (выпущена) released_suffix: (выпущена)
confirm_delete: Вы уверены, что хотите удалить эту платформу? confirm_delete: Вы уверены, что хотите удалить эту платформу?
current_platform_header: Текущая платформа current_platform_header: Текущая платформа
owner: Владелец
visibility: Видимость
platform_type: Тип платформы
distrib_type: Тип дистрибутива
repositories: repositories:
list: Список list: Список
@ -98,6 +104,7 @@ ru:
weekdays: Дни недели weekdays: Дни недели
projects: projects:
add: Добавить
list: Список list: Список
list_header: Проекты list_header: Проекты
show: Проект show: Проект
@ -113,6 +120,18 @@ ru:
current_build_lists: Текущие сборки current_build_lists: Текущие сборки
build_button: Начать сборку build_button: Начать сборку
groups:
list: Список
new: Создать
edit: Редактировать
members: Участники
new_header: Новая группа
edit_header: Редактировать
list_header: Группы
show: Группа
back_to_the_list: К списку групп
confirm_delete: Вы уверены, что хотите удалить эту группу?
users: users:
list: Список list: Список
new: Создать new: Создать
@ -120,6 +139,7 @@ ru:
new_header: Новый пользователь new_header: Новый пользователь
edit_header: Редактировать edit_header: Редактировать
list_header: Пользователи list_header: Пользователи
groups: Группы
show: Пользователь show: Пользователь
back_to_the_list: К списку пользователей back_to_the_list: К списку пользователей
confirm_delete: Вы уверены, что хотите удалить этого пользователя? confirm_delete: Вы уверены, что хотите удалить этого пользователя?
@ -180,10 +200,19 @@ ru:
save_error: Не удалось сохранить данные о пользователе save_error: Не удалось сохранить данные о пользователе
destroyed: Учетная запись успешно удалена destroyed: Учетная запись успешно удалена
group:
saved: Группа успешно сохранена
save_error: Не удалось сохранить группу
destroyed: Группа успешно удалена
repository: repository:
saved: Репозиторий успешно добавлен saved: Репозиторий успешно добавлен
save_error: Не удалось добавить репозиторий save_error: Не удалось добавить репозиторий
destroyed: Репозиторий успешно удален destroyed: Репозиторий успешно удален
project_added: Проект добавлен к репозиторию
project_not_added: Не удалось добавить проект
project_removed: Проект удален из репозитория
project_not_removed: Не удалось удалить проект из репозитория
product: product:
saved: Продукт успешно сохранен saved: Продукт успешно сохранен
@ -222,6 +251,7 @@ ru:
arch: Arch arch: Arch
container: Container container: Container
platform: Платформа platform: Платформа
group: Группа
project: Проект project: Проект
rpm: RPM rpm: RPM
user: Пользователь user: Пользователь
@ -281,6 +311,8 @@ ru:
project: project:
name: Название name: Название
unixname: Unixname unixname: Unixname
owner: Владелец
visibility: Видимость
repository_id: Репозиторий repository_id: Репозиторий
repository: Репозиторий repository: Репозиторий
created_at: Создан created_at: Создан
@ -295,6 +327,13 @@ ru:
created_at: Создан created_at: Создан
updated_at: Обновлен updated_at: Обновлен
group:
name: Название
uname: Unixname
owner: Владелец
created_at: Создана
updated_at: Обновлена
user: user:
name: Имя name: Имя
login: Никнейм или Email login: Никнейм или Email
@ -302,6 +341,7 @@ ru:
nickname: Никнейм nickname: Никнейм
ssh_key: SSH ключ ssh_key: SSH ключ
current_password: Текущий пароль current_password: Текущий пароль
roles: Роли
created_at: Создан created_at: Создан
updated_at: Обновлен updated_at: Обновлен

View File

@ -4,6 +4,42 @@ Rosa::Application.routes.draw do
end end
resources :users resources :users
# resources :platforms do
# member do
# get 'freeze'
# get 'unfreeze'
# get 'clone'
# end
#
# resources :products do
# member do
# get :clone
# get :build
# end
# end
#
# resources :repositories do
# resources :projects do
# resource :repo, :controller => "git/repositories", :only => [:show]
# resources :build_lists, :only => [:index, :show] do
# collection do
# get :recent
# post :filter
# end
# member do
# post :publish
# end
# end
#
# member do
# get :build
# post :process_build
# end
#
# end
# end
# end
resources :platforms do resources :platforms do
member do member do
get 'freeze' get 'freeze'
@ -19,8 +55,10 @@ Rosa::Application.routes.draw do
end end
resources :repositories do resources :repositories do
end
end
resources :projects do resources :projects do
resource :repo, :controller => "git/repositories", :only => [:show]
resources :build_lists, :only => [:index, :show] do resources :build_lists, :only => [:index, :show] do
collection do collection do
get :recent get :recent
@ -30,14 +68,21 @@ Rosa::Application.routes.draw do
post :publish post :publish
end end
end end
end
resources :repositories do
member do member do
get :build get :add_project
post :process_build get :remove_project
end
end end
end resources :users, :groups do
end resources :platforms, :only => [:new, :create]
resources :projects, :only => [:new, :create]
resources :repositories, :only => [:new, :create]
end end
match 'build_lists/status_build', :to => "build_lists#status_build" match 'build_lists/status_build', :to => "build_lists#status_build"

View File

@ -0,0 +1,15 @@
class CreatePermissions < ActiveRecord::Migration
def self.up
create_table :permissions do |t|
t.integer :id
t.integer :right_id
t.integer :role_id
t.timestamps
end
end
def self.down
drop_table :permissions
end
end

View File

@ -0,0 +1,14 @@
class CreateRoles < ActiveRecord::Migration
def self.up
create_table :roles do |t|
t.integer :id
t.string :name
t.timestamps
end
end
def self.down
drop_table :roles
end
end

View File

@ -0,0 +1,17 @@
class CreateRelations < ActiveRecord::Migration
def self.up
create_table :relations do |t|
t.integer :object_id
t.string :object_type
t.integer :target_id
t.string :target_type
t.integer :role_id
t.timestamps
end
end
def self.down
drop_table :relations
end
end

View File

@ -0,0 +1,14 @@
class CreateGroups < ActiveRecord::Migration
def self.up
create_table :groups do |t|
t.string :name
t.integer :owner_id
t.timestamps
end
end
def self.down
drop_table :groups
end
end

View File

@ -0,0 +1,15 @@
class CreateProjectToRepositories < ActiveRecord::Migration
def self.up
create_table :project_to_repositories do |t|
t.integer :id
t.integer :project_id
t.integer :repository_id
t.timestamps
end
end
def self.down
drop_table :project_to_repositories
end
end

View File

@ -0,0 +1,9 @@
class RemoveRepositoryIdFromProject < ActiveRecord::Migration
def self.up
remove_column :projects, :repository_id
end
def self.down
add_column :projects, :repository_id, :integer, :null => false
end
end

View File

@ -0,0 +1,9 @@
class AddUnameToGroups < ActiveRecord::Migration
def self.up
add_column :groups, :uname, :string
end
def self.down
remove_column :groups, :uname
end
end

View File

@ -0,0 +1,18 @@
class PlatformRestruct < ActiveRecord::Migration
def self.up
change_table :platforms do |t|
t.references :owner, :polymorphic => true
t.string :visibility, :default => 'open'
t.string :platform_type, :default => 'main'
t.string :distrib_type
end
end
def self.down
remove_column :platforms, :visibility
remove_column :platforms, :owner_id
remove_column :platforms, :owner_type
remove_column :platforms, :platform_type
remove_column :platforms, :distrib_type
end
end

View File

@ -0,0 +1,14 @@
class ProjectRestruct < ActiveRecord::Migration
def self.up
change_table :projects do |t|
t.references :owner, :polymorphic => true
t.string :visibility, :default => 'open'
end
end
def self.down
remove_column :projects, :visibility
remove_column :projects, :owner_id
remove_column :projects, :owner_type
end
end

View File

@ -0,0 +1,14 @@
class RepositoriesRestruct < ActiveRecord::Migration
def self.up
change_table :repositories do |t|
t.references :owner, :polymorphic => true
t.string :visibility, :default => 'open'
end
end
def self.down
remove_column :repositories, :visibility
remove_column :repositories, :owner_id
remove_column :repositories, :owner_type
end
end

View File

@ -0,0 +1,9 @@
class AddUnameToUsers < ActiveRecord::Migration
def self.up
add_column :users, :uname, :string
end
def self.down
remove_column :users, :uname
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111011200645) do ActiveRecord::Schema.define(:version => 20111018102655) do
create_table "arches", :force => true do |t| create_table "arches", :force => true do |t|
t.string "name", :null => false t.string "name", :null => false
@ -84,6 +84,21 @@ ActiveRecord::Schema.define(:version => 20111011200645) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "groups", :force => true do |t|
t.string "name"
t.integer "owner_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "uname"
end
create_table "permissions", :force => true do |t|
t.integer "right_id"
t.integer "role_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "platforms", :force => true do |t| create_table "platforms", :force => true do |t|
t.string "name" t.string "name"
t.string "unixname" t.string "unixname"
@ -91,6 +106,11 @@ ActiveRecord::Schema.define(:version => 20111011200645) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "released", :default => false t.boolean "released", :default => false
t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
t.string "platform_type", :default => "main"
t.string "distrib_type"
end end
create_table "products", :force => true do |t| create_table "products", :force => true do |t|
@ -114,12 +134,31 @@ ActiveRecord::Schema.define(:version => 20111011200645) do
t.boolean "use_cron", :default => false t.boolean "use_cron", :default => false
end end
create_table "project_to_repositories", :force => true do |t|
t.integer "project_id"
t.integer "repository_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "projects", :force => true do |t| create_table "projects", :force => true do |t|
t.string "name" t.string "name"
t.string "unixname" t.string "unixname"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "repository_id", :null => false t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
end
create_table "relations", :force => true do |t|
t.integer "object_id"
t.string "object_type"
t.integer "target_id"
t.string "target_type"
t.integer "role_id"
t.datetime "created_at"
t.datetime "updated_at"
end end
create_table "repositories", :force => true do |t| create_table "repositories", :force => true do |t|
@ -128,6 +167,23 @@ ActiveRecord::Schema.define(:version => 20111011200645) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "unixname", :null => false t.string "unixname", :null => false
t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
end
create_table "rights", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "roles", :force => true do |t|
t.string "name"
t.string "to"
t.string "on"
t.datetime "created_at"
t.datetime "updated_at"
end end
create_table "rpms", :force => true do |t| create_table "rpms", :force => true do |t|
@ -153,6 +209,7 @@ ActiveRecord::Schema.define(:version => 20111011200645) do
t.datetime "updated_at" t.datetime "updated_at"
t.string "nickname" t.string "nickname"
t.text "ssh_key" t.text "ssh_key"
t.string "uname"
end end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Group do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Permission do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe ProjectToRepository do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Relation do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Right do
pending "add some examples to (or delete) #{__FILE__}"
end

5
spec/models/role_spec.rb Normal file
View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Role do
pending "add some examples to (or delete) #{__FILE__}"
end