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
Jérome Perrin
gitlab-ce
Commits
8e5bf9d8
Commit
8e5bf9d8
authored
Jun 20, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new check_project_feature_available! method in project controllers
parent
03228cb5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
32 deletions
+13
-32
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+6
-1
app/controllers/projects/discussions_controller.rb
app/controllers/projects/discussions_controller.rb
+1
-5
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+2
-2
app/controllers/projects/labels_controller.rb
app/controllers/projects/labels_controller.rb
+1
-7
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-5
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+1
-7
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+1
-5
No files found.
app/controllers/projects/application_controller.rb
View file @
8e5bf9d8
...
...
@@ -54,7 +54,12 @@ class Projects::ApplicationController < ApplicationController
end
def
check_project_feature_available!
(
feature
)
return
render_404
unless
project
.
feature_available?
(
feature
,
current_user
)
render_404
unless
project
.
feature_available?
(
feature
,
current_user
)
end
def
check_issuables_available!
render_404
unless
project
.
feature_available?
(
:issues
,
current_user
)
||
project
.
feature_available?
(
:merge_requests
,
current_user
)
end
def
method_missing
(
method_sym
,
*
arguments
,
&
block
)
...
...
app/controllers/projects/discussions_controller.rb
View file @
8e5bf9d8
class
Projects::DiscussionsController
<
Projects
::
ApplicationController
before_action
:
module_enabled
before_action
:
check_merge_requests_available!
before_action
:merge_request
before_action
:discussion
before_action
:authorize_resolve_discussion!
...
...
@@ -34,8 +34,4 @@ class Projects::DiscussionsController < Projects::ApplicationController
def
authorize_resolve_discussion!
access_denied!
unless
discussion
.
can_resolve?
(
current_user
)
end
def
module_enabled
render_404
unless
@project
.
feature_available?
(
:merge_requests
,
current_user
)
end
end
app/controllers/projects/issues_controller.rb
View file @
8e5bf9d8
...
...
@@ -9,7 +9,7 @@ class Projects::IssuesController < Projects::ApplicationController
prepend_before_action
:authenticate_user!
,
only:
[
:new
]
before_action
:redirect_to_external_issue_tracker
,
only:
[
:index
,
:new
]
before_action
:
module_enabled
before_action
:
check_issues_available!
before_action
:issue
,
except:
[
:index
,
:new
,
:create
,
:bulk_update
]
# Allow write(create) issue
...
...
@@ -250,7 +250,7 @@ class Projects::IssuesController < Projects::ApplicationController
return
render_404
unless
can?
(
current_user
,
:push_code
,
@project
)
&&
@issue
.
can_be_worked_on?
(
current_user
)
end
def
module_enabled
def
check_issues_available!
return
render_404
unless
@project
.
feature_available?
(
:issues
,
current_user
)
&&
@project
.
default_issues_tracker?
end
...
...
app/controllers/projects/labels_controller.rb
View file @
8e5bf9d8
class
Projects::LabelsController
<
Projects
::
ApplicationController
include
ToggleSubscriptionAction
before_action
:
module_enabled
before_action
:
check_issuables_available!
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
,
:promote
]
before_action
:find_labels
,
only:
[
:index
,
:set_priorities
,
:remove_priority
,
:toggle_subscription
]
before_action
:authorize_read_label!
...
...
@@ -135,12 +135,6 @@ class Projects::LabelsController < Projects::ApplicationController
protected
def
module_enabled
unless
@project
.
feature_available?
(
:issues
,
current_user
)
||
@project
.
feature_available?
(
:merge_requests
,
current_user
)
return
render_404
end
end
def
label_params
params
.
require
(
:label
).
permit
(
:title
,
:description
,
:color
)
end
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
8e5bf9d8
...
...
@@ -7,7 +7,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
include
ToggleAwardEmoji
include
IssuableCollections
before_action
:
module_enabled
before_action
:
check_merge_requests_available!
before_action
:merge_request
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:conflicts
,
:conflict_for_path
,
:pipelines
,
:merge
,
:pipeline_status
,
:ci_environments_status
,
:toggle_subscription
,
:cancel_merge_when_pipeline_succeeds
,
:remove_wip
,
:resolve_conflicts
,
:assign_related_issues
,
:commit_change_content
...
...
@@ -461,10 +461,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return
render_404
unless
@conflicts_list
.
can_be_resolved_by?
(
current_user
)
end
def
module_enabled
return
render_404
unless
@project
.
feature_available?
(
:merge_requests
,
current_user
)
end
def
validates_merge_request
# Show git not found page
# if there is no saved commits between source & target branch
...
...
app/controllers/projects/milestones_controller.rb
View file @
8e5bf9d8
class
Projects::MilestonesController
<
Projects
::
ApplicationController
include
MilestoneActions
before_action
:
module_enabled
before_action
:
check_issuables_available!
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:merge_requests
,
:participants
,
:labels
]
# Allow read any milestone
...
...
@@ -95,12 +95,6 @@ class Projects::MilestonesController < Projects::ApplicationController
return
render_404
unless
can?
(
current_user
,
:admin_milestone
,
@project
)
end
def
module_enabled
unless
@project
.
feature_available?
(
:issues
,
current_user
)
||
@project
.
feature_available?
(
:merge_requests
,
current_user
)
return
render_404
end
end
def
milestone_params
params
.
require
(
:milestone
).
permit
(
:title
,
:description
,
:start_date
,
:due_date
,
:state_event
)
end
...
...
app/controllers/projects/snippets_controller.rb
View file @
8e5bf9d8
...
...
@@ -5,7 +5,7 @@ class Projects::SnippetsController < Projects::ApplicationController
include
SnippetsActions
include
RendersBlob
before_action
:
module_enabled
before_action
:
check_snippets_available!
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
,
:toggle_award_emoji
,
:mark_as_spam
]
# Allow read any snippet
...
...
@@ -102,10 +102,6 @@ class Projects::SnippetsController < Projects::ApplicationController
return
render_404
unless
can?
(
current_user
,
:admin_project_snippet
,
@snippet
)
end
def
module_enabled
return
render_404
unless
@project
.
feature_available?
(
:snippets
,
current_user
)
end
def
snippet_params
params
.
require
(
:project_snippet
).
permit
(
:title
,
:content
,
:file_name
,
:private
,
:visibility_level
,
:description
)
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