Commit 9840102651ac84d2eb7824113a544bf4992e0398
1 parent
819818ad
Exists in
master
and in
4 other branches
Issue #82 - Add owner to project
Showing
7 changed files
with
15 additions
and
3 deletions
Show diff stats
app/controllers/projects_controller.rb
app/models/project.rb
... | ... | @@ -4,6 +4,7 @@ class Project < ActiveRecord::Base |
4 | 4 | has_many :issues, :dependent => :destroy |
5 | 5 | has_many :users_projects, :dependent => :destroy |
6 | 6 | has_many :users, :through => :users_projects |
7 | + belongs_to :owner, :class_name => "User" | |
7 | 8 | has_many :notes, :dependent => :destroy |
8 | 9 | |
9 | 10 | validates :name, |
... | ... | @@ -28,7 +29,7 @@ class Project < ActiveRecord::Base |
28 | 29 | after_destroy :destroy_gitosis_project |
29 | 30 | after_save :update_gitosis_project |
30 | 31 | |
31 | - attr_protected :private_flag | |
32 | + attr_protected :private_flag, :owner_id | |
32 | 33 | |
33 | 34 | scope :public_only, where(:private_flag => false) |
34 | 35 | |
... | ... | @@ -44,7 +45,6 @@ class Project < ActiveRecord::Base |
44 | 45 | read_attribute(:code).downcase.strip.gsub(' ', '') |
45 | 46 | end |
46 | 47 | |
47 | - | |
48 | 48 | def update_gitosis_project |
49 | 49 | Gitosis.new.configure do |c| |
50 | 50 | c.update_project(path, gitosis_writers) |
... | ... | @@ -145,5 +145,6 @@ end |
145 | 145 | # updated_at :datetime |
146 | 146 | # private_flag :boolean default(TRUE), not null |
147 | 147 | # code :string(255) |
148 | +# owner_id :integer | |
148 | 149 | # |
149 | 150 | ... | ... |
app/models/user.rb
... | ... | @@ -9,6 +9,7 @@ class User < ActiveRecord::Base |
9 | 9 | |
10 | 10 | has_many :users_projects, :dependent => :destroy |
11 | 11 | has_many :projects, :through => :users_projects |
12 | + has_many :my_own_projects, :class_name => "Project", :foreign_key => :owner_id | |
12 | 13 | has_many :keys, :dependent => :destroy |
13 | 14 | has_many :issues, |
14 | 15 | :foreign_key => :author_id, |
... | ... | @@ -48,5 +49,6 @@ end |
48 | 49 | # updated_at :datetime |
49 | 50 | # name :string(255) |
50 | 51 | # admin :boolean default(FALSE), not null |
52 | +# allowed_create_repo :boolean default(TRUE), not null | |
51 | 53 | # |
52 | 54 | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20111005193700) do | |
14 | +ActiveRecord::Schema.define(:version => 20111009101738) do | |
15 | 15 | |
16 | 16 | create_table "issues", :force => true do |t| |
17 | 17 | t.string "title" |
... | ... | @@ -52,6 +52,7 @@ ActiveRecord::Schema.define(:version => 20111005193700) do |
52 | 52 | t.datetime "updated_at" |
53 | 53 | t.boolean "private_flag", :default => true, :null => false |
54 | 54 | t.string "code" |
55 | + t.integer "owner_id" | |
55 | 56 | end |
56 | 57 | |
57 | 58 | create_table "users", :force => true do |t| | ... | ... |
spec/models/project_spec.rb