diff options
| author | Alban Peignier | 2018-05-10 21:39:38 +0200 |
|---|---|---|
| committer | GitHub | 2018-05-10 21:39:38 +0200 |
| commit | 093599f1c2e75ba2a4e3e9e8a6aa2cf665919886 (patch) | |
| tree | d6488fa756d37198f0b50c93e7ddf8e23d3ee46e /app/controllers | |
| parent | fdde7e05c29738356abe488a1b80ade098ef269d (diff) | |
| parent | 6f624a7ca68600e93aae71f98182dfeb8c082674 (diff) | |
| download | chouette-core-093599f1c2e75ba2a4e3e9e8a6aa2cf665919886.tar.bz2 | |
Merge pull request #558 from af83/6960-workgroup-edition
Workgroup edition. Fixes #6960
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/import_resources_controller.rb | 9 | ||||
| -rw-r--r-- | app/controllers/imports_controller.rb | 9 | ||||
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/workgroups_controller.rb | 13 |
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 |
