Revision 4b26e243
Von Sven Schöling vor fast 12 Jahren hinzugefügt
SL/Controller/CsvImport.pm | ||
---|---|---|
53 | 53 |
sub action_save { |
54 | 54 |
my ($self) = @_; |
55 | 55 |
|
56 |
$self->profile_from_form(SL::DB::Manager::CsvImportProfile->find_by(name => $::form->{profile}->{name})); |
|
56 |
$self->profile_from_form(SL::DB::Manager::CsvImportProfile->find_by(name => $::form->{profile}->{name}, login => $::myconfig{login}));
|
|
57 | 57 |
$self->profile->save; |
58 | 58 |
|
59 | 59 |
flash_later('info', $::locale->text("The profile has been saved under the name '#1'.", $self->profile->name)); |
... | ... | |
63 | 63 |
sub action_destroy { |
64 | 64 |
my $self = shift; |
65 | 65 |
|
66 |
my $profile = SL::DB::CsvImportProfile->new(id => $::form->{profile}->{id}); |
|
66 |
my $profile = SL::DB::CsvImportProfile->new(id => $::form->{profile}->{id}, login => $::myconfig{login});
|
|
67 | 67 |
$profile->delete(cascade => 1); |
68 | 68 |
|
69 | 69 |
flash_later('info', $::locale->text('The profile \'#1\' has been deleted.', $profile->name)); |
... | ... | |
193 | 193 |
sub load_default_profile { |
194 | 194 |
my ($self) = @_; |
195 | 195 |
|
196 |
my $profile; |
|
196 | 197 |
if ($::form->{profile}->{id}) { |
197 |
$self->profile(SL::DB::CsvImportProfile->new(id => $::form->{profile}->{id})->load); |
|
198 |
|
|
199 |
} else { |
|
200 |
$self->profile(SL::DB::Manager::CsvImportProfile->find_by(type => $self->{type}, is_default => 1)); |
|
201 |
$self->profile(SL::DB::CsvImportProfile->new(type => $self->{type})) unless $self->profile; |
|
198 |
$profile = SL::DB::Manager::CsvImportProfile->find_by(id => $::form->{profile}->{id}, login => $::myconfig{login}); |
|
202 | 199 |
} |
200 |
$profile ||= SL::DB::Manager::CsvImportProfile->find_by(type => $self->{type}, is_default => 1, login => $::myconfig{login}); |
|
201 |
$profile ||= SL::DB::CsvImportProfile->new(type => $self->{type}, login => $::myconfig{login}); |
|
203 | 202 |
|
203 |
$self->profile($profile); |
|
204 | 204 |
$self->profile->set_defaults; |
205 | 205 |
} |
206 | 206 |
|
207 | 207 |
sub load_all_profiles { |
208 | 208 |
my ($self, %params) = @_; |
209 | 209 |
|
210 |
$self->all_profiles(SL::DB::Manager::CsvImportProfile->get_all(where => [ type => $self->type ], sort_by => 'name')); |
|
210 |
$self->all_profiles(SL::DB::Manager::CsvImportProfile->get_all( |
|
211 |
where => [ |
|
212 |
type => $self->type, |
|
213 |
login => $::myconfig{login}, |
|
214 |
], |
|
215 |
sort_by => 'name')); |
|
211 | 216 |
} |
212 | 217 |
|
213 | 218 |
sub profile_from_form { |
... | ... | |
230 | 235 |
} |
231 | 236 |
|
232 | 237 |
delete $::form->{profile}->{id}; |
233 |
$self->profile($existing_profile || SL::DB::CsvImportProfile->new); |
|
238 |
$self->profile($existing_profile || SL::DB::CsvImportProfile->new(login => $::myconfig{login}));
|
|
234 | 239 |
$self->profile->assign_attributes(%{ $::form->{profile} }); |
235 | 240 |
$self->profile->settings(map({ { key => $_, value => $::form->{settings}->{$_} } } keys %{ $::form->{settings} }), |
236 | 241 |
@settings); |
Auch abrufbar als: Unified diff
CsvImportProfiles an den erstellenden Benutzer gebunden