Bug 18789 - Send a Koha::Patron object to the templates
Summary: Send a Koha::Patron object to the templates
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 18403
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-12 16:40 UTC by Jonathan Druart
Modified: 2017-08-22 15:41 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 18789: Send Koha::Patron object to the templates (219.30 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Pass a Koha::Patron object from returns.pl (16.86 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Use Koha::Patron->image from the templates (18.83 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: add tests for is_adult and is_child (3.84 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Use Koha::Patron->is_child where needed (7.88 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Use Koha::Patron->is_adult where needed (10.60 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Remove useless IS_ADULT variable (845 bytes, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Remove adultborrower from the pay* scripts (1.76 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: Update other occurences where is->child should be used (7.70 KB, patch)
2017-06-12 16:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18789: (follow-up)Send Koha::Patron object to the templates (1.36 KB, patch)
2017-06-12 17:20 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 Jonathan Druart 2017-06-12 16:40:02 UTC
The simplify and make uniform the code, the controller scripts should send a Koha::Patron object to the templates and not all attributes of a patron.

That will make the code much more easier to maintain and will be less error-prone.
Comment 1 Jonathan Druart 2017-06-12 16:59:20 UTC
Created attachment 64211 [details] [review]
Bug 18789: Send Koha::Patron object to the templates

In order to simplify and make uniform the code, the controller scripts send
a Koha::Patron object to the templates instead of all attributes of a patron.

That will make the code much more easier to maintain and will be less
error-prone.

The variable "patron" sent to the templates is supposed to represent the
patron the librarian is editing the detail.

In the members module and some scripts of the circulation module, the
patron's detail are sent one by one to the template. That leads to
frustration from developpers (making sure everything is passed from all
scripts) and to regression (we got tone of bugs in the last year because
of this way to do).
With this patch set it will be easy access patron's detail, passing only
1 variable from the controllers.

Test plan:
Play with the patron and circulation module and make sur the detail of
the patron you are editing/seeing info are correctly displayed.
Comment 2 Jonathan Druart 2017-06-12 16:59:24 UTC
Created attachment 64212 [details] [review]
Bug 18789: Pass a Koha::Patron object from returns.pl

This is a specific patch for returns.pl

Test plan:
Do some checkin for a patron and make sure the info are correctly
displayed (and info from someone that has placed a hold on this item)
Comment 3 Jonathan Druart 2017-06-12 16:59:28 UTC
Created attachment 64213 [details] [review]
Bug 18789: Use Koha::Patron->image from the templates

Now that we have the 'patron' variable in all our templates, we can call
Koha::Patron->image and do the check from the templates.

Test plan:
On the different pages of the patron module, you should see the default
image if there is no image attached or the one that has been attached
(see pref patronimages)
Comment 4 Jonathan Druart 2017-06-12 16:59:31 UTC
Created attachment 64214 [details] [review]
Bug 18789: add tests for is_adult and is_child

This patch add 2 methods to the Koha::Patron module: is_adult and
is_child.
That way the business logic is at only one place and covered by tests.
Comment 5 Jonathan Druart 2017-06-12 16:59:35 UTC
Created attachment 64215 [details] [review]
Bug 18789: Use Koha::Patron->is_child where needed

Test plan:
When you are on a page related to a child you should see the "Update
child to adult patron" button
Comment 6 Jonathan Druart 2017-06-12 16:59:38 UTC
Created attachment 64216 [details] [review]
Bug 18789: Use Koha::Patron->is_adult where needed

Test plan:
When editing adult's info you must see the "Add child" button
Comment 7 Jonathan Druart 2017-06-12 16:59:41 UTC
Created attachment 64218 [details] [review]
Bug 18789: Remove useless IS_ADULT variable

Test plan:
  git grep IS_ADULT
must not return any results
Comment 8 Jonathan Druart 2017-06-12 16:59:45 UTC
Created attachment 64219 [details] [review]
Bug 18789: Remove adultborrower from the pay* scripts

This flag is not used in the templates
Comment 9 Jonathan Druart 2017-06-12 16:59:48 UTC
Created attachment 64221 [details] [review]
Bug 18789: Update other occurences where is->child should be used

Trivial changes here, just do a code review on the QA step
Comment 10 Jonathan Druart 2017-06-12 17:20:51 UTC
Created attachment 64229 [details] [review]
Bug 18789: (follow-up)Send Koha::Patron object to the templates
Comment 11 Aleisha Amohia 2017-08-21 00:32:26 UTC
Patch did not apply:

$ git bz apply 18789
Bug 18789 - Send a Koha::Patron object to the templates

64211 - Bug 18789: Send Koha::Patron object to the templates
64212 - Bug 18789: Pass a Koha::Patron object from returns.pl
64213 - Bug 18789: Use Koha::Patron->image from the templates
64214 - Bug 18789: add tests for is_adult and is_child
64215 - Bug 18789: Use Koha::Patron->is_child where needed
64216 - Bug 18789: Use Koha::Patron->is_adult where needed
64218 - Bug 18789: Remove useless IS_ADULT variable
64219 - Bug 18789: Remove adultborrower from the pay* scripts
64221 - Bug 18789: Update other occurences where is->child should be used
64229 - Bug 18789: (follow-up)Send Koha::Patron object to the templates

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 18789: Send Koha::Patron object to the templates
fatal: sha1 information is lacking or useless (acqui/booksellers.pl).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 Bug 18789: Send Koha::Patron object to the templates
Comment 12 Jonathan Druart 2017-08-22 15:41:15 UTC
You need to apply the dependencies first.