Bug 17971 - TT syntax for notices - Add support for plurals
Summary: TT syntax for notices - Add support for plurals
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 17958 17970
Blocks: 17966 18620
  Show dependency treegraph
 
Reported: 2017-01-23 14:31 UTC by Jonathan Druart
Modified: 2017-12-07 22:16 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 17971: TT syntax for notices - Add support for plurals (6.51 KB, patch)
2017-01-23 15:05 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 17971: Add support for objects represented by fk (3.02 KB, patch)
2017-01-23 15:05 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 17971: TT syntax for notices - Add support for plurals (6.58 KB, patch)
2017-01-24 19:58 UTC, Josef Moravec
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 17971: Add support for objects represented by fk (3.09 KB, patch)
2017-01-24 19:58 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 17971: TT syntax for notices - Add support for plurals (5.71 KB, patch)
2017-03-10 12:32 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 17971: Add support for objects represented by fk (2.98 KB, patch)
2017-03-10 12:32 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 17971: TT syntax for notices - Add support for plurals (5.76 KB, patch)
2017-03-29 20:12 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 17971: Add support for objects represented by fk (3.03 KB, patch)
2017-03-29 20:12 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 17971 (QA Followup) Clarify comment (914 bytes, patch)
2017-03-29 20:12 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2017-01-23 14:31:12 UTC
On of the awesome things we will be able to do with the TT syntax is the support of plurals.

For instance we will be able to send a list of items, checkouts, etc. to the notice template.
That way we will get rid of our custom syntax like <<items.content>> or <item></item> for instance.

The existing code already has the playground for that but it is not used.
Comment 1 Jonathan Druart 2017-01-23 15:05:14 UTC
Created attachment 59426 [details] [review]
Bug 17971: TT syntax for notices - Add support for plurals

On of the awesome things we will be able to do with the TT syntax is the support of plurals.

For instance we will be able to send a list of items, checkouts, etc. to the notice template.
That way we will get rid of our custom syntax like <<items.content>> or <item></item> for instance.

The existing code already has the playground for that but it is not used.

Basically the idea is to add a "loops" key which can contain a list of
object to retrieve from the DB and send to the template.
For instance:
    loops => { overdues => [ $itemnumber_1, .., $itemnumber_N ] }

will send a variable "overdues" to the template. It will contain the
Koha::Checkout objects relative to the id passed.

There is one quite big inconvenient to this approach so far: since we
are still supporting the historical syntax, the objects can be fetch by
a script, then the script will send the id to GetPreparedLetter which
will refetch them.
This must be improved, but I suggest to do that later.

Test plan:
  prove t/db_dependent/Letters/TemplateToolkit.t
should return green
Comment 2 Jonathan Druart 2017-01-23 15:05:21 UTC
Created attachment 59427 [details] [review]
Bug 17971: Add support for objects represented by fk

For instance an issue is not fetch from its fk but using the fk
itemnumber.
We need to support them.
Comment 3 Josef Moravec 2017-01-24 19:58:46 UTC
Created attachment 59529 [details] [review]
[SIGNED-OFF] Bug 17971: TT syntax for notices - Add support for plurals

On of the awesome things we will be able to do with the TT syntax is the support of plurals.

For instance we will be able to send a list of items, checkouts, etc. to the notice template.
That way we will get rid of our custom syntax like <<items.content>> or <item></item> for instance.

The existing code already has the playground for that but it is not used.

Basically the idea is to add a "loops" key which can contain a list of
object to retrieve from the DB and send to the template.
For instance:
    loops => { overdues => [ $itemnumber_1, .., $itemnumber_N ] }

will send a variable "overdues" to the template. It will contain the
Koha::Checkout objects relative to the id passed.

There is one quite big inconvenient to this approach so far: since we
are still supporting the historical syntax, the objects can be fetch by
a script, then the script will send the id to GetPreparedLetter which
will refetch them.
This must be improved, but I suggest to do that later.

Test plan:
  prove t/db_dependent/Letters/TemplateToolkit.t
should return green

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 4 Josef Moravec 2017-01-24 19:58:55 UTC
Created attachment 59530 [details] [review]
[SIGNED-OFF] Bug 17971: Add support for objects represented by fk

For instance an issue is not fetch from its fk but using the fk
itemnumber.
We need to support them.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 5 Marcel de Rooy 2017-03-10 09:49:02 UTC
Applying on top of 17970:

Applying: Bug 17971: TT syntax for notices - Add support for plurals
fatal: sha1 information is lacking or useless (C4/Letters.pm).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Comment 6 Jonathan Druart 2017-03-10 12:32:08 UTC
Created attachment 60987 [details] [review]
Bug 17971: TT syntax for notices - Add support for plurals

On of the awesome things we will be able to do with the TT syntax is the support of plurals.

For instance we will be able to send a list of items, checkouts, etc. to the notice template.
That way we will get rid of our custom syntax like <<items.content>> or <item></item> for instance.

The existing code already has the playground for that but it is not used.

Basically the idea is to add a "loops" key which can contain a list of
object to retrieve from the DB and send to the template.
For instance:
    loops => { overdues => [ $itemnumber_1, .., $itemnumber_N ] }

will send a variable "overdues" to the template. It will contain the
Koha::Checkout objects relative to the id passed.

There is one quite big inconvenient to this approach so far: since we
are still supporting the historical syntax, the objects can be fetch by
a script, then the script will send the id to GetPreparedLetter which
will refetch them.
This must be improved, but I suggest to do that later.

Test plan:
  prove t/db_dependent/Letters/TemplateToolkit.t
should return green

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 7 Jonathan Druart 2017-03-10 12:32:22 UTC
Created attachment 60988 [details] [review]
Bug 17971: Add support for objects represented by fk

For instance an issue is not fetch from its fk but using the fk
itemnumber.
We need to support them.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 8 Nick Clemens (kidclamp) 2017-03-29 20:12:33 UTC
Created attachment 61710 [details] [review]
Bug 17971: TT syntax for notices - Add support for plurals

On of the awesome things we will be able to do with the TT syntax is the support of plurals.

For instance we will be able to send a list of items, checkouts, etc. to the notice template.
That way we will get rid of our custom syntax like <<items.content>> or <item></item> for instance.

The existing code already has the playground for that but it is not used.

Basically the idea is to add a "loops" key which can contain a list of
object to retrieve from the DB and send to the template.
For instance:
    loops => { overdues => [ $itemnumber_1, .., $itemnumber_N ] }

will send a variable "overdues" to the template. It will contain the
Koha::Checkout objects relative to the id passed.

There is one quite big inconvenient to this approach so far: since we
are still supporting the historical syntax, the objects can be fetch by
a script, then the script will send the id to GetPreparedLetter which
will refetch them.
This must be improved, but I suggest to do that later.

Test plan:
  prove t/db_dependent/Letters/TemplateToolkit.t
should return green

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Nick Clemens (kidclamp) 2017-03-29 20:12:38 UTC
Created attachment 61711 [details] [review]
Bug 17971: Add support for objects represented by fk

For instance an issue is not fetch from its fk but using the fk
itemnumber.
We need to support them.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Nick Clemens (kidclamp) 2017-03-29 20:12:45 UTC
Created attachment 61712 [details] [review]
Bug 17971 (QA Followup) Clarify comment
Comment 11 Kyle M Hall (khall) 2017-03-31 11:53:47 UTC
Pushed to master for 17.05, thanks Jonathan, Nick!
Comment 12 Katrin Fischer 2017-04-02 16:23:10 UTC
This won't get ported back to 16.11.x as it is an enhancement.