From 4b26e2437f1ea0d13980a1847cbfbfbd133cae2f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 30 Oct 2012 17:23:58 +0100 Subject: [PATCH] CsvImportProfiles an den erstellenden Benutzer gebunden --- SL/Controller/CsvImport.pm | 23 ++++++++++++++--------- SL/DB/MetaSetup/CsvImportProfile.pm | 1 + sql/Pg-upgrade2/csv_import_profiles_2.sql | 6 ++++++ 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 sql/Pg-upgrade2/csv_import_profiles_2.sql diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index 99f53c0bd..34b794fdb 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -53,7 +53,7 @@ sub action_import { sub action_save { my ($self) = @_; - $self->profile_from_form(SL::DB::Manager::CsvImportProfile->find_by(name => $::form->{profile}->{name})); + $self->profile_from_form(SL::DB::Manager::CsvImportProfile->find_by(name => $::form->{profile}->{name}, login => $::myconfig{login})); $self->profile->save; flash_later('info', $::locale->text("The profile has been saved under the name '#1'.", $self->profile->name)); @@ -63,7 +63,7 @@ sub action_save { sub action_destroy { my $self = shift; - my $profile = SL::DB::CsvImportProfile->new(id => $::form->{profile}->{id}); + my $profile = SL::DB::CsvImportProfile->new(id => $::form->{profile}->{id}, login => $::myconfig{login}); $profile->delete(cascade => 1); flash_later('info', $::locale->text('The profile \'#1\' has been deleted.', $profile->name)); @@ -193,21 +193,26 @@ sub test_and_import { sub load_default_profile { my ($self) = @_; + my $profile; if ($::form->{profile}->{id}) { - $self->profile(SL::DB::CsvImportProfile->new(id => $::form->{profile}->{id})->load); - - } else { - $self->profile(SL::DB::Manager::CsvImportProfile->find_by(type => $self->{type}, is_default => 1)); - $self->profile(SL::DB::CsvImportProfile->new(type => $self->{type})) unless $self->profile; + $profile = SL::DB::Manager::CsvImportProfile->find_by(id => $::form->{profile}->{id}, login => $::myconfig{login}); } + $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}); + $self->profile($profile); $self->profile->set_defaults; } sub load_all_profiles { my ($self, %params) = @_; - $self->all_profiles(SL::DB::Manager::CsvImportProfile->get_all(where => [ type => $self->type ], sort_by => 'name')); + $self->all_profiles(SL::DB::Manager::CsvImportProfile->get_all( + where => [ + type => $self->type, + login => $::myconfig{login}, + ], + sort_by => 'name')); } sub profile_from_form { @@ -230,7 +235,7 @@ sub profile_from_form { } delete $::form->{profile}->{id}; - $self->profile($existing_profile || SL::DB::CsvImportProfile->new); + $self->profile($existing_profile || SL::DB::CsvImportProfile->new(login => $::myconfig{login})); $self->profile->assign_attributes(%{ $::form->{profile} }); $self->profile->settings(map({ { key => $_, value => $::form->{settings}->{$_} } } keys %{ $::form->{settings} }), @settings); diff --git a/SL/DB/MetaSetup/CsvImportProfile.pm b/SL/DB/MetaSetup/CsvImportProfile.pm index 0acc97d94..fb0d3da8e 100644 --- a/SL/DB/MetaSetup/CsvImportProfile.pm +++ b/SL/DB/MetaSetup/CsvImportProfile.pm @@ -14,6 +14,7 @@ __PACKAGE__->meta->setup( name => { type => 'text', not_null => 1 }, type => { type => 'varchar', length => 20, not_null => 1 }, is_default => { type => 'boolean', default => 'false' }, + login => { type => 'text' }, ], primary_key_columns => [ 'id' ], diff --git a/sql/Pg-upgrade2/csv_import_profiles_2.sql b/sql/Pg-upgrade2/csv_import_profiles_2.sql new file mode 100644 index 000000000..efe2dd46f --- /dev/null +++ b/sql/Pg-upgrade2/csv_import_profiles_2.sql @@ -0,0 +1,6 @@ +-- @tag: csv_import_profiles_2 +-- @description: Tempflag in CSV-Import-Profilen +-- @depends: csv_import_profiles +-- @charset: utf-8 + +ALTER TABLE csv_import_profiles ADD COLUMN login TEXT; -- 2.20.1