Issue #82 - Add owner to project
This commit is contained in:
parent
819818ad74
commit
9840102651
7 changed files with 15 additions and 3 deletions
|
@ -87,6 +87,7 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@project = Project.new(params[:project])
|
@project = Project.new(params[:project])
|
||||||
|
@project.owner = current_user
|
||||||
|
|
||||||
Project.transaction do
|
Project.transaction do
|
||||||
@project.save!
|
@project.save!
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Project < ActiveRecord::Base
|
||||||
has_many :issues, :dependent => :destroy
|
has_many :issues, :dependent => :destroy
|
||||||
has_many :users_projects, :dependent => :destroy
|
has_many :users_projects, :dependent => :destroy
|
||||||
has_many :users, :through => :users_projects
|
has_many :users, :through => :users_projects
|
||||||
|
belongs_to :owner, :class_name => "User"
|
||||||
has_many :notes, :dependent => :destroy
|
has_many :notes, :dependent => :destroy
|
||||||
|
|
||||||
validates :name,
|
validates :name,
|
||||||
|
@ -28,7 +29,7 @@ class Project < ActiveRecord::Base
|
||||||
after_destroy :destroy_gitosis_project
|
after_destroy :destroy_gitosis_project
|
||||||
after_save :update_gitosis_project
|
after_save :update_gitosis_project
|
||||||
|
|
||||||
attr_protected :private_flag
|
attr_protected :private_flag, :owner_id
|
||||||
|
|
||||||
scope :public_only, where(:private_flag => false)
|
scope :public_only, where(:private_flag => false)
|
||||||
|
|
||||||
|
@ -44,7 +45,6 @@ class Project < ActiveRecord::Base
|
||||||
read_attribute(:code).downcase.strip.gsub(' ', '')
|
read_attribute(:code).downcase.strip.gsub(' ', '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def update_gitosis_project
|
def update_gitosis_project
|
||||||
Gitosis.new.configure do |c|
|
Gitosis.new.configure do |c|
|
||||||
c.update_project(path, gitosis_writers)
|
c.update_project(path, gitosis_writers)
|
||||||
|
@ -145,5 +145,6 @@ end
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# private_flag :boolean default(TRUE), not null
|
# private_flag :boolean default(TRUE), not null
|
||||||
# code :string(255)
|
# code :string(255)
|
||||||
|
# owner_id :integer
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :users_projects, :dependent => :destroy
|
has_many :users_projects, :dependent => :destroy
|
||||||
has_many :projects, :through => :users_projects
|
has_many :projects, :through => :users_projects
|
||||||
|
has_many :my_own_projects, :class_name => "Project", :foreign_key => :owner_id
|
||||||
has_many :keys, :dependent => :destroy
|
has_many :keys, :dependent => :destroy
|
||||||
has_many :issues,
|
has_many :issues,
|
||||||
:foreign_key => :author_id,
|
:foreign_key => :author_id,
|
||||||
|
@ -48,5 +49,6 @@ end
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# name :string(255)
|
# name :string(255)
|
||||||
# admin :boolean default(FALSE), not null
|
# admin :boolean default(FALSE), not null
|
||||||
|
# allowed_create_repo :boolean default(TRUE), not null
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
5
db/migrate/20111009101738_add_ownerto_project.rb
Normal file
5
db/migrate/20111009101738_add_ownerto_project.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddOwnertoProject < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :projects, :owner_id, :integer
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,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 => 20111005193700) do
|
ActiveRecord::Schema.define(:version => 20111009101738) do
|
||||||
|
|
||||||
create_table "issues", :force => true do |t|
|
create_table "issues", :force => true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
@ -52,6 +52,7 @@ ActiveRecord::Schema.define(:version => 20111005193700) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.boolean "private_flag", :default => true, :null => false
|
t.boolean "private_flag", :default => true, :null => false
|
||||||
t.string "code"
|
t.string "code"
|
||||||
|
t.integer "owner_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", :force => true do |t|
|
create_table "users", :force => true do |t|
|
||||||
|
|
|
@ -122,5 +122,6 @@ end
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# private_flag :boolean default(TRUE), not null
|
# private_flag :boolean default(TRUE), not null
|
||||||
# code :string(255)
|
# code :string(255)
|
||||||
|
# owner_id :integer
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -38,5 +38,6 @@ end
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# name :string(255)
|
# name :string(255)
|
||||||
# admin :boolean default(FALSE), not null
|
# admin :boolean default(FALSE), not null
|
||||||
|
# allowed_create_repo :boolean default(TRUE), not null
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue