Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
98401026
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
98401026
编写于
10月 09, 2011
作者:
V
Valera Sizov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue #82 - Add owner to project
上级
819818ad
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
15 addition
and
3 deletion
+15
-3
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
app/models/project.rb
app/models/project.rb
+3
-2
app/models/user.rb
app/models/user.rb
+2
-0
db/migrate/20111009101738_add_ownerto_project.rb
db/migrate/20111009101738_add_ownerto_project.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-0
未找到文件。
app/controllers/projects_controller.rb
浏览文件 @
98401026
...
...
@@ -87,6 +87,7 @@ class ProjectsController < ApplicationController
def
create
@project
=
Project
.
new
(
params
[
:project
])
@project
.
owner
=
current_user
Project
.
transaction
do
@project
.
save!
...
...
app/models/project.rb
浏览文件 @
98401026
...
...
@@ -4,6 +4,7 @@ class Project < ActiveRecord::Base
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 @@ class Project < ActiveRecord::Base
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 @@ class Project < ActiveRecord::Base
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 @@ end
# updated_at :datetime
# private_flag :boolean default(TRUE), not null
# code :string(255)
# owner_id :integer
#
app/models/user.rb
浏览文件 @
98401026
...
...
@@ -9,6 +9,7 @@ class User < ActiveRecord::Base
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 @@ end
# 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
浏览文件 @
98401026
class
AddOwnertoProject
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:owner_id
,
:integer
end
end
db/schema.rb
浏览文件 @
98401026
...
...
@@ -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 @@ ActiveRecord::Schema.define(:version => 20111005193700) do
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
浏览文件 @
98401026
...
...
@@ -122,5 +122,6 @@ end
# updated_at :datetime
# private_flag :boolean default(TRUE), not null
# code :string(255)
# owner_id :integer
#
spec/models/user_spec.rb
浏览文件 @
98401026
...
...
@@ -38,5 +38,6 @@ end
# updated_at :datetime
# name :string(255)
# admin :boolean default(FALSE), not null
# allowed_create_repo :boolean default(TRUE), not null
#
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录