Summary: | Add itemtype description template plugin | ||
---|---|---|---|
Product: | Koha | Reporter: | Fridolin Somers <fridolin.somers> |
Component: | Templates | Assignee: | Fridolin Somers <fridolin.somers> |
Status: | RESOLVED DUPLICATE | QA Contact: | Jonathan Druart <jonathan.druart> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | jonathan.druart, kyle |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Attachments: |
Proposed patch
Proposed patch Bug 9426: Add itemtype description template plugin Bug 9426: Add itemtype description template plugin |
Description
Fridolin Somers
2013-01-18 15:07:04 UTC
Created attachment 14702 [details] [review] Proposed patch See commit message 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. I get an error unless I change "[% USE KohaAuthorisedValues %]" (in the test plan) to "[% USE KohaItemType %]" Is that what it should be? (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 Created attachment 14922 [details] [review] Proposed patch Created attachment 15188 [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> 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. 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> 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. |