Some libraries would like to have the text version of the serials "published on" field auto-generated from a template. This template should be definable at the subscription level.
Created attachment 147167 [details] [review] Bug 33039: Add ability to specify a template for serial subscription "Published on (text)" field Some libraries would like to have the text version of the serials "published on" field auto-generated from a template. This template should be definable at the subscription level. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Restart all the things! 4) Create or edit a new subscription 5) Edit the "Publication date template", create a template toolkit template. Keys available are the Koha::Subscription object as 'subscription' and the following serial table columns as keys: serialseq serialseq_x serialseq_y serialseq_z subscriptionid biblionumber status planneddate publisheddate publisheddateext notes routingnotes So your example template could be "[% subscription.subscriptionid %] [% biblionumber %]" 6) Generate the next serial 7) Note the next issue has a "Date published (text)" field based on the template you set!
Created attachment 147168 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH]
Created attachment 147173 [details] [review] Bug 33039: Add ability to specify a template for serial subscription "Published on (text)" field Some libraries would like to have the text version of the serials "published on" field auto-generated from a template. This template should be definable at the subscription level. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Restart all the things! 4) Create or edit a new subscription 5) Edit the "Publication date template", create a template toolkit template. Keys available are the Koha::Subscription object as 'subscription' and the following serial table columns as keys: serialseq serialseq_x serialseq_y serialseq_z subscriptionid biblionumber status planneddate publisheddate publisheddateext notes routingnotes So your example template could be "[% subscription.subscriptionid %] [% biblionumber %]" 6) Generate the next serial 7) Note the next issue has a "Date published (text)" field based on the template you set!
Created attachment 147174 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH]
(In reply to Kyle M Hall from comment #3) > Created attachment 147173 [details] [review] [review] > Bug 33039: Add ability to specify a template for serial subscription > "Published on (text)" field > > Some libraries would like to have the text version of the serials > "published on" field auto-generated from a template. This template > should be definable at the subscription level. > > Test Plan: > 1) Apply this patch > 2) Run updatedatabase.pl > 3) Restart all the things! > 4) Create or edit a new subscription > 5) Edit the "Publication date template", create a template toolkit > template. > Keys available are the Koha::Subscription object as 'subscription' > and the following serial table columns as keys: > serialseq > serialseq_x > serialseq_y > serialseq_z > subscriptionid > biblionumber > status > planneddate > publisheddate > publisheddateext > notes > routingnotes > So your example template could be "[% subscription.subscriptionid %] [% > biblionumber %]" > 6) Generate the next serial > 7) Note the next issue has a "Date published (text)" field based on the > template you set! Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 148470 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH] Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 148471 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH] Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 148472 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH] Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 148482 [details] [review] Bug 32924: (follow-up) Add left margin to 'Show mine only' label Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 148534 [details] [review] Bug 33039: Add ability to specify a template for serial subscription "Published on (text)" field Some libraries would like to have the text version of the serials "published on" field auto-generated from a template. This template should be definable at the subscription level. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Restart all the things! 4) Create or edit a new subscription 5) Edit the "Publication date template", create a template toolkit template. Keys available are the Koha::Subscription object as 'subscription' and the following serial table columns as keys: serialseq serialseq_x serialseq_y serialseq_z subscriptionid biblionumber status planneddate publisheddate publisheddateext notes routingnotes So your example template could be "[% subscription.subscriptionid %] [% biblionumber %]" 6) Generate the next serial 7) Note the next issue has a "Date published (text)" field based on the template you set! Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 148535 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH] Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Looking here
+use Carp qw( croak ); Shouldnt we use exceptions now ? PERL26: Koha::Exceptions (Approved on Apr 26, 2017) Instead of die or croak when meeting unfavorable conditions in our code, we should raise exceptions via Koha::Exceptions.
+ if ( index( $template, '[%' ) != -1 ) { # Much faster than regex No problem, but 'much' sounds like exaggerating :) Just in memory.. The variable name could be confusing btw. It is template code. This call worries me: + my $tt = Template->new( + { + EVAL_PERL => 1, + ABSOLUTE => 1, + PLUGIN_BASE => 'Koha::Template::Plugin', + COMPILE_EXT => $use_template_cache ? '.ttc' : '', + COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', + FILTERS => {}, + ENCODING => 'UTF-8', + } + ) or die Template->error(); Would prefer to see calling something central like in C4::Templates or in C4::Letters instead. + $schema->txn_begin; + try { + my $text; + $tt->process( Please explain why a process call would need a transaction. Can we just remove it ? Could generating alternative text via a Koha plugin be easier somehow? And without needing a db revision ? Note that we already have: Koha/Plugins/Base.pm: $args->{'template'} = Template->new( { ABSOLUTE => 1, ENCODING => 'UTF-8' } );
(In reply to Marcel de Rooy from comment #14) > + if ( index( $template, '[%' ) != -1 ) { # Much faster than regex > No problem, but 'much' sounds like exaggerating :) Just in memory.. https://stackoverflow.com/questions/30744379/unanchored-substring-searching-index-vs-regex > > This call worries me: > + my $tt = Template->new( > + { > + EVAL_PERL => 1, > + ABSOLUTE => 1, > + PLUGIN_BASE => 'Koha::Template::Plugin', > + COMPILE_EXT => $use_template_cache ? '.ttc' : '', > + COMPILE_DIR => $use_template_cache ? > C4::Context->config('template_cache_dir') : '', > + FILTERS => {}, > + ENCODING => 'UTF-8', > + } > + ) or die Template->error(); > Would prefer to see calling something central like in C4::Templates or in > C4::Letters instead. Bug 33041 already handles that > > + $schema->txn_begin; > + try { > + my $text; > + $tt->process( > Please explain why a process call would need a transaction. Can we just > remove it ? Please have a look at C4::Letters. This is now standard procedure for template processing. > Could generating alternative text via a Koha plugin be easier somehow? And > without needing a db revision ? > Note that we already have: > Koha/Plugins/Base.pm: $args->{'template'} = Template->new( { ABSOLUTE => > 1, ENCODING => 'UTF-8' } ); That sounds more complicated. If you want to write a POC for that I'd be happy to take a look.
Created attachment 153089 [details] [review] Bug 33039: Add ability to specify a template for serial subscription "Published on (text)" field Some libraries would like to have the text version of the serials "published on" field auto-generated from a template. This template should be definable at the subscription level. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Restart all the things! 4) Create or edit a new subscription 5) Edit the "Publication date template", create a template toolkit template. Keys available are the Koha::Subscription object as 'subscription' and the following serial table columns as keys: serialseq serialseq_x serialseq_y serialseq_z subscriptionid biblionumber status planneddate publisheddate publisheddateext notes routingnotes So your example template could be "[% subscription.subscriptionid %] [% biblionumber %]" 6) Generate the next serial 7) Note the next issue has a "Date published (text)" field based on the template you set! Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 153090 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH] Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Created attachment 153138 [details] [review] Bug 33039: Add ability to specify a template for serial subscription "Published on (text)" field Some libraries would like to have the text version of the serials "published on" field auto-generated from a template. This template should be definable at the subscription level. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Restart all the things! 4) Create or edit a new subscription 5) Edit the "Publication date template", create a template toolkit template. Keys available are the Koha::Subscription object as 'subscription' and the following serial table columns as keys: serialseq serialseq_x serialseq_y serialseq_z subscriptionid biblionumber status planneddate publisheddate publisheddateext notes routingnotes So your example template could be "[% subscription.subscriptionid %] [% biblionumber %]" 6) Generate the next serial 7) Note the next issue has a "Date published (text)" field based on the template you set! Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 153139 [details] [review] Bug 33039: Update Schema File [DO NOT PUSH] Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 23.11. Nice work everyone, thanks!
Enhancement, no backport for 23.05.x series.
*** Bug 31792 has been marked as a duplicate of this bug. ***
Created attachment 164154 [details] Bug 33039: Incorrect date value stored when 'Published on' or 'Expected on' are empty When we edit a serial and we leave the date fields ('Published on' or 'Expected on') empty incorrect date are saved in the database 0000-00-00 instade of current date and we get Error 500 to reproduce 1. Connect to staff interface 2. Go to Serials and create a new subscription 3. Click on Serial collection in the left menu (and note the Subscription numnber) 4. Select a serial to edit and Click on «Edit serials» 5. In the Serial edition form, delete «Published on > and « Expected on » dates and save ----> Error 500 page is displayed 6. Check the value of «Published on > and « Expected on » dates in the database select planneddate,publisheddate from serial where subscriptionid=<Subscription numnber in step 3>; ------> planneddate publisheddate have «0000-00-00» value 7. Apply the patch 8. repeat step 2, 3, 4, 5, 6 -----> Error 500 page is no more displayed -----> «Published on » and « Expected on » field have today date
Please set the status to 'Needs documenting' when there is a new field visible to the user. Thanks! :)