Bug 37360 - Add 'protected status' as one of the things that can be updated via batch patron modification
Summary: Add 'protected status' as one of the things that can be updated via batch pat...
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jake Deery
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 36085 37755
Blocks:
  Show dependency treegraph
 
Reported: 2024-07-15 12:00 UTC by Andrew Auld
Modified: 2025-01-03 02:59 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement to the batch patron modification tool allows superlibrarians to batch update the protected status setting for patrons, instead of having to change each patron individually. The edit patrons form now includes the "Protected" field. (The protected status option for patrons was added in Koha 23.11.
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 37360: Add protected as a borrower mod option (7.48 KB, patch)
2024-09-02 09:55 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: Add protected as a borrower mod option (7.54 KB, patch)
2024-09-03 15:28 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (3.21 KB, patch)
2024-10-04 11:37 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: Add protected as a borrower mod option (7.59 KB, patch)
2024-10-18 13:37 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (3.27 KB, patch)
2024-10-18 13:37 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 37360: Add protected as a borrower mod option (7.39 KB, patch)
2024-10-24 14:35 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (3.22 KB, patch)
2024-10-24 14:35 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: Add protected as a borrower mod option (7.49 KB, patch)
2024-10-24 14:38 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (3.27 KB, patch)
2024-10-24 14:38 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (4.66 KB, patch)
2024-11-22 10:43 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (4.41 KB, patch)
2024-12-06 09:33 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 37360: Add protected as a borrower mod option (7.59 KB, patch)
2024-12-06 09:38 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 37360: (follow-up) added bool type to modborrowers (4.50 KB, patch)
2024-12-06 09:38 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 Andrew Auld 2024-07-15 12:00:55 UTC
The new 'Protected Status' characteristic is something that could usefully be included as editable via Batch Patron Modification.

Please consider adding.
Comment 1 Chanel Wheeler 2024-08-02 21:02:27 UTC
+1
Comment 2 Jake Deery 2024-09-02 09:55:18 UTC
Created attachment 170932 [details] [review]
Bug 37360: Add protected as a borrower mod option

This patch adds protected status as a batch borrower modification
option, if the user performing the modification is a superlibrarian.

TO TEST:

a)  login as a superlibrarian
b)  attempt to batch modify these k.t.d user barcodes:
    1)  23529000035676
    2)  23529001000463
    3)  23529000050113
c)  notice that there is no protected option
d)  APPLY PATCH
e)  repeat step b
f)  notice that protected is now an option
g)  set all borrowers to protected (yes)
    1)  notice that the status has changed, in each individual user
	record
h)  set all borrowers to unprotected (no)
    1)  notice that the status has changed, in each individual user
	record
i)  set the proctedted status back to yes, but also set some other
    random options (e.g. city to Cork)
    1)  notice that the city and protected status are both updated
j)  use the disabled checkbox next to protected
    1)  notice that this always sets the protected status to zero
k)  SIGN OFF
Comment 3 Jake Deery 2024-09-02 09:58:18 UTC
Thanks in advance for the sign-off and QA :-)

Jake.
Comment 4 ByWater Sandboxes 2024-09-03 15:28:49 UTC
Created attachment 170991 [details] [review]
Bug 37360: Add protected as a borrower mod option

This patch adds protected status as a batch borrower modification
option, if the user performing the modification is a superlibrarian.

TO TEST:

a)  login as a superlibrarian
b)  attempt to batch modify these k.t.d user barcodes:
    1)  23529000035676
    2)  23529001000463
    3)  23529000050113
c)  notice that there is no protected option
d)  APPLY PATCH
e)  repeat step b
f)  notice that protected is now an option
g)  set all borrowers to protected (yes)
    1)  notice that the status has changed, in each individual user
	record
h)  set all borrowers to unprotected (no)
    1)  notice that the status has changed, in each individual user
	record
i)  set the proctedted status back to yes, but also set some other
    random options (e.g. city to Cork)
    1)  notice that the city and protected status are both updated
j)  use the disabled checkbox next to protected
    1)  notice that this always sets the protected status to zero
k)  SIGN OFF

Signed-off-by: Catrina <catrina@bywatersolutions.com>
Comment 5 Catrina Berka 2024-09-03 15:30:04 UTC
Test plan works as described. Selecting the box to clear the value on "Protected" sets the users to "No" (not protected) - some clarifying helper text might be useful there.
Comment 6 Jake Deery 2024-09-04 08:00:58 UTC
Thanks for the sign-off, Catrina. I could add a tooltip, but it might also be worth considering properly documenting this?

Jake.
Comment 7 Nick Clemens (kidclamp) 2024-09-16 19:29:01 UTC
Just curious, why push, push, unshift for the options for the dropdown? 
Could you just define them all at once or push the empty option first?

I think the bigger issue is that the values will not be translatable, failing for this


You also change the check for empty fields from a truth check to only assigning if not empty string, then checking if defined, is there a reason for that?
Comment 8 Jake Deery 2024-10-04 11:08:17 UTC
Thanks for the feedback. Because this hasn't been done before, I sort of adapted what's there. I guess the solution would be to put the Yes/No text within the template? I can put together a follow-up to address this.

Jake.
Comment 9 Jake Deery 2024-10-04 11:37:59 UTC
Created attachment 172385 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.
Comment 10 Jake Deery 2024-10-04 11:38:40 UTC
All done – thanks for the FQA on this one. I think this is a much cleaner solution.

Jake.
Comment 11 Kristi 2024-10-11 18:53:40 UTC
Looks like this one has been signed off already. Should it be marked as Signed off status?
Comment 12 Brendan Lawlor 2024-10-18 13:37:26 UTC
Created attachment 172977 [details] [review]
Bug 37360: Add protected as a borrower mod option

This patch adds protected status as a batch borrower modification
option, if the user performing the modification is a superlibrarian.

TO TEST:

a)  login as a superlibrarian
b)  attempt to batch modify these k.t.d user barcodes:
    1)  23529000035676
    2)  23529001000463
    3)  23529000050113
c)  notice that there is no protected option
d)  APPLY PATCH
e)  repeat step b
f)  notice that protected is now an option
g)  set all borrowers to protected (yes)
    1)  notice that the status has changed, in each individual user
	record
h)  set all borrowers to unprotected (no)
    1)  notice that the status has changed, in each individual user
	record
i)  set the proctedted status back to yes, but also set some other
    random options (e.g. city to Cork)
    1)  notice that the city and protected status are both updated
j)  use the disabled checkbox next to protected
    1)  notice that this always sets the protected status to zero
k)  SIGN OFF

Signed-off-by: Catrina <catrina@bywatersolutions.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 13 Brendan Lawlor 2024-10-18 13:37:28 UTC
Created attachment 172978 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 14 Jake Deery 2024-10-24 14:35:33 UTC
Created attachment 173273 [details] [review]
Bug 37360: Add protected as a borrower mod option

This patch adds protected status as a batch borrower modification
option, if the user performing the modification is a superlibrarian.

TO TEST:

a)  login as a superlibrarian
b)  attempt to batch modify these k.t.d user barcodes:
    1)  23529000035676
    2)  23529001000463
    3)  23529000050113
c)  notice that there is no protected option
d)  APPLY PATCH
e)  repeat step b
f)  notice that protected is now an option
g)  set all borrowers to protected (yes)
    1)  notice that the status has changed, in each individual user
	record
h)  set all borrowers to unprotected (no)
    1)  notice that the status has changed, in each individual user
	record
i)  set the proctedted status back to yes, but also set some other
    random options (e.g. city to Cork)
    1)  notice that the city and protected status are both updated
j)  use the disabled checkbox next to protected
    1)  notice that this always sets the protected status to zero
k)  SIGN OFF
Comment 15 Jake Deery 2024-10-24 14:35:42 UTC
Created attachment 173274 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.
Comment 16 Jake Deery 2024-10-24 14:37:05 UTC
Ah whoops, removed the SO lines... one tick
Comment 17 Jake Deery 2024-10-24 14:38:46 UTC
Created attachment 173275 [details] [review]
Bug 37360: Add protected as a borrower mod option

This patch adds protected status as a batch borrower modification
option, if the user performing the modification is a superlibrarian.

TO TEST:

a)  login as a superlibrarian
b)  attempt to batch modify these k.t.d user barcodes:
    1)  23529000035676
    2)  23529001000463
    3)  23529000050113
c)  notice that there is no protected option
d)  APPLY PATCH
e)  repeat step b
f)  notice that protected is now an option
g)  set all borrowers to protected (yes)
    1)  notice that the status has changed, in each individual user
	record
h)  set all borrowers to unprotected (no)
    1)  notice that the status has changed, in each individual user
	record
i)  set the proctedted status back to yes, but also set some other
    random options (e.g. city to Cork)
    1)  notice that the city and protected status are both updated
j)  use the disabled checkbox next to protected
    1)  notice that this always sets the protected status to zero
k)  SIGN OFF

Signed-off-by: Catrina <catrina@bywatersolutions.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 18 Jake Deery 2024-10-24 14:38:54 UTC
Created attachment 173276 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 19 Jake Deery 2024-10-24 14:39:16 UTC
Those patches are now rebased on main :-)

Jake.
Comment 20 Jake Deery 2024-11-13 17:14:29 UTC
Any chance of a QA for this one in time for 24.11?
Comment 21 Marcel de Rooy 2024-11-22 09:44:59 UTC
(In reply to Jake Deery from comment #20)
> Any chance of a QA for this one in time for 24.11?

You wont pass the bug freeze anymore now. Sorry.
Note that this feels like an enh instead of a bug ?

This does not look good:
+        my $value = $input->param($field) if $input->param($field) ne '';
+        $infos->{$field} = $value if defined $value;
Never declare a variable with an if statement like that. The next line you are referring to it.

Our qa tools see it too:
 FAIL   tools/modborrowers.pl
   FAIL   critic
                # Variables::ProhibitConditionalDeclarations: Got 1 violation(s).
   WARN   tidiness
                The file is less tidy than before (bad/messy lines before: 0, now: 4)

Please tidy too.
Comment 22 Jake Deery 2024-11-22 10:43:50 UTC
Created attachment 174919 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 23 Jake Deery 2024-11-22 10:45:42 UTC
Hi Marcel,

Yes, I would agree, this is an enhancement. It will need to wait now until 25.05. I have tidied the offending file and rebased for good measure :-)

Jake.
Comment 24 Marcel de Rooy 2024-12-06 07:27:50 UTC
Just having a question still about this change:

-        my $value = $input->param($field);
-        $infos->{$field} = $value if $value;
-        $infos->{$field} = ""     if grep { $_ eq $field } @disabled;
+        my $value;
+        $value           = $input->param($field) if $input->param($field) ne '';
+        $infos->{$field} = $value                if defined $value;
+        $infos->{$field} = ""                    if grep { $_ eq $field } @disabled;

On first glance, nothing special happens here. Code looks more complicated than before.
And the $value assignemnt may trigger a warning now if the input->param is undef.

Please explain why you are doing this.
Comment 25 Jake Deery 2024-12-06 09:10:08 UTC
Hi Marcel,

I believe it was due to triggering Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations the old way. Happy to put it back, if we think this is safe to ignore? Or is there another way? :-) 

Jake.
Comment 26 Marcel de Rooy 2024-12-06 09:25:37 UTC
(In reply to Jake Deery from comment #25)
> Hi Marcel,
> 
> I believe it was due to triggering
> Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations the old
> way. Happy to put it back, if we think this is safe to ignore? Or is there
> another way? :-) 
> 
> Jake.

-        my $value = $input->param($field);
-        $infos->{$field} = $value if $value;
-        $infos->{$field} = ""     if grep { $_ eq $field } @disabled;

I remember the conditional declaration, but the original code above does not contain that. Could we just put these lines back? Or was there any issue with empty string versus undef that you wanted to fix here?
Comment 27 Jake Deery 2024-12-06 09:33:46 UTC
Created attachment 175253 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 28 Jake Deery 2024-12-06 09:34:49 UTC
Hi Marcel,

I've reverted the changes to those lines, but left the perltidy in as a cleansing operation. Hope this helps! :-)

Jake.
Comment 29 Marcel de Rooy 2024-12-06 09:38:52 UTC
Created attachment 175254 [details] [review]
Bug 37360: Add protected as a borrower mod option

This patch adds protected status as a batch borrower modification
option, if the user performing the modification is a superlibrarian.

TO TEST:

a)  login as a superlibrarian
b)  attempt to batch modify these k.t.d user barcodes:
    1)  23529000035676
    2)  23529001000463
    3)  23529000050113
c)  notice that there is no protected option
d)  APPLY PATCH
e)  repeat step b
f)  notice that protected is now an option
g)  set all borrowers to protected (yes)
    1)  notice that the status has changed, in each individual user
	record
h)  set all borrowers to unprotected (no)
    1)  notice that the status has changed, in each individual user
	record
i)  set the proctedted status back to yes, but also set some other
    random options (e.g. city to Cork)
    1)  notice that the city and protected status are both updated
j)  use the disabled checkbox next to protected
    1)  notice that this always sets the protected status to zero
k)  SIGN OFF

Signed-off-by: Catrina <catrina@bywatersolutions.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 30 Marcel de Rooy 2024-12-06 09:38:55 UTC
Created attachment 175255 [details] [review]
Bug 37360: (follow-up) added bool type to modborrowers

This follow-up patch adds a bool type to modborrowers, so that the
options can be translated within the template files.

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 31 Katrin Fischer 2024-12-23 10:07:52 UTC
Small thing... CanUpdateProtectPatron... Why not ProtectedPatron?
Comment 32 Katrin Fischer 2024-12-23 11:23:23 UTC
Pushed for 25.05!

Well done everyone, thank you!