Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
817b9d1b
Commit
817b9d1b
authored
Aug 20, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refactor/access_roles' of /home/git/repositories/gitlab/gitlabhq
parents
d04ad4cb
7a26a4b6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
53 deletions
+66
-53
app/models/project.rb
app/models/project.rb
+0
-9
app/models/users_group.rb
app/models/users_group.rb
+4
-15
app/models/users_project.rb
app/models/users_project.rb
+6
-22
app/services/system_hooks_service.rb
app/services/system_hooks_service.rb
+1
-1
app/views/admin/projects/show.html.haml
app/views/admin/projects/show.html.haml
+3
-2
app/views/notify/project_access_granted_email.html.haml
app/views/notify/project_access_granted_email.html.haml
+1
-1
app/views/notify/project_access_granted_email.text.erb
app/views/notify/project_access_granted_email.text.erb
+1
-1
app/views/projects/team_members/_form.html.haml
app/views/projects/team_members/_form.html.haml
+1
-1
lib/gitlab/access.rb
lib/gitlab/access.rb
+48
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
817b9d1b
...
@@ -133,10 +133,6 @@ class Project < ActiveRecord::Base
...
@@ -133,10 +133,6 @@ class Project < ActiveRecord::Base
where
(
path:
id
,
namespace_id:
nil
).
last
where
(
path:
id
,
namespace_id:
nil
).
last
end
end
end
end
def
access_options
UsersProject
.
access_roles
end
end
end
def
team
def
team
...
@@ -399,11 +395,6 @@ class Project < ActiveRecord::Base
...
@@ -399,11 +395,6 @@ class Project < ActiveRecord::Base
http_url
=
[
Gitlab
.
config
.
gitlab
.
url
,
"/"
,
path_with_namespace
,
".git"
].
join
(
''
)
http_url
=
[
Gitlab
.
config
.
gitlab
.
url
,
"/"
,
path_with_namespace
,
".git"
].
join
(
''
)
end
end
def
project_access_human
(
member
)
project_user_relation
=
self
.
users_projects
.
find_by_user_id
(
member
.
id
)
self
.
class
.
access_options
.
key
(
project_user_relation
.
project_access
)
end
# Check if current branch name is marked as protected in the system
# Check if current branch name is marked as protected in the system
def
protected_branch?
branch_name
def
protected_branch?
branch_name
protected_branches_names
.
include?
(
branch_name
)
protected_branches_names
.
include?
(
branch_name
)
...
...
app/models/users_group.rb
View file @
817b9d1b
...
@@ -12,21 +12,10 @@
...
@@ -12,21 +12,10 @@
class
UsersGroup
<
ActiveRecord
::
Base
class
UsersGroup
<
ActiveRecord
::
Base
include
Notifiable
include
Notifiable
include
Gitlab
::
Access
GUEST
=
10
REPORTER
=
20
DEVELOPER
=
30
MASTER
=
40
OWNER
=
50
def
self
.
group_access_roles
def
self
.
group_access_roles
{
Gitlab
::
Access
.
options_with_owner
"Guest"
=>
GUEST
,
"Reporter"
=>
REPORTER
,
"Developer"
=>
DEVELOPER
,
"Master"
=>
MASTER
,
"Owner"
=>
OWNER
}
end
end
attr_accessible
:group_access
,
:user_id
attr_accessible
:group_access
,
:user_id
...
@@ -50,7 +39,7 @@ class UsersGroup < ActiveRecord::Base
...
@@ -50,7 +39,7 @@ class UsersGroup < ActiveRecord::Base
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
def
human_access
def
access_field
UsersGroup
.
group_access_roles
.
key
(
self
.
group_access
)
group_access
end
end
end
end
app/models/users_project.rb
View file @
817b9d1b
...
@@ -14,11 +14,7 @@
...
@@ -14,11 +14,7 @@
class
UsersProject
<
ActiveRecord
::
Base
class
UsersProject
<
ActiveRecord
::
Base
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
include
Notifiable
include
Notifiable
include
Gitlab
::
Access
GUEST
=
10
REPORTER
=
20
DEVELOPER
=
30
MASTER
=
40
attr_accessible
:user
,
:user_id
,
:project_access
attr_accessible
:user
,
:user_id
,
:project_access
...
@@ -27,7 +23,7 @@ class UsersProject < ActiveRecord::Base
...
@@ -27,7 +23,7 @@ class UsersProject < ActiveRecord::Base
validates
:user
,
presence:
true
validates
:user
,
presence:
true
validates
:user_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:user_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:project_access
,
inclusion:
{
in:
[
GUEST
,
REPORTER
,
DEVELOPER
,
MASTER
]
},
presence:
true
validates
:project_access
,
inclusion:
{
in:
Gitlab
::
Access
.
values
},
presence:
true
validates
:project
,
presence:
true
validates
:project
,
presence:
true
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
...
@@ -103,27 +99,15 @@ class UsersProject < ActiveRecord::Base
...
@@ -103,27 +99,15 @@ class UsersProject < ActiveRecord::Base
end
end
def
roles_hash
def
roles_hash
{
Gitlab
::
Access
.
sym_options
guest:
GUEST
,
reporter:
REPORTER
,
developer:
DEVELOPER
,
master:
MASTER
}
end
end
def
access_roles
def
access_roles
{
Gitlab
::
Access
.
options
"Guest"
=>
GUEST
,
"Reporter"
=>
REPORTER
,
"Developer"
=>
DEVELOPER
,
"Master"
=>
MASTER
}
end
end
end
end
def
project_access_human
def
access_field
Project
.
access_options
.
key
(
self
.
project_access
)
project_access
end
end
alias_method
:human_access
,
:project_access_human
end
end
app/services/system_hooks_service.rb
View file @
817b9d1b
...
@@ -43,7 +43,7 @@ class SystemHooksService
...
@@ -43,7 +43,7 @@ class SystemHooksService
project_id:
model
.
project_id
,
project_id:
model
.
project_id
,
user_name:
model
.
user
.
name
,
user_name:
model
.
user
.
name
,
user_email:
model
.
user
.
email
,
user_email:
model
.
user
.
email
,
project_access:
model
.
project_access_human
project_access:
model
.
human_access
})
})
end
end
end
end
...
...
app/views/admin/projects/show.html.haml
View file @
817b9d1b
...
@@ -96,11 +96,12 @@
...
@@ -96,11 +96,12 @@
%i
.icon-edit
%i
.icon-edit
Manage Access
Manage Access
%ul
.well-list.team_members
%ul
.well-list.team_members
-
@project
.
users
.
each
do
|
user
|
-
@project
.
users_projects
.
each
do
|
users_project
|
-
user
=
users_project
.
user
%li
%li
%strong
%strong
=
link_to
user
.
name
,
admin_user_path
(
user
)
=
link_to
user
.
name
,
admin_user_path
(
user
)
.pull-right
.pull-right
%span
.light
=
@project
.
project_access_human
(
user
)
%span
.light
=
users_project
.
human_access
=
link_to
admin_project_member_path
(
@project
,
user
),
confirm:
remove_from_project_team_message
(
@project
,
user
),
method: :delete
,
class:
"btn btn-small btn-remove"
do
=
link_to
admin_project_member_path
(
@project
,
user
),
confirm:
remove_from_project_team_message
(
@project
,
user
),
method: :delete
,
class:
"btn btn-small btn-remove"
do
%i
.icon-remove
%i
.icon-remove
app/views/notify/project_access_granted_email.html.haml
View file @
817b9d1b
%p
%p
=
"You have been granted
#{
@users_project
.
project_access_human
}
access to project"
=
"You have been granted
#{
@users_project
.
human_access
}
access to project"
%p
%p
=
link_to
project_url
(
@project
)
do
=
link_to
project_url
(
@project
)
do
=
@project
.
name_with_namespace
=
@project
.
name_with_namespace
app/views/notify/project_access_granted_email.text.erb
View file @
817b9d1b
You have been granted
<%=
@users_project
.
project_access_human
%>
access to project
<%=
@project
.
name_with_namespace
%>
You have been granted
<%=
@users_project
.
human_access
%>
access to project
<%=
@project
.
name_with_namespace
%>
<%=
url_for
(
project_url
(
@project
))
%>
<%=
url_for
(
project_url
(
@project
))
%>
app/views/projects/team_members/_form.html.haml
View file @
817b9d1b
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
%h6
2. Set access level for them
%h6
2. Set access level for them
.control-group
.control-group
=
f
.
label
:project_access
,
"Project Access"
=
f
.
label
:project_access
,
"Project Access"
.controls
=
select_tag
:project_access
,
options_for_select
(
Project
.
access_
options
,
@user_project_relation
.
project_access
),
class:
"project-access-select chosen"
.controls
=
select_tag
:project_access
,
options_for_select
(
Gitlab
::
Access
.
options
,
@user_project_relation
.
project_access
),
class:
"project-access-select chosen"
.form-actions
.form-actions
=
f
.
submit
'Add users'
,
class:
"btn btn-create"
=
f
.
submit
'Add users'
,
class:
"btn btn-create"
...
...
lib/gitlab/access.rb
0 → 100644
View file @
817b9d1b
# Gitlab::Access module
#
# Define allowed roles that can be used
# in GitLab code to determine authorization level
#
module
Gitlab
module
Access
GUEST
=
10
REPORTER
=
20
DEVELOPER
=
30
MASTER
=
40
OWNER
=
50
class
<<
self
def
values
options
.
values
end
def
options
{
"Guest"
=>
GUEST
,
"Reporter"
=>
REPORTER
,
"Developer"
=>
DEVELOPER
,
"Master"
=>
MASTER
,
}
end
def
options_with_owner
options
.
merge
(
"Owner"
=>
OWNER
)
end
def
sym_options
{
guest:
GUEST
,
reporter:
REPORTER
,
developer:
DEVELOPER
,
master:
MASTER
,
}
end
end
def
human_access
Gitlab
::
Access
.
options_with_owner
.
key
(
access_field
)
end
end
end
spec/mailers/notify_spec.rb
View file @
817b9d1b
...
@@ -250,7 +250,7 @@ describe Notify do
...
@@ -250,7 +250,7 @@ describe Notify do
should
have_body_text
/
#{
project
.
name
}
/
should
have_body_text
/
#{
project
.
name
}
/
end
end
it
'contains new user role'
do
it
'contains new user role'
do
should
have_body_text
/
#{
users_project
.
project_access_human
}
/
should
have_body_text
/
#{
users_project
.
human_access
}
/
end
end
end
end
...
...
Write
Preview
Markdown
is supported
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