diff --git a/.gitignore b/.gitignore index dd86dc098..2774c7312 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ public/stylesheets/compiled/* public/assets/* config/initializers/local.rb public/system/* +.rvmrc diff --git a/Gemfile b/Gemfile index ccbac6cce..1f6d1c2e5 100644 --- a/Gemfile +++ b/Gemfile @@ -51,6 +51,10 @@ group :development do gem 'capistrano_colors', :require => false end +group :development, :test do + gem 'mysql2', '<= 0.2.9' +end + group :test do gem 'rspec-rails', '~> 2.6.1' gem 'factory_girl_rails', '~> 1.2.0' diff --git a/Gemfile.lock b/Gemfile.lock index e06fd22da..a0378304c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,6 +105,7 @@ GEM multi_json (1.0.3) multi_xml (0.4.1) multipart-post (1.1.3) + mysql2 (0.2.9) net-ldap (0.2.2) net-scp (1.0.4) net-ssh (>= 1.99.1) @@ -154,7 +155,7 @@ GEM oa-oauth (= 0.3.0) oa-openid (= 0.3.0) orm_adapter (0.0.5) - paperclip (2.4.3) + paperclip (2.4.4) activerecord (>= 2.3.0) activesupport (>= 2.3.2) cocaine (>= 0.0.2) @@ -186,10 +187,10 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.4) - raindrops (0.7.0) + raindrops (0.8.0) rake (0.9.2) rbx-require-relative (0.0.5) - rdoc (3.10) + rdoc (3.11) json (~> 1.4) rest-client (1.6.7) mime-types (>= 1.16) @@ -256,6 +257,7 @@ DEPENDENCIES haml-rails (~> 0.3.4) hpricot jammit + mysql2 (<= 0.2.9) oa-openid (~> 0.3.0) omniauth (~> 0.3.0) paperclip (~> 2.3) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 51b260773..f7372d2aa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,45 @@ +# coding: UTF-8 class ApplicationController < ActionController::Base protect_from_forgery 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 def layout_by_resource if devise_controller? diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 000000000..5e47b5a78 --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -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 diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index fb508a727..9494dd461 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -4,14 +4,16 @@ class PlatformsController < ApplicationController before_filter :authenticate_user! before_filter :find_platform, :only => [:freeze, :unfreeze, :clone] + before_filter :get_paths, :only => [:new, :create] def index - @platforms = Platform.all + @platforms = Platform.paginate(:page => params[:platform_page]) end def show @platform = Platform.find params[:id], :include => :repositories @repositories = @platform.repositories + @members = @platform.members.uniq end def new @@ -21,6 +23,9 @@ class PlatformsController < ApplicationController def create @platform = Platform.new params[:platform] + + @platform.owner = get_acter + if @platform.save flash[:notice] = I18n.t("flash.platform.saved") redirect_to @platform @@ -72,6 +77,21 @@ class PlatformsController < ApplicationController end 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 @platform = Platform.find params[:id] end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 76f69c1f7..839442128 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,11 +1,12 @@ class ProjectsController < ApplicationController before_filter :authenticate_user! - before_filter :find_platform - before_filter :find_repository +# before_filter :find_platform +# before_filter :find_repository before_filter :find_project, :only => [:show, :destroy, :build, :process_build] + before_filter :get_paths, :only => [:new, :create] def new - @project = @repository.projects.new + @project = Project.new end def show @@ -44,10 +45,12 @@ class ProjectsController < ApplicationController end def create - @project = @repository.projects.new params[:project] + @project = Project.new params[:project] + @project.owner = get_acter + if @project.save flash[:notice] = t('flash.project.saved') - redirect_to [@platform, @repository] + redirect_to @project.owner else flash[:error] = t('flash.project.save_error') render :action => :new @@ -63,6 +66,21 @@ class ProjectsController < ApplicationController 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 @platform = Platform.find params[:platform_id] end @@ -72,7 +90,7 @@ class ProjectsController < ApplicationController end def find_project - @project = @repository.projects.find params[:id] + @project = Project.find params[:id] end def check_arches diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9a9b1c2d9..dad3a6e0e 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -1,18 +1,24 @@ class RepositoriesController < ApplicationController before_filter :authenticate_user! - before_filter :find_platform - before_filter :find_repository, :only => [:show, :destroy] + #before_filter :find_platform, :except => [:index, :new, :create] + 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 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 - @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 def new - @repository = @platform.repositories.new + @repository = Repository.new end def destroy @@ -23,23 +29,91 @@ class RepositoriesController < ApplicationController end def create - @repository = @platform.repositories.new(params[:repository]) + @repository = Repository.new(params[:repository]) + @repository.owner = get_acter if @repository.save flash[:notice] = t('flash.repository.saved') - redirect_to [@platform, @repository] + redirect_to @repositories_path else flash[:error] = t('flash.repository.save_error') render :action => :new 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 + 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] + @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 = Platform.find params[:platform_id] + @platform = @repository.platform + end + + def find_platforms + @platforms = Platform.all end def find_repository - @repository = @platform.repositories.find(params[:id]) + @repository = Repository.find(params[:id]) end end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb new file mode 100644 index 000000000..2a6429bdb --- /dev/null +++ b/app/controllers/roles_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e5d8c2540..8707ec422 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,6 +6,11 @@ class UsersController < ApplicationController end 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 def new diff --git a/app/models/group.rb b/app/models/group.rb new file mode 100644 index 000000000..d8acb3774 --- /dev/null +++ b/app/models/group.rb @@ -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 diff --git a/app/models/permission.rb b/app/models/permission.rb new file mode 100644 index 000000000..5db19cfa5 --- /dev/null +++ b/app/models/permission.rb @@ -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 \ No newline at end of file diff --git a/app/models/platform.rb b/app/models/platform.rb index a0a6bf8ca..4a14012a7 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -1,15 +1,25 @@ #require 'lib/build_server.rb' class Platform < ActiveRecord::Base belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' + belongs_to :owner, :polymorphic => true + has_many :repositories, :dependent => :destroy has_many :products, :dependent => :destroy - validates :name, :presence => true, :uniqueness => true - validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false + 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' - before_create :xml_rpc_create - before_destroy :xml_rpc_destroy - before_update :check_freezing + validates :name, :presence => true, :uniqueness => true + validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }, :allow_nil => false, :allow_blank => false + + #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 @@ -30,10 +40,24 @@ class Platform < ActiveRecord::Base released? ? "#{self[:name]} #{I18n.t("layout.platforms.released_suffix")}" : self[:name] 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 def build_path(dir) - File.join(APP_CONFIG['root_path'], dir) + File.join(APP_CONFIG['root_path'], 'platforms', dir) end def git_path(dir) @@ -50,31 +74,47 @@ class Platform < ActiveRecord::Base end end - def xml_rpc_create - result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] - if result == BuildServer::SUCCESS - return true - else - raise "Failed to create platform #{name}. Path: #{build_path(unixname)}" + def remove_directory + exists = File.exists?(path) && File.directory?(path) + raise "Directory #{path} didn't exists" unless exists + FileUtils.rm_rf(path) + 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 + def xml_rpc_destroy - result = BuildServer.delete_platform unixname - if result == BuildServer::SUCCESS - return true - else - raise "Failed to delete platform #{unixname}." - end + return true +# result = BuildServer.delete_platform unixname +# if result == BuildServer::SUCCESS +# return true +# else +# raise "Failed to delete platform #{unixname}." +# end end def xml_rpc_clone(new_unixname) - result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] - if result == BuildServer::SUCCESS - return true - else - raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}" - end + return true +# result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] +# if result == BuildServer::SUCCESS +# return true +# else +# raise "Failed to clone platform #{name}. Path: #{build_path(unixname)} to platform #{new_unixname}" +# end end def check_freezing diff --git a/app/models/project.rb b/app/models/project.rb index e925a8070..6bc6c6685 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,18 +1,33 @@ class Project < ActiveRecord::Base - belongs_to :repository + belongs_to :owner, :polymorphic => true + has_many :build_lists, :dependent => :destroy - validates :name, :uniqueness => {:scope => :repository_id}, :presence => true, :allow_nil => false, :allow_blank => false - validates :unixname, :uniqueness => {:scope => :repository_id}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false + has_many :project_to_repositories + 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 scope :recent, order("name ASC") scope :by_name, lambda { |name| {:conditions => ['name like ?', '%' + name + '%']} } - #before_create :create_directory, :create_git_repo - before_create :xml_rpc_create - before_destroy :xml_rpc_destroy + before_save :create_directory#, :create_git_repo + before_save :make_owner_rel + 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 def git_repo_path @@ -41,8 +56,15 @@ class Project < ActiveRecord::Base 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) - File.join(repository.path, dir) + File.join(APP_CONFIG['root_path'], 'projects', dir) end def create_directory @@ -55,6 +77,12 @@ class Project < ActiveRecord::Base 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 result = BuildServer.create_project unixname, repository.platform.unixname, repository.unixname if result == BuildServer::SUCCESS diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb new file mode 100644 index 000000000..a0cc507d5 --- /dev/null +++ b/app/models/project_to_repository.rb @@ -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 diff --git a/app/models/relation.rb b/app/models/relation.rb new file mode 100644 index 000000000..53cf77a69 --- /dev/null +++ b/app/models/relation.rb @@ -0,0 +1,5 @@ +class Relation < ActiveRecord::Base + belongs_to :target, :polymorphic => true + belongs_to :object, :polymorphic => true + belongs_to :role, :autosave => true +end diff --git a/app/models/repository.rb b/app/models/repository.rb index 247010c60..1ee8a3850 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,14 +1,26 @@ class Repository < ActiveRecord::Base belongs_to :platform - has_many :projects, :dependent => :destroy + belongs_to :owner, :polymorphic => true - validates :name, :uniqueness => {:scope => :platform_id}, :presence => true - validates :unixname, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ } + has_many :projects, :through => :project_to_repositories #, :dependent => :destroy + 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") - before_create :xml_rpc_create - before_destroy :xml_rpc_destroy + before_save :create_directory + before_save :make_owner_rel + after_destroy :remove_directory + +# before_create :xml_rpc_create +# before_destroy :xml_rpc_destroy def path build_path(unixname) @@ -24,6 +36,13 @@ class Repository < ActiveRecord::Base 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) File.join(platform.path, dir) end @@ -38,7 +57,13 @@ class Repository < ActiveRecord::Base FileUtils.mv(build_path(unixname_was), buildpath(unixname)) 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 result = BuildServer.create_repo unixname, platform.unixname if result == BuildServer::SUCCESS diff --git a/app/models/role.rb b/app/models/role.rb new file mode 100644 index 000000000..85e31b9da --- /dev/null +++ b/app/models/role.rb @@ -0,0 +1,4 @@ +class Role < ActiveRecord::Base + has_many :permissions + has_many :relations +end diff --git a/app/models/user.rb b/app/models/user.rb index d0e10cbd6..141cf4741 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,11 +3,36 @@ class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :omniauthable, # :token_authenticatable, :encryptable, :timeoutable :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 attr_accessible :email, :password, :password_confirmation, :remember_me, :login, :nickname, :name, :ssh_key attr_readonly :nickname + before_save :create_dir + after_destroy :remove_dir + + def path + build_path(uname) + end + + protected attr_accessor :login @@ -46,4 +71,24 @@ class User < ActiveRecord::Base clean_up_passwords result 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 diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml new file mode 100644 index 000000000..7fe4a3e9a --- /dev/null +++ b/app/views/groups/_form.html.haml @@ -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" diff --git a/app/views/groups/_list.html.haml b/app/views/groups/_list.html.haml new file mode 100644 index 000000000..d66c0364e --- /dev/null +++ b/app/views/groups/_list.html.haml @@ -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   + - @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 diff --git a/app/views/groups/_sidebar.html.haml b/app/views/groups/_sidebar.html.haml new file mode 100644 index 000000000..83cef0324 --- /dev/null +++ b/app/views/groups/_sidebar.html.haml @@ -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) diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml new file mode 100644 index 000000000..5d29b63b7 --- /dev/null +++ b/app/views/groups/edit.html.haml @@ -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') diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml new file mode 100644 index 000000000..005f4b168 --- /dev/null +++ b/app/views/groups/index.html.haml @@ -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') diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml new file mode 100644 index 000000000..04a96c3e0 --- /dev/null +++ b/app/views/groups/new.html.haml @@ -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') diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml new file mode 100644 index 000000000..29522f7e2 --- /dev/null +++ b/app/views/groups/show.html.haml @@ -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') diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 752f0ad37..493a37a38 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,10 +14,16 @@ %ul.wat-cf %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 +/ = t("layout.logged_in_as") + ' ' + current_user.name +/   |   +/ = link_to t('layout.logout'), destroy_user_session_path, :class => "logout" #main-navigation %ul.wat-cf %li{:class => controller.controller_path == 'users' ? 'active' : '' } %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' : '' } %a{:href => platforms_path}= t("layout.menu.platforms") #wrapper.wat-cf diff --git a/app/views/platforms/_form.html.haml b/app/views/platforms/_form.html.haml index 3cdecdc89..6152a8713 100644 --- a/app/views/platforms/_form.html.haml +++ b/app/views/platforms/_form.html.haml @@ -19,4 +19,4 @@ = 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"), platforms_path, :class => "text_button_padding link_button" + = link_to t("layout.cancel"), @platforms_path, :class => "text_button_padding link_button" diff --git a/app/views/platforms/_list.html.haml b/app/views/platforms/_list.html.haml new file mode 100644 index 000000000..e9d8caf7f --- /dev/null +++ b/app/views/platforms/_list.html.haml @@ -0,0 +1,10 @@ +%table.table + %tr + %th.first= t("activerecord.attributes.platform.name") + %th.last   + - @platforms.each do |platform| + %tr{:class => cycle("odd", "even")} + %td + = link_to platform.name, platform_path(platform) + %td.last + #{link_to t("layout.show"), platform_path(platform)} | #{link_to t("layout.delete"), platform_path(platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete")} diff --git a/app/views/platforms/_sidebar.html.haml b/app/views/platforms/_sidebar.html.haml index e69de29bb..dbe489981 100644 --- a/app/views/platforms/_sidebar.html.haml +++ b/app/views/platforms/_sidebar.html.haml @@ -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) diff --git a/app/views/platforms/index.html.haml b/app/views/platforms/index.html.haml index 61bfbfdac..8c86683d4 100644 --- a/app/views/platforms/index.html.haml +++ b/app/views/platforms/index.html.haml @@ -7,15 +7,29 @@ %h2.title = t("layout.platforms.list_header") .inner - %table.table - %tr - %th.first= t("activerecord.attributes.platform.name") - %th.last   - - @platforms.each do |platform| - %tr{:class => cycle("odd", "even")} - %td - = link_to platform.name, platform_path(platform) - %td.last - #{link_to t("layout.show"), platform_path(platform)} | #{link_to t("layout.delete"), platform_path(platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete")} + = 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.platforms.list"), platforms_path +/ %li= link_to t("layout.platforms.new"), new_platform_path +/ .content +/ %h2.title +/ = t("layout.platforms.list_header") +/ .inner +/ %table.table +/ %tr +/ %th.first= t("activerecord.attributes.platform.name") +/ %th.last   +/ - @platforms.each do |platform| +/ %tr{:class => cycle("odd", "even")} +/ %td +/ = link_to platform.name, platform_path(platform) +/ %td.last +/ #{link_to t("layout.show"), platform_path(platform)} | #{link_to t("layout.delete"), platform_path(platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete")} +/ .actions-bar.wat-cf +/ .actions diff --git a/app/views/platforms/new.html.haml b/app/views/platforms/new.html.haml index 5f44e786a..a6fad7b32 100644 --- a/app/views/platforms/new.html.haml +++ b/app/views/platforms/new.html.haml @@ -1,11 +1,11 @@ .block .secondary-navigation %ul.wat-cf - %li.first= link_to "#{t("layout.platforms.list")}", platforms_path - %li.active= link_to "#{t("layout.platforms.new")}", new_platform_path + %li.first= link_to "#{t("layout.platforms.list")}", @platforms_path + %li.active= link_to "#{t("layout.platforms.new")}", @new_platform_path .content %h2.title = t("layout.platforms.new_header") .inner - = form_for :platform, :url => platforms_path, :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} \ No newline at end of file + = form_for :platform, :url => @platforms_path, :html => { :class => :form } do |f| + = render :partial => "form", :locals => {:f => f} diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/show.html.haml index c6b5c770c..3cd62b70a 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/show.html.haml @@ -29,6 +29,31 @@ \: = @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 -#= 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") @@ -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 } .actions-bar.wat-cf .actions --#- content_for :sidebar do - +- content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 6322f58e4..51a3bf29e 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -10,4 +10,4 @@ = 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"), platform_repository_path(@platform, @repository), :class => "text_button_padding link_button" \ No newline at end of file + = link_to t("layout.cancel"), @projects_path, :class => "text_button_padding link_button" diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml new file mode 100644 index 000000000..32f63774b --- /dev/null +++ b/app/views/projects/_list.html.haml @@ -0,0 +1,10 @@ +%table.table + %tr + %th.first= t("activerecord.attributes.project.name") + %th.last   + - @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")} diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index dee8efad4..666eaea30 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -1,14 +1,14 @@ .block .secondary-navigation %ul.wat-cf - %li.first= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" - %li.active= link_to t("layout.projects.new"), new_platform_repository_project_path(@platform, @repository) + %li.first= link_to t("layout.projects.list"), @projects_path#url_for(get_acter) + "#projects" + %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 t("layout.projects.build"), build_platform_repository_project_path(@platform, @repository, @project) .content %h2.title= t("layout.projects.new_header") .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} -- content_for :sidebar, render(:partial => 'sidebar') +-# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 417edd325..a8198dc0f 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -1,11 +1,11 @@ .block .secondary-navigation %ul.wat-cf - %li.first= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" - %li= link_to t("layout.projects.new"), new_platform_repository_project_path(@platform, @repository) - %li.active= link_to t("layout.projects.show"), platform_repository_project_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.first= link_to t("layout.projects.list"), projects_path + %li= link_to t("layout.projects.new"), new_project_path + %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 t("layout.projects.build"), '#'#build_platform_repository_project_path(@platform, @repository, @project) .content .inner @@ -21,21 +21,31 @@ = @project.unixname %p %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 - = 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"} .block .secondary-navigation %ul.wat-cf - %li.first.active= link_to t("layout.build_lists.current"), platform_repository_project_path(@platform, @repository, @project) + "#build_lists" - %li= link_to t("layout.build_lists.all"), platform_repository_project_build_lists_path(@platform, @repository, @project) + %li.first.active= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists" + %li= link_to t("layout.build_lists.all"), project_build_lists_path(@project) .content = render :partial => "build_lists/build_lists", :object => @current_build_lists -- content_for :sidebar, render(:partial => 'sidebar') +-# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/repositories/_form.html.haml b/app/views/repositories/_form.html.haml index 1ec4e7935..e34e61de3 100644 --- a/app/views/repositories/_form.html.haml +++ b/app/views/repositories/_form.html.haml @@ -5,10 +5,14 @@ = f.label :unixname, t("activerecord.attributes.repository.unixname"), :class => :label = 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 %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"), platform_path(@platform) + "#repositories", :class => "text_button_padding link_button" + = link_to t("layout.cancel"), @repositories_path + "#repositories", :class => "text_button_padding link_button" diff --git a/app/views/repositories/_list.html.haml b/app/views/repositories/_list.html.haml new file mode 100644 index 000000000..581f705d3 --- /dev/null +++ b/app/views/repositories/_list.html.haml @@ -0,0 +1,10 @@ +%table.table + %tr + %th.first= t("activerecord.attributes.repository.name") + %th.last   + - @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")} diff --git a/app/views/repositories/_proj_list.html.haml b/app/views/repositories/_proj_list.html.haml new file mode 100644 index 000000000..cb3745999 --- /dev/null +++ b/app/views/repositories/_proj_list.html.haml @@ -0,0 +1,11 @@ +%table.table + %tr + %th.first= t("activerecord.attributes.project.name") + %th.last   + - @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)} + diff --git a/app/views/repositories/_proj_list1.html.haml b/app/views/repositories/_proj_list1.html.haml new file mode 100644 index 000000000..c37d33bf7 --- /dev/null +++ b/app/views/repositories/_proj_list1.html.haml @@ -0,0 +1,10 @@ +%table.table + %tr + %th.first= t("activerecord.attributes.project.name") + %th.last   + - @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")} diff --git a/app/views/repositories/index.html.haml b/app/views/repositories/index.html.haml new file mode 100644 index 000000000..00a1677f9 --- /dev/null +++ b/app/views/repositories/index.html.haml @@ -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 diff --git a/app/views/repositories/new.html.haml b/app/views/repositories/new.html.haml index d2509bd2c..36708efde 100644 --- a/app/views/repositories/new.html.haml +++ b/app/views/repositories/new.html.haml @@ -1,11 +1,11 @@ .block .secondary-navigation %ul.wat-cf - %li.first= link_to t("layout.repositories.list"), platform_path(@platform) + "#platforms" - %li.active= link_to t("layout.repositories.new"), new_platform_repository_path(@platform) + %li.first= link_to t("layout.repositories.list"), @repositories_path + "#platforms" + %li.active= link_to t("layout.repositories.new"), @new_repository_path .content %h2.title= t("layout.repositories.new_header") .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} -- content_for :sidebar, render(:partial => 'sidebar') \ No newline at end of file +-# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/repositories/projects_list.html.haml b/app/views/repositories/projects_list.html.haml new file mode 100644 index 000000000..ed5120d3c --- /dev/null +++ b/app/views/repositories/projects_list.html.haml @@ -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') + diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml index 47a2b547f..d96f8b62a 100644 --- a/app/views/repositories/show.html.haml +++ b/app/views/repositories/show.html.haml @@ -1,9 +1,9 @@ .block .secondary-navigation %ul.wat-cf - %li.first= link_to t("layout.repositories.list"), platform_path(@platform) + "#repositories" - %li= link_to t("layout.repositories.new"), new_platform_repository_path(@platform) - %li.active= link_to t("layout.repositories.show"), platform_repository_path(@platform, @repository) + %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 @@ -16,42 +16,44 @@ = 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"), 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" } .block .secondary-navigation %ul.wat-cf - %li.first.active= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" - %li= link_to t("layout.projects.new"), new_platform_repository_project_path(@platform, @repository) + %li.first.active= link_to t("layout.projects.list"), repository_path(@repository) + "#projects" + %li= link_to t("layout.projects.add"), url_for(:controller => :repositories, :action => :add_project) .content %h2.title = t("layout.projects.list_header") .inner - = form_tag 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") - %table.table - %tr - %th.first= t("activerecord.attributes.project.name") - %th.last   - - @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")} + = render :partial => 'shared/search_form' + = render :partial => 'proj_list1', :object => @projects .actions-bar.wat-cf .actions - = will_paginate @projects + = will_paginate @projects, :param_name => :project_page -- content_for :sidebar, render(:partial => 'sidebar') + +-# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/roles/_form.html.haml b/app/views/roles/_form.html.haml new file mode 100644 index 000000000..8710ea245 --- /dev/null +++ b/app/views/roles/_form.html.haml @@ -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" \ No newline at end of file diff --git a/app/views/roles/_sidebar.html.haml b/app/views/roles/_sidebar.html.haml new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/roles/edit.html.haml b/app/views/roles/edit.html.haml new file mode 100644 index 000000000..8f833ba6d --- /dev/null +++ b/app/views/roles/edit.html.haml @@ -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') diff --git a/app/views/roles/index.html.haml b/app/views/roles/index.html.haml new file mode 100644 index 000000000..3462e5071 --- /dev/null +++ b/app/views/roles/index.html.haml @@ -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   + - @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') diff --git a/app/views/roles/new.html.haml b/app/views/roles/new.html.haml new file mode 100644 index 000000000..c433a39ed --- /dev/null +++ b/app/views/roles/new.html.haml @@ -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') \ No newline at end of file diff --git a/app/views/roles/show.html.haml b/app/views/roles/show.html.haml new file mode 100644 index 000000000..6a98822b6 --- /dev/null +++ b/app/views/roles/show.html.haml @@ -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') diff --git a/app/views/shared/_search_form.html.haml b/app/views/shared/_search_form.html.haml new file mode 100644 index 000000000..b94ba5a3e --- /dev/null +++ b/app/views/shared/_search_form.html.haml @@ -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") diff --git a/app/views/users/_groups_roled_list.html.haml b/app/views/users/_groups_roled_list.html.haml new file mode 100644 index 000000000..60325749a --- /dev/null +++ b/app/views/users/_groups_roled_list.html.haml @@ -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   + - @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 diff --git a/app/views/users/_sidebar.html.haml b/app/views/users/_sidebar.html.haml index e69de29bb..78f72b290 100644 --- a/app/views/users/_sidebar.html.haml +++ b/app/views/users/_sidebar.html.haml @@ -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) diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 7b05d0bd3..e147bd57e 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -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")} .actions-bar.wat-cf .actions -- content_for :sidebar, render(:partial => 'sidebar') +-# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/users/new.html.haml b/app/views/users/new.html.haml index 65a4228de..0c86e995f 100644 --- a/app/views/users/new.html.haml +++ b/app/views/users/new.html.haml @@ -8,4 +8,4 @@ .inner = form_for :user, :url => users_path, :html => { :class => :form } do |f| = render :partial => "form", :locals => {:f => f} -- content_for :sidebar, render(:partial => 'sidebar') \ No newline at end of file +-# content_for :sidebar, render(:partial => 'sidebar') diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index ab8c9d039..0089b5bfc 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -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/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') diff --git a/config/initializers/ext.rb b/config/initializers/ext.rb new file mode 100644 index 000000000..26cb643b3 --- /dev/null +++ b/config/initializers/ext.rb @@ -0,0 +1,4 @@ +# Load extensions to existing classes. +Dir["lib/ext/**/*.rb"].each do |fn| + require File.expand_path( fn ) +end diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 6711ed015..5cd0bac00 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -20,6 +20,7 @@ ru: true_: Да false_: Нет publish: Опубликовать + add: Добавить weekdays: Monday: Понедельник @@ -33,6 +34,7 @@ ru: menu: users: Пользователи platforms: Платформы + groups: Группы sessions: sign_in_header: Вход в систему @@ -57,6 +59,10 @@ ru: released_suffix: (выпущена) confirm_delete: Вы уверены, что хотите удалить эту платформу? current_platform_header: Текущая платформа + owner: Владелец + visibility: Видимость + platform_type: Тип платформы + distrib_type: Тип дистрибутива repositories: list: Список @@ -98,6 +104,7 @@ ru: weekdays: Дни недели projects: + add: Добавить list: Список list_header: Проекты show: Проект @@ -113,6 +120,18 @@ ru: current_build_lists: Текущие сборки build_button: Начать сборку + groups: + list: Список + new: Создать + edit: Редактировать + members: Участники + new_header: Новая группа + edit_header: Редактировать + list_header: Группы + show: Группа + back_to_the_list: ⇐ К списку групп + confirm_delete: Вы уверены, что хотите удалить эту группу? + users: list: Список new: Создать @@ -120,6 +139,7 @@ ru: new_header: Новый пользователь edit_header: Редактировать list_header: Пользователи + groups: Группы show: Пользователь back_to_the_list: ⇐ К списку пользователей confirm_delete: Вы уверены, что хотите удалить этого пользователя? @@ -180,10 +200,19 @@ ru: save_error: Не удалось сохранить данные о пользователе destroyed: Учетная запись успешно удалена + group: + saved: Группа успешно сохранена + save_error: Не удалось сохранить группу + destroyed: Группа успешно удалена + repository: saved: Репозиторий успешно добавлен save_error: Не удалось добавить репозиторий destroyed: Репозиторий успешно удален + project_added: Проект добавлен к репозиторию + project_not_added: Не удалось добавить проект + project_removed: Проект удален из репозитория + project_not_removed: Не удалось удалить проект из репозитория product: saved: Продукт успешно сохранен @@ -222,6 +251,7 @@ ru: arch: Arch container: Container platform: Платформа + group: Группа project: Проект rpm: RPM user: Пользователь @@ -281,6 +311,8 @@ ru: project: name: Название unixname: Unixname + owner: Владелец + visibility: Видимость repository_id: Репозиторий repository: Репозиторий created_at: Создан @@ -295,6 +327,13 @@ ru: created_at: Создан updated_at: Обновлен + group: + name: Название + uname: Unixname + owner: Владелец + created_at: Создана + updated_at: Обновлена + user: name: Имя login: Никнейм или Email @@ -302,6 +341,7 @@ ru: nickname: Никнейм ssh_key: SSH ключ current_password: Текущий пароль + roles: Роли created_at: Создан updated_at: Обновлен diff --git a/config/routes.rb b/config/routes.rb index fe44ff666..b96b9d6fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,42 @@ Rosa::Application.routes.draw do end 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 member do get 'freeze' @@ -19,27 +55,36 @@ Rosa::Application.routes.draw do 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 + resources :projects do + resources :build_lists, :only => [:index, :show] do + collection do + get :recent + post :filter + end + member do + post :publish end end end - + + resources :repositories do + member do + get :add_project + get :remove_project + end + end + + resources :users, :groups do + resources :platforms, :only => [:new, :create] + + resources :projects, :only => [:new, :create] + + resources :repositories, :only => [:new, :create] + end + match 'build_lists/status_build', :to => "build_lists#status_build" match 'build_lists/post_build', :to => "build_lists#post_build" match 'build_lists/pre_build', :to => "build_lists#pre_build" diff --git a/db/migrate/20111012223006_create_permissions.rb b/db/migrate/20111012223006_create_permissions.rb new file mode 100644 index 000000000..8001623a4 --- /dev/null +++ b/db/migrate/20111012223006_create_permissions.rb @@ -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 diff --git a/db/migrate/20111012223306_create_roles.rb b/db/migrate/20111012223306_create_roles.rb new file mode 100644 index 000000000..b5693219d --- /dev/null +++ b/db/migrate/20111012223306_create_roles.rb @@ -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 diff --git a/db/migrate/20111012223521_create_relations.rb b/db/migrate/20111012223521_create_relations.rb new file mode 100644 index 000000000..b29830025 --- /dev/null +++ b/db/migrate/20111012223521_create_relations.rb @@ -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 diff --git a/db/migrate/20111012223944_create_groups.rb b/db/migrate/20111012223944_create_groups.rb new file mode 100644 index 000000000..c5b3522ea --- /dev/null +++ b/db/migrate/20111012223944_create_groups.rb @@ -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 diff --git a/db/migrate/20111013150125_create_project_to_repositories.rb b/db/migrate/20111013150125_create_project_to_repositories.rb new file mode 100644 index 000000000..148561c4c --- /dev/null +++ b/db/migrate/20111013150125_create_project_to_repositories.rb @@ -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 diff --git a/db/migrate/20111014150436_remove_repository_id_from_project.rb b/db/migrate/20111014150436_remove_repository_id_from_project.rb new file mode 100644 index 000000000..bc85b3ae0 --- /dev/null +++ b/db/migrate/20111014150436_remove_repository_id_from_project.rb @@ -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 diff --git a/db/migrate/20111016130557_add_uname_to_groups.rb b/db/migrate/20111016130557_add_uname_to_groups.rb new file mode 100644 index 000000000..37805aabf --- /dev/null +++ b/db/migrate/20111016130557_add_uname_to_groups.rb @@ -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 diff --git a/db/migrate/20111016220428_platform_restruct.rb b/db/migrate/20111016220428_platform_restruct.rb new file mode 100644 index 000000000..60d49c43d --- /dev/null +++ b/db/migrate/20111016220428_platform_restruct.rb @@ -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 diff --git a/db/migrate/20111016224709_project_restruct.rb b/db/migrate/20111016224709_project_restruct.rb new file mode 100644 index 000000000..89d190c12 --- /dev/null +++ b/db/migrate/20111016224709_project_restruct.rb @@ -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 diff --git a/db/migrate/20111016225240_repositories_restruct.rb b/db/migrate/20111016225240_repositories_restruct.rb new file mode 100644 index 000000000..21a3a5b60 --- /dev/null +++ b/db/migrate/20111016225240_repositories_restruct.rb @@ -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 diff --git a/db/migrate/20111018102655_add_uname_to_users.rb b/db/migrate/20111018102655_add_uname_to_users.rb new file mode 100644 index 000000000..7572a6139 --- /dev/null +++ b/db/migrate/20111018102655_add_uname_to_users.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 0e1886e2d..fc4f1b313 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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| 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" + 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| t.string "name" t.string "unixname" @@ -91,6 +106,11 @@ ActiveRecord::Schema.define(:version => 20111011200645) do t.datetime "created_at" t.datetime "updated_at" 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 create_table "products", :force => true do |t| @@ -114,20 +134,56 @@ ActiveRecord::Schema.define(:version => 20111011200645) do t.boolean "use_cron", :default => false 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| t.string "name" t.string "unixname" t.datetime "created_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 create_table "repositories", :force => true do |t| - t.string "name", :null => false - t.integer "platform_id", :null => false + t.string "name", :null => false + t.integer "platform_id", :null => false + t.datetime "created_at" + t.datetime "updated_at" + 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" - t.string "unixname", :null => false end create_table "rpms", :force => true do |t| @@ -153,6 +209,7 @@ ActiveRecord::Schema.define(:version => 20111011200645) do t.datetime "updated_at" t.string "nickname" t.text "ssh_key" + t.string "uname" end add_index "users", ["email"], :name => "index_users_on_email", :unique => true diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb new file mode 100644 index 000000000..8f2de370f --- /dev/null +++ b/spec/models/group_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Group do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/permission_spec.rb b/spec/models/permission_spec.rb new file mode 100644 index 000000000..60a42775b --- /dev/null +++ b/spec/models/permission_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Permission do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/project_to_repository_spec.rb b/spec/models/project_to_repository_spec.rb new file mode 100644 index 000000000..f908dee57 --- /dev/null +++ b/spec/models/project_to_repository_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ProjectToRepository do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/relation_spec.rb b/spec/models/relation_spec.rb new file mode 100644 index 000000000..da5c5a4ff --- /dev/null +++ b/spec/models/relation_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Relation do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/right_spec.rb b/spec/models/right_spec.rb new file mode 100644 index 000000000..d866fdc4f --- /dev/null +++ b/spec/models/right_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Right do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb new file mode 100644 index 000000000..b575576c3 --- /dev/null +++ b/spec/models/role_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Role do + pending "add some examples to (or delete) #{__FILE__}" +end