Bug 9426 - Add itemtype description template plugin
Summary: Add itemtype description template plugin
Status: RESOLVED DUPLICATE of bug 8215
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Fridolin Somers
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-18 15:07 UTC by Fridolin Somers
Modified: 2013-05-30 13:23 UTC (History)
2 users (show)

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


Attachments
Proposed patch (2.92 KB, patch)
2013-01-18 15:18 UTC, Fridolin Somers
Details | Diff | Splinter Review
Proposed patch (2.91 KB, patch)
2013-01-29 17:29 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 9426: Add itemtype description template plugin (2.98 KB, patch)
2013-02-08 18:01 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 9426: Add itemtype description template plugin (3.02 KB, patch)
2013-03-15 15:37 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2013-01-18 15:07:04 UTC
Like branch name template plugin KohaBranchName, add a plugin that converts itemtype code into its description.
Comment 1 Fridolin Somers 2013-01-18 15:18:59 UTC Comment hidden (obsolete)
Comment 2 Fridolin Somers 2013-01-18 15:23:14 UTC
I added in this patch a new method to instantiate a C4::ItemType object from its code, in order to improve the use of object-oriented programing in Koha.
Comment 3 Fridolin Somers 2013-01-18 15:24:58 UTC
It will be useful to improve bug 9423.
Comment 4 Owen Leonard 2013-01-28 15:42:35 UTC
I get an error unless I change "[% USE KohaAuthorisedValues %]" (in the test plan) to "[% USE KohaItemType %]"

Is that what it should be?
Comment 5 Fridolin Somers 2013-01-29 17:28:14 UTC
(In reply to comment #4)
> I get an error unless I change "[% USE KohaAuthorisedValues %]" (in the test
> plan) to "[% USE KohaItemType %]"
> 
> Is that what it should be?

Sorry, error in my test plan : 
- Add as first line : [% USE KohaAuthorisedValues %]
It is : 
- Add as first line : [% USE KohaItemType %]

Thanks for testing
Comment 6 Fridolin Somers 2013-01-29 17:29:34 UTC Comment hidden (obsolete)
Comment 7 Kyle M Hall 2013-02-08 18:01:45 UTC Comment hidden (obsolete)
Comment 8 Jonathan Druart 2013-03-15 15:36:49 UTC
QA comment:

Works as described.

I am not sure about the behavior if the code doesn't exist in the DB, maybe we should return the code instead of an empty string.

Marked as Passed.
Comment 9 Jonathan Druart 2013-03-15 15:37:03 UTC
Created attachment 16165 [details] [review]
Bug 9426: Add itemtype description template plugin

Like branch name template plugin KohaBranchName, add a plugin that converts itemtype code into its description.

This patch adds this template plugin and a method tho instanciate a C4::ItemType object using its code.

Test plan :
- Choose an existing itemtype code (ie DVD)
- Edit any template (ie intranet-main.tt)
- Add as first line : [% USE KohaItemType %]
- Add in body : itemtype=[% 'DVD' | $KohaItemType %]
- Go to this page
=> Itemtype description is displayed next to 'itemtype='

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 10 Jared Camins-Esakov 2013-03-16 15:10:13 UTC
This patch looks good, except it doesn't add unit tests for the new code in C4/ and Koha/. 

What about something like this in t/ItemType.t (obviously a resultset will have to be added to the mocked dbh before this test):
my $itype = C4::ItemType->new_from_code('BK');
is(ref $itype, 'C4::ItemType', 'new_from_code creates correct type of object');
is($itype->description, 'Books', 'new_from_code retrieved correct itemtype');

And, of course, there also need to be tests for Koha::Template::Plugin::ItemType. If you look at t/db_dependent/Koha_template_plugin_KohaDates.t you'll see an example of a unit test for a TT filter (and bonus points if you test by way of C4::Template as well).

A follow-up adding the unit tests need not go through the entire sign off/QA process again. If the coverage is good (and the tests pass), I will review it myself and push it, so you can set this bug back to "Passed QA" after your follow-up is attached.
Comment 11 Fridolin Somers 2013-05-30 13:23:02 UTC
Same plugin was added by Bug 8215.
Cool.

*** This bug has been marked as a duplicate of bug 8215 ***