Bug 22910 - Unique attributes should not be copied when duplicating a patron
Summary: Unique attributes should not be copied when duplicating a patron
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: paxed
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 23283
  Show dependency treegraph
 
Reported: 2019-05-15 10:58 UTC by paxed
Modified: 2019-10-14 20:02 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:
19.11.00,19.05.01


Attachments
Bug 22910 - Do not copy unique patron attributes to duplicated patron (1.48 KB, patch)
2019-05-15 11:01 UTC, paxed
Details | Diff | Splinter Review
Bug 22910 - Do not copy unique patron attributes to duplicated patron (1.52 KB, patch)
2019-05-15 12:27 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 22910 - Do not copy unique patron attributes to duplicated patron (2.08 KB, patch)
2019-05-29 06:22 UTC, paxed
Details | Diff | Splinter Review
Bug 22910: Do not copy unique patron attributes to duplicated patron (2.17 KB, patch)
2019-05-31 09:12 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description paxed 2019-05-15 10:58:58 UTC
When creating a new patron by duplicating another, all of the patron attributes are also copied into the form. Some of those value may be unique, so don't copy those.
Comment 1 paxed 2019-05-15 11:01:57 UTC
Created attachment 89782 [details] [review]
Bug 22910 - Do not copy unique patron attributes to duplicated patron

When creating a new patron by duplicating another, all of the patron
attributes are also copied into the form. Some of those value may be
unique, so don't copy those.
    
1) Create patron attribute types, one with "unique identifier", one without.
2) Create or a patron so it has values in both of those attributes.
3) Duplicate the patron
4) The edit form should retain the values from the "original" patron.
5) Apply patch.
6) Duplicate the patron - this time the attributes with unique values
   are cleared.
Comment 2 Owen Leonard 2019-05-15 12:27:41 UTC
Created attachment 89783 [details] [review]
Bug 22910 - Do not copy unique patron attributes to duplicated patron

When creating a new patron by duplicating another, all of the patron
attributes are also copied into the form. Some of those value may be
unique, so don't copy those.

1) Create patron attribute types, one with "unique identifier", one without.
2) Create or a patron so it has values in both of those attributes.
3) Duplicate the patron
4) The edit form should retain the values from the "original" patron.
5) Apply patch.
6) Duplicate the patron - this time the attributes with unique values
   are cleared.

Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi>

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 Katrin Fischer 2019-05-28 05:28:49 UTC
Very oddly, but this doesn't work for me. Can you please recheck?

What I did:
- Fresh database, created with reset_all
- Created a new patron attribute ID = Identifier as unique
- Edited my patron (42), setting it to uuu and SHOW_BARCODE to No
- Saved
- Duplicate patron 
- uuu remains
Comment 4 Katrin Fischer 2019-05-28 05:29:10 UTC
... also tried several restart_all and refreshes.
Comment 5 paxed 2019-05-29 05:23:35 UTC
(In reply to Katrin Fischer from comment #3)
> Very oddly, but this doesn't work for me. Can you please recheck?
> 
> What I did:
> - Fresh database, created with reset_all
> - Created a new patron attribute ID = Identifier as unique
> - Edited my patron (42), setting it to uuu and SHOW_BARCODE to No
> - Saved
> - Duplicate patron 
> - uuu remains

Retried it again, and it (still) works for me. No idea what's different (other than me not using kohadevbox and manually installing koha)
Comment 6 Katrin Fischer 2019-05-29 05:52:51 UTC
I am not sure when I can retest - putting this back into the QA queue.
Comment 7 paxed 2019-05-29 06:02:05 UTC
Seems like this depends on the system - It works on my test environment, but on another the patron_attributes_form sub cannot see the $op variable. I have no idea why.
Comment 8 paxed 2019-05-29 06:22:26 UTC
Created attachment 90173 [details] [review]
Bug 22910 - Do not copy unique patron attributes to duplicated patron

When creating a new patron by duplicating another, all of the patron
attributes are also copied into the form. Some of those value may be
unique, so don't copy those.

1) Create patron attribute types, one with "unique identifier", one without.
2) Create or a patron so it has values in both of those attributes.
3) Duplicate the patron
4) The edit form should retain the values from the "original" patron.
5) Apply patch.
6) Duplicate the patron - this time the attributes with unique values
   are cleared.


For some reason, on some environments the op-variable cannot be seen inside
the patron_attributes_form, so just pass it in as a parameter.
Comment 9 Marcel de Rooy 2019-05-31 09:12:21 UTC
(In reply to paxed from comment #7)
> Seems like this depends on the system - It works on my test environment, but
> on another the patron_attributes_form sub cannot see the $op variable. I
> have no idea why.

With Plack, you should not use the $op from global level in a subroutine. You should pass it. Which you do now and that is fine!
Comment 10 Marcel de Rooy 2019-05-31 09:12:59 UTC
Created attachment 90218 [details] [review]
Bug 22910: Do not copy unique patron attributes to duplicated patron

When creating a new patron by duplicating another, all of the patron
attributes are also copied into the form. Some of those value may be
unique, so don't copy those.

1) Create patron attribute types, one with "unique identifier", one without.
2) Create or a patron so it has values in both of those attributes.
3) Duplicate the patron
4) The edit form should retain the values from the "original" patron.
5) Apply patch.
6) Duplicate the patron - this time the attributes with unique values
   are cleared.

Signed-off-by: Pasi Kallinen <pasi.kallinen@koha-suomi.fi>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 11 Marcel de Rooy 2019-05-31 09:13:21 UTC
Side note:
* Commit title does not start with 'Bug XXXXX: ' - 24453d52d0

Fixed
Comment 12 paxed 2019-05-31 09:29:20 UTC
(In reply to Marcel de Rooy from comment #11)
> Side note:
> * Commit title does not start with 'Bug XXXXX: ' - 24453d52d0
> 
> Fixed

Whoops, thanks!
Comment 13 Martin Renvoize 2019-06-06 15:10:48 UTC
Nice work!

Pushed to master for 19.11.00
Comment 14 Fridolin SOMERS 2019-06-11 15:20:13 UTC
Pushed to 19.05.x for 19.05.01
Comment 15 Lucas Gass 2019-06-14 20:49:13 UTC
backported to 18.11.x for 18.11.07