diff options
author | Nick Thomas <nick@gitlab.com> | 2017-06-19 21:45:28 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-06-21 12:33:17 +0300 |
commit | ddef87b7b6a282c0846d95a9f094dcca62b709d5 (patch) | |
tree | d750fd63f73c825c637bae3468c9e77136ec3393 /app/controllers | |
parent | 3863e46bf6cb89f50904645b1db2c46430b43c6d (diff) |
Namespace license checks for exporting issues (EES)
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/ee/projects/issues_controller.rb | 18 | ||||
-rw-r--r-- | app/controllers/projects/application_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 9 |
3 files changed, 28 insertions, 8 deletions
diff --git a/app/controllers/ee/projects/issues_controller.rb b/app/controllers/ee/projects/issues_controller.rb new file mode 100644 index 00000000000..4b166e038bf --- /dev/null +++ b/app/controllers/ee/projects/issues_controller.rb @@ -0,0 +1,18 @@ +module EE + module Projects + module IssuesController + extend ActiveSupport::Concern + + included do + before_action :check_export_issues_available!, only: [:export_csv] + end + + def export_csv + ExportCsvWorker.perform_async(current_user.id, project.id, filter_params) + + index_path = namespace_project_issues_path(project.namespace, project) + redirect_to(index_path, notice: "Your CSV export has started. It will be emailed to #{current_user.notification_email} when complete.") + end + end + end +end diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 603a51266da..dff48dda351 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -53,9 +53,16 @@ class Projects::ApplicationController < ApplicationController end end + def check_project_feature_available!(feature) + render_404 unless project.feature_available?(feature, current_user) + end + def method_missing(method_sym, *arguments, &block) - if method_sym.to_s =~ /\Aauthorize_(.*)!\z/ + case method_sym.to_s + when /\Aauthorize_(.*)!\z/ authorize_action!($1.to_sym) + when /\Acheck_(.*)_available!\z/ + check_project_feature_available!($1.to_sym) else super end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 4c2f414e376..81f131a792c 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -6,6 +6,8 @@ class Projects::IssuesController < Projects::ApplicationController include IssuableCollections include SpammableActions + include ::EE::Projects::IssuesController + prepend_before_action :authenticate_user!, only: [:new, :export_csv] before_action :redirect_to_external_issue_tracker, only: [:index, :new] @@ -156,13 +158,6 @@ class Projects::IssuesController < Projects::ApplicationController render_conflict_response end - def export_csv - ExportCsvWorker.perform_async(@current_user.id, @project.id, filter_params) - - index_path = namespace_project_issues_path(@project.namespace, @project) - redirect_to(index_path, notice: "Your CSV export has started. It will be emailed to #{current_user.notification_email} when complete.") - end - def referenced_merge_requests @merge_requests = @issue.referenced_merge_requests(current_user) @closed_by_merge_requests = @issue.closed_by_merge_requests(current_user) |