From 6261d6ca23a2943f691d45ae6944da1a37eb7867 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Thu, 15 Sep 2016 19:01:12 +0200 Subject: [PATCH] =?utf8?q?Spezifisches=20Recht=20f=C3=BCr=20CSV-Import?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Da immer mehr Bewegungsdaten per CSV-Import eingelesen werden, ist es sinnvoll, dies ohne 'config' Recht durchführen zu können. In diesem Falle sind default Import-Profile vorzuhalten, da die Nutzer dann keine Anpassungen machen dürfen. Die Default Profile haben das flag is_default gesetzt und als login "default" eingetragen. Zur Übergabe dieses Rechts dient der neue Parameter csv_import_access, der entsprechend weiterzugeben ist. Diese Änderung wird erstmalig für den MT940 Bankimport eingesetzt Voraussetzung für #5193.1 --- SL/Controller/CsvImport.pm | 12 +++++++++--- SL/DB/CsvImportProfile.pm | 1 - templates/webpages/csv_import/_deferred_report.html | 2 +- templates/webpages/csv_import/_deferred_results.html | 1 + templates/webpages/csv_import/form.html | 6 ++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index 86cecfe57..3c925abdd 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -32,6 +32,7 @@ use parent qw(SL::Controller::Base); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen all_units + csv_import_access import_status errors headers raw_data_headers info_headers data num_importable displayable_columns file all_taxzones) ], 'scalar --get_set_init' => [ qw(worker task_server num_imported mappings) ], 'array' => [ @@ -98,7 +99,6 @@ sub action_result { my $data = $self->{background_job}->data_as_hash; my $profile = SL::DB::Manager::CsvImportProfile->find_by(id => $data->{profile_id}); - $self->profile($profile); if ($data->{errors} and my $first_error = $data->{errors}->[0]) { @@ -267,7 +267,13 @@ sub action_add_mapping_from_upload { # sub check_auth { - $::auth->assert('config'); + my ($self) = @_; + if ( $::form->{csv_import_access} ) { + $self->csv_import_access($::form->{csv_import_access}); + return $::auth->assert($self->csv_import_access); + } else { + return $::auth->assert('config'); + } } sub check_type { @@ -414,7 +420,7 @@ sub load_default_profile { my $profile; if ($::form->{profile}->{id}) { - $profile = SL::DB::Manager::CsvImportProfile->find_by(id => $::form->{profile}->{id}, login => $::myconfig{login}); + $profile = SL::DB::Manager::CsvImportProfile->find_by(id => $::form->{profile}->{id}); } $profile ||= SL::DB::Manager::CsvImportProfile->find_by(type => $self->{type}, is_default => 1, login => $::myconfig{login}); $profile ||= SL::DB::CsvImportProfile->new(type => $self->{type}, login => $::myconfig{login}); diff --git a/SL/DB/CsvImportProfile.pm b/SL/DB/CsvImportProfile.pm index 922ab7afb..bf11279d1 100644 --- a/SL/DB/CsvImportProfile.pm +++ b/SL/DB/CsvImportProfile.pm @@ -85,7 +85,6 @@ sub clone_and_reset_deep { $clone->settings(map { $_->clone_and_reset } $self->settings); $clone->is_default(0); $clone->name(''); - return $clone; } diff --git a/templates/webpages/csv_import/_deferred_report.html b/templates/webpages/csv_import/_deferred_report.html index d4fde0885..4d084321a 100644 --- a/templates/webpages/csv_import/_deferred_report.html +++ b/templates/webpages/csv_import/_deferred_report.html @@ -20,7 +20,7 @@ $(document).ready(function(){ [%- IF SELF.background_job.data_as_hash.report_id %] - get_report('#csv_import_report', 'controller.pl', { action: 'CsvImport/report', 'no_layout': 1, 'id': [% SELF.background_job.data_as_hash.report_id %] }); + get_report('#csv_import_report', 'controller.pl', { action: 'CsvImport/report', 'no_layout': 1, 'id': [% SELF.background_job.data_as_hash.report_id %], 'csv_import_access' : '[% SELF.csv_import_access %]' }); [%- END %] }); diff --git a/templates/webpages/csv_import/_deferred_results.html b/templates/webpages/csv_import/_deferred_results.html index 7f68a32d5..87e913f7d 100644 --- a/templates/webpages/csv_import/_deferred_results.html +++ b/templates/webpages/csv_import/_deferred_results.html @@ -16,6 +16,7 @@ data: { action: 'CsvImport/result', 'profile.type': '[% SELF.profile.type %]', + 'csv_import_access' : '[% SELF.csv_import_access %]', job: '[% SELF.background_job.id %]' }, success: function(data) { $('#results').html(data) }, diff --git a/templates/webpages/csv_import/form.html b/templates/webpages/csv_import/form.html index 9b8fd1a84..f42cdd873 100644 --- a/templates/webpages/csv_import/form.html +++ b/templates/webpages/csv_import/form.html @@ -10,7 +10,12 @@ [% L.hidden_tag('form_sent', '1') %] [% L.hidden_tag('action', 'CsvImport/dispatch') %] [% L.hidden_tag('profile.type', SELF.profile.type) %] + [% L.hidden_tag('csv_import_access', SELF.csv_import_access) %] + [%- IF SELF.csv_import_access %] + [% L.hidden_tag('force_profile', 1) %] + [% L.hidden_tag('profile.id', SELF.profile.id) %] + [%- ELSE %]

[%- LxERP.t8('Import profiles') %]

@@ -323,6 +328,7 @@
+[%- END %] [%- END %] [% L.submit_tag('action_test', LxERP.t8('Test and preview')) %] [% L.submit_tag('action_import', LxERP.t8('Import'), style='display:none') %] -- 2.20.1