Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
43cfc38d2438
Commit
43cfc38d
authored
Oct 09, 2011
by
Valera Sizov
Browse files
Issue
#82
- Add owner to project
parent
8131f88da612
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/controllers/projects_controller.rb
View file @
43cfc38d
...
...
@@ -87,6 +87,7 @@
def
create
@project
=
Project
.
new
(
params
[
:project
])
@project
.
owner
=
current_user
Project
.
transaction
do
@project
.
save!
...
...
app/models/project.rb
View file @
43cfc38d
...
...
@@ -4,6 +4,7 @@
has_many
:issues
,
:dependent
=>
:destroy
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:users
,
:through
=>
:users_projects
belongs_to
:owner
,
:class_name
=>
"User"
has_many
:notes
,
:dependent
=>
:destroy
validates
:name
,
...
...
@@ -28,7 +29,7 @@
after_destroy
:destroy_gitosis_project
after_save
:update_gitosis_project
attr_protected
:private_flag
attr_protected
:private_flag
,
:owner_id
scope
:public_only
,
where
(
:private_flag
=>
false
)
...
...
@@ -44,7 +45,6 @@
read_attribute
(
:code
).
downcase
.
strip
.
gsub
(
' '
,
''
)
end
def
update_gitosis_project
Gitosis
.
new
.
configure
do
|
c
|
c
.
update_project
(
path
,
gitosis_writers
)
...
...
@@ -145,5 +145,6 @@
# updated_at :datetime
# private_flag :boolean default(TRUE), not null
# code :string(255)
# owner_id :integer
#
app/models/user.rb
View file @
43cfc38d
...
...
@@ -9,6 +9,7 @@
has_many
:users_projects
,
:dependent
=>
:destroy
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
:issues
,
:foreign_key
=>
:author_id
,
...
...
@@ -48,5 +49,6 @@
# updated_at :datetime
# name :string(255)
# admin :boolean default(FALSE), not null
# allowed_create_repo :boolean default(TRUE), not null
#
db/migrate/20111009101738_add_ownerto_project.rb
0 → 100644
View file @
43cfc38d
class
AddOwnertoProject
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:owner_id
,
:integer
end
end
db/schema.rb
View file @
43cfc38d
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
2011100
5193700
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
2011100
9101738
)
do
create_table
"issues"
,
:force
=>
true
do
|
t
|
t
.
string
"title"
...
...
@@ -52,6 +52,7 @@
t
.
datetime
"updated_at"
t
.
boolean
"private_flag"
,
:default
=>
true
,
:null
=>
false
t
.
string
"code"
t
.
integer
"owner_id"
end
create_table
"users"
,
:force
=>
true
do
|
t
|
...
...
spec/models/project_spec.rb
View file @
43cfc38d
...
...
@@ -122,5 +122,6 @@
# updated_at :datetime
# private_flag :boolean default(TRUE), not null
# code :string(255)
# owner_id :integer
#
spec/models/user_spec.rb
View file @
43cfc38d
...
...
@@ -38,5 +38,6 @@
# updated_at :datetime
# name :string(255)
# admin :boolean default(FALSE), not null
# allowed_create_repo :boolean default(TRUE), not null
#
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment