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
Kazuhiko Shiozaki
gitlab-ce
Commits
e3351287
Commit
e3351287
authored
Mar 25, 2013
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permissions for Project Snippet fixed
parent
033037a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+6
-6
app/views/projects/snippets/index.html.haml
app/views/projects/snippets/index.html.haml
+1
-1
app/views/projects/snippets/show.html.haml
app/views/projects/snippets/show.html.haml
+1
-1
No files found.
app/controllers/projects/snippets_controller.rb
View file @
e3351287
...
...
@@ -3,16 +3,16 @@ class Projects::SnippetsController < Projects::ApplicationController
before_filter
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
# Allow read any snippet
before_filter
:authorize_read_snippet!
before_filter
:authorize_read_
project_
snippet!
# Allow write(create) snippet
before_filter
:authorize_write_snippet!
,
only:
[
:new
,
:create
]
before_filter
:authorize_write_
project_
snippet!
,
only:
[
:new
,
:create
]
# Allow modify snippet
before_filter
:authorize_modify_snippet!
,
only:
[
:edit
,
:update
]
before_filter
:authorize_modify_
project_
snippet!
,
only:
[
:edit
,
:update
]
# Allow destroy snippet
before_filter
:authorize_admin_snippet!
,
only:
[
:destroy
]
before_filter
:authorize_admin_
project_
snippet!
,
only:
[
:destroy
]
layout
'project_resource'
...
...
@@ -80,11 +80,11 @@ class Projects::SnippetsController < Projects::ApplicationController
@snippet
||=
@project
.
snippets
.
find
(
params
[
:id
])
end
def
authorize_modify_snippet!
def
authorize_modify_
project_
snippet!
return
render_404
unless
can?
(
current_user
,
:modify_project_snippet
,
@snippet
)
end
def
authorize_admin_snippet!
def
authorize_admin_
project_
snippet!
return
render_404
unless
can?
(
current_user
,
:admin_project_snippet
,
@snippet
)
end
...
...
app/views/projects/snippets/index.html.haml
View file @
e3351287
...
...
@@ -2,7 +2,7 @@
Snippets
%small
share code pastes with others out of git repository
-
if
can?
current_user
,
:write_snippet
,
@project
-
if
can?
current_user
,
:write_
project_
snippet
,
@project
=
link_to
new_project_snippet_path
(
@project
),
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
Add new snippet
%br
...
...
app/views/projects/snippets/show.html.haml
View file @
e3351287
%h3
.page_title
=
@snippet
.
title
%small
=
@snippet
.
file_name
-
if
can?
(
current_user
,
:admin_snippet
,
@project
)
||
@snippet
.
author
==
current_user
-
if
can?
(
current_user
,
:admin_
project_
snippet
,
@project
)
||
@snippet
.
author
==
current_user
=
link_to
"Edit"
,
edit_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-small pull-right"
,
title:
'Edit Snippet'
%br
...
...
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