From: Frank Brehm Date: Fri, 28 Mar 2008 14:35:36 +0000 (+0000) Subject: Speicherung des Autors komplett X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=b92bfada5e7356f5e6e3ba8e3d6b5d431a2c49aa;p=books.git Speicherung des Autors komplett --- diff --git a/lib/FrBr/Books/Controller/Autor.pm b/lib/FrBr/Books/Controller/Autor.pm index 947432c..622865f 100644 --- a/lib/FrBr/Books/Controller/Autor.pm +++ b/lib/FrBr/Books/Controller/Autor.pm @@ -115,10 +115,11 @@ sub form_new : Path('new') { $self->autor_session2stash($c); $c->stash->{'autor_edit'}{'name'} = "Neuer Autor" unless $c->stash->{'autor_edit'}{'name'}; + $c->stash->{'return_target_autor_save'} = $c->session->{'return_target_autor_save'} || $c->web_path('/autor'); + return 1 unless $c->request->params->{'autor_form_sent'} and $c->request->params->{'do_save'}; - return 1 unless $self->check_formparams($c); - return 1; + return $self->save_author($c); } @@ -129,7 +130,21 @@ sub save_author : Private { my ( $self, $c ) = @_; my $K = __PACKAGE__ . "::save_author(): "; - + return 1 unless $self->check_formparams($c); + + eval { + die "Speichern des Autors misslungen." unless save_autor( $c, $c->stash->{'autor_edit'} ); + }; + if ( $@ ) { + $c->stash->{'error_message'} = $@; + return undef; + } + + $c->stash->{'template'} = 'autor/save_success.tt2'; + delete $c->session->{'autor_data_edit'} if exists $c->session->{'autor_data_edit'}; + delete $c->session->{'return_target_autor_save'} if exists $c->session->{'return_target_autor_save'}; + + return 1; } @@ -179,6 +194,8 @@ sub autor_cgi2session : Private { return 1 unless $c->request->params->{'autor_form_sent'}; + $c->session->{'return_target_autor_save'} = $c->request->params->{'return_target_form'} if $c->request->params->{'return_target_form'}; + # Basis anlegen, wenn notwendig $c->session->{'autor_data_edit'} = {} unless $c->session->{'autor_data_edit'}; diff --git a/lib/FrBr/Books/Controller/Books.pm b/lib/FrBr/Books/Controller/Books.pm index 7c01385..17fbc67 100644 --- a/lib/FrBr/Books/Controller/Books.pm +++ b/lib/FrBr/Books/Controller/Books.pm @@ -143,6 +143,11 @@ sub form_new : Path('new') { $self->bookdata_cgi2session($c); + if ( $c->request->params->{'neuer_autor'} ) { + $c->session->{'return_target_autor_save'} = $c->stash->{'self_url'}; + $c->detach('/autor/form_new'); + } + $c->stash->{'book_edit'} = {} unless $c->stash->{'book_edit'}; $self->bookdata_session2stash($c); $c->stash->{'book_edit'}{'title'} = "Neues Buch" unless $c->stash->{'book_edit'}{'title'}; diff --git a/lib/FrBr/Books/Util/Author.pm b/lib/FrBr/Books/Util/Author.pm index d9624bc..4e2655c 100644 --- a/lib/FrBr/Books/Util/Author.pm +++ b/lib/FrBr/Books/Util/Author.pm @@ -130,6 +130,7 @@ sub save_autor { my $save_func = sub { my ( $storage, $dbh, $autor_id, $name, $desc ) = @_; + $desc = '' unless defined $desc; my $sql = <debug() ) { my $text = $sql; $text =~ s/\s+$//; - $text .= ": " . join( ", ", map { $dbh->quote($_) } ( $uid, $ptype_id, $value, $value ) ) . "\n"; + $text .= ": " . join( ", ", map { $dbh->quote($_) } ( $autor_id, $name, $desc, $name, $desc ) ) . "\n"; warn $text; } diff --git a/root/src/autor/new.tt2 b/root/src/autor/new.tt2 index bb27468..c52fbd4 100644 --- a/root/src/autor/new.tt2 +++ b/root/src/autor/new.tt2 @@ -9,5 +9,5 @@ [% PROCESS autor/autor_form.tt2 %] diff --git a/root/src/autor/save_success.tt2 b/root/src/autor/save_success.tt2 new file mode 100644 index 0000000..0024240 --- /dev/null +++ b/root/src/autor/save_success.tt2 @@ -0,0 +1,15 @@ +[%# + + index.tt2 - Template fuer erfolgreiches Speichern des Autors + + #$Id$ + #$URL$ + +-%] +
+ +Der Autor "[% autor_edit.name %] wurde erfolgreich gespeichert. + +

OK

+ +
diff --git a/root/src/books/book_form.tt2 b/root/src/books/book_form.tt2 index 4561da3..5995377 100644 --- a/root/src/books/book_form.tt2 +++ b/root/src/books/book_form.tt2 @@ -5,7 +5,18 @@ $URL$ -%] + + + +
[%- IF book_edit.id %][% END %] @@ -29,7 +40,7 @@ [% END %]



-

+



@@ -49,10 +60,10 @@ Verlag: - [% FOR verlagsid IN verlags_ids %] [% END %] -   +   Kategorie(n): @@ -67,7 +78,7 @@ [% END %]

-

+



-

+