There is no restriction (certainly a unique key missing). To recreate: Create 3 clubs, 1 limited to library A, 1 limited to library B and one not limited Use a patron with home library A. Go to the opac-user page, "Clubs" tab show 0/2 (the one from library B is not listed) Hit http://localhost:8080/cgi-bin/koha/svc/club/enroll?id=1 http://localhost:8080/cgi-bin/koha/svc/club/enroll?id=2 http://localhost:8080/cgi-bin/koha/svc/club/enroll?id=3 Oops, you see 3/0 Hit again the same link Oops, you see 6/0
There are 2 things here: 1. No unicity check on (patron, club, date_cancelled) 2. No check on the library limitation
Created attachment 161648 [details] [review] Bug 35942: OPAC user can enroll several times to the same club Test Plan: 1) Create 3 clubs, 1 limited to library A, 1 limited to library B and one not limited 2) Use a patron with home library A. 3) Go to the opac-user page, "Clubs" tab show 0/2 (the one from library B is not listed) 4) Browse to /cgi-bin/koha/svc/club/enroll?id=1 5) Reload that page a couple times 6) Note the patron is now enrolled in the same club multiple times 7) Delete those enrollments 8) Apply this patch 9) Restart all the things! 10) Repeat steps 2-7, note the lack of duplicate enrollments! 11) Repeat steps 2-10 for the staff interface
Created attachment 161649 [details] [review] Bug 35942: OPAC user can enroll several times to the same club Test Plan: 1) Create 3 clubs, 1 limited to library A, 1 limited to library B and one not limited 2) Use a patron with home library A. 3) Go to the opac-user page, "Clubs" tab show 0/2 (the one from library B is not listed) 4) Browse to /cgi-bin/koha/svc/club/enroll?id=1 5) Reload that page a couple times 6) Note the patron is now enrolled in the same club multiple times 7) Delete those enrollments 8) Apply this patch 9) Restart all the things! 10) Repeat steps 2-7, note the lack of duplicate enrollments! 11) Repeat steps 2-10 for the staff interface
Created attachment 161665 [details] [review] Bug 35942: OPAC user can enroll several times to the same club Test Plan: 1) Create 3 clubs, 1 limited to library A, 1 limited to library B and one not limited 2) Use a patron with home library A. 3) Go to the opac-user page, "Clubs" tab show 0/2 (the one from library B is not listed) 4) Browse to /cgi-bin/koha/svc/club/enroll?id=1 5) Reload that page a couple times 6) Note the patron is now enrolled in the same club multiple times 7) Delete those enrollments 8) Apply this patch 9) Restart all the things! 10) Repeat steps 2-7, note the lack of duplicate enrollments! 11) Repeat steps 2-10 for the staff interface Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Not perfect but good enough for now. We should have the constraint in the DB. Also I am wondering if the start/end dates should not be checked as well. That's for another day... Thanks for the quick fix!
Created attachment 161689 [details] [review] Bug 35942: OPAC user can enroll several times to the same club Test Plan: 1) Create 3 clubs, 1 limited to library A, 1 limited to library B and one not limited 2) Use a patron with home library A. 3) Go to the opac-user page, "Clubs" tab show 0/2 (the one from library B is not listed) 4) Browse to /cgi-bin/koha/svc/club/enroll?id=1 5) Reload that page a couple times 6) Note the patron is now enrolled in the same club multiple times 7) Delete those enrollments 8) Apply this patch 9) Restart all the things! 10) Repeat steps 2-7, note the lack of duplicate enrollments! 11) Repeat steps 2-10 for the staff interface Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
All working, QA script happy, Passing QA
(In reply to Jonathan Druart from comment #5) > Not perfect but good enough for now. We should have the constraint in the DB. > > Also I am wondering if the start/end dates should not be checked as well. > That's for another day... > > Thanks for the quick fix! I wasn't sure which columns should be part of a UNIQUE constraint for this table. It definitely needs club_id, borrowernumber, and date_cancelled. I'm not sure if date_cancelled being nullable causes any issues. If you think those are a good key set I'll add a followup to enforce those.
(In reply to Kyle M Hall from comment #8) > (In reply to Jonathan Druart from comment #5) > > Not perfect but good enough for now. We should have the constraint in the DB. > > > > Also I am wondering if the start/end dates should not be checked as well. > > That's for another day... > > > > Thanks for the quick fix! > > I wasn't sure which columns should be part of a UNIQUE constraint for this > table. It definitely needs club_id, borrowernumber, and date_cancelled. I'm > not sure if date_cancelled being nullable causes any issues. If you think > those are a good key set I'll add a followup to enforce those. Hum indeed, we certainly need a separate column (boolean) to tell that the patron is currently enrolled or not.
Pushed to master for 24.05.00
This doesn't apply cleanly to 23.05.x. Kyle can we get a rebase?
Created attachment 162332 [details] [review] Bug 35942: OPAC user can enroll several times to the same club [23.05.x] Test Plan: 1) Create 3 clubs, 1 limited to library A, 1 limited to library B and one not limited 2) Use a patron with home library A. 3) Go to the opac-user page, "Clubs" tab show 0/2 (the one from library B is not listed) 4) Browse to /cgi-bin/koha/svc/club/enroll?id=1 5) Reload that page a couple times 6) Note the patron is now enrolled in the same club multiple times 7) Delete those enrollments 8) Apply this patch 9) Restart all the things! 10) Repeat steps 2-7, note the lack of duplicate enrollments! 11) Repeat steps 2-10 for the staff interface Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Hi there, I can't seem to reproduce the error on 22.05.x
(In reply to wainuiwitikapark from comment #13) > Hi there, I can't seem to reproduce the error on 22.05.x I do reproduce on 22.05.x
I see it is in 22.05.19 @Frederic But I don't see it in 22.11.15
(In reply to Fridolin Somers from comment #15) > But I don't see it in 22.11.15 Noooo! I don't know what happened. I can see myself testing this patch.
Patch pushed in v22.11.15-1
The missing patch has been pushed to main for 24.11 now. I am resetting status to show that it still needs to go into 24.05.
Pushed for 24.11! Well done everyone, thank you!
Probably want to wait to take it on 24.05 until you can also take bug 37031.
Really bad testing (from me) here!
Backported to 24.05.x for upcoming 24.05.02 I was confused here, this one was already marked as backported to 24.05. It wasn't.
This fixes patron club enrolment from their account in the OPAC. They can now only enroll in a club once.