aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/import_resources_controller.rb9
-rw-r--r--app/controllers/imports_controller.rb9
-rw-r--r--app/controllers/workbenches_controller.rb2
-rw-r--r--app/controllers/workgroups_controller.rb13
4 files changed, 31 insertions, 2 deletions
diff --git a/app/controllers/import_resources_controller.rb b/app/controllers/import_resources_controller.rb
index 1535fd171..46f8f0337 100644
--- a/app/controllers/import_resources_controller.rb
+++ b/app/controllers/import_resources_controller.rb
@@ -24,6 +24,15 @@ class ImportResourcesController < ChouetteController
@import_resources ||= parent.resources
end
+ def resource
+ @import ||= Import::Base.find params[:import_id]
+ @import_resource ||= begin
+ import_resource = Import::Resource.find params[:id]
+ raise ActiveRecord::RecordNotFound unless import_resource.import == @import
+ import_resource
+ end
+ end
+
private
def decorate_import_resources(import_resources)
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 8d7a723a0..b98d7da8d 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -4,6 +4,7 @@ class ImportsController < ChouetteController
include IevInterfaces
skip_before_action :authenticate_user!, only: [:download]
defaults resource_class: Import::Base, collection_name: 'imports', instance_name: 'import'
+ before_action :notify_parents
def download
if params[:token] == resource.token_download
@@ -18,7 +19,7 @@ class ImportsController < ChouetteController
def index_model
Import::Workbench
end
-
+
def build_resource
@import ||= Import::Workbench.new(*resource_params) do |import|
import.workbench = parent
@@ -43,4 +44,10 @@ class ImportsController < ChouetteController
}
)
end
+
+ def notify_parents
+ if Rails.env.development?
+ ParentNotifier.new(Import::Base).notify_when_finished
+ end
+ end
end
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 43415ff60..d4dfdebe3 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -42,7 +42,7 @@ class WorkbenchesController < ChouetteController
private
def workbench_params
- params.require(:workbench).permit(:import_compliance_control_set_id, :merge_compliance_control_set_id)
+ params.require(:workbench).permit(compliance_control_set_ids: @workbench.workgroup.compliance_control_sets_by_workbench.keys)
end
def resource
diff --git a/app/controllers/workgroups_controller.rb b/app/controllers/workgroups_controller.rb
new file mode 100644
index 000000000..3acea248d
--- /dev/null
+++ b/app/controllers/workgroups_controller.rb
@@ -0,0 +1,13 @@
+class WorkgroupsController < ChouetteController
+ defaults resource_class: Workgroup
+
+ include PolicyChecker
+
+ def show
+ redirect_to "/"
+ end
+
+ def workgroup_params
+ params[:workgroup].permit(workbenches_attributes: [:id, compliance_control_set_ids: @workgroup.compliance_control_sets_by_workgroup.keys])
+ end
+end