The problem ----------- Public libraries and school libraries often have to deal with a lot of age restrictions, e.g. wit FSK (see www.fsk.de) or PEGI (Pan European Game Information, see www.pegi.info) and/or with regional rules regarding movies (virtually every canton in Switzerland has it's own rules). The classic way to implement age restrictions is to make use of a lot of categories. This gets soon very complicated, and is not easily maintainable. The librarians need an easy way to maintain age restrictions per title, otherwise they will not accept Koha. I tried to find a robust ad easily configurable way to match age restriction against the borrower's age. I implemented it on my test server. The concept ----------- 1) Have information about age restriction in field 521 a (Target audience) The entry can be anywhere in the field. It reads like PEGI 3 or FSK 12 (or any other 'tag' + age). 2) Have a preference like 'AgeRestrictionTags' where such tags are defined. It is a text field with a list like PEGI,FSK,Age... (Make things robust by accepting ,;: and space as delimiters...) 3) In circulation.pm, sub CanBookBeIssued, fetch the value from 521 a using the tags above. If the text after such tag is numeric, take this value as $restrictionyear. Add the years to the borrower's birth date. If the resulting date is in the future ( >today) , issuing is blocked by setting $issuingimpossible{AGE_RESTRICTION} = $restrictionyear; 4) In circulation.tt, part , add: [% IF ( AGE_RESTRICTION ) %] <li>Age restriction [% AGE_RESTRICTION %]</li> [% END %] Result ------- If a borrower tries to check out a restricted book and does not have the appropriate age, the circulation module will block the check out and issue a message like "Age restriction 12"
I might add that it might be helpful to have this for "canBookBeReserved" as well.
(In reply to comment #1) > I might add that it might be helpful to have this for "canBookBeReserved" as > well. It seems that CanBookBeReserved works on borrower and item data only (in Reserves.pm it loops through items and calls CanItemBeReserved ). The first idea would be to let CanBookBeReserved call CanBookBeIssued as well, but in this case at least the parameter handling of CanBookBeIssued would need modifications. It might even be necessary to break down CanBookBeIssued to several single sub routines (for each check one). This way, CanBokBeReserved and CanBookBeIssued could call the sub routines as appropriate. I think this would lead to some bigger architectural modifications. My proposition is to implement the functionality for CanBookBeIssued in a first step and to do the integration with CanBookBeIssued later.
Please make sure you wrap the behavior with a syspref so its only called for libraries that want it. Because it will cause a slight performance hit.
(In reply to comment #3) > Please make sure you wrap the behavior with a syspref so its only called for > libraries that want it. Because it will cause a slight performance hit. I can do this with checking first C4::Context->preference('AgeRestrictionTags' ) If it is emtty, skip.
Some additional considerations: 1) The MARC field and subfield for age restriction needs to be configurable, so it can accommodate MARC21, UNIMARC and NORMARC equally. Note that Restrictions on Access are recorded in 506 in MARC21. UNIMARC 333 (Notes Pertaining to Users/Intended Audience) may be the best fit on that side. 2) A single delimiter for acceptable tags should be decided on. I recommend | to be consistent with other system preferences. Space should not be used, as someone will undoubtedly want to use a two-word tag (like "Age Restriction:"). 3) The behaviour should be configurable as to whether it completely blocks circ (issuingimpossible) or just prompts a confirmation box (needsconfirmation), since not every library will want to have this be a hard and fast rule. 4) Once DOM biblio indexing is in place, doing a numeric index on age restriction would make it searchable in the OPAC (and facetable, perhaps even with an "age appropriate for me?" facet for logged in users). 5) Should age restrictions interact at all with Analytics (passing through from serial record to monographic record)?
I have implemented Ian Walls' suggestions #1-#3 on my server. Preferences in Section "Checkout Policy" read like this: 2 Fields: AgeRestrictionField AgeRestrictionSubField [ ] [ ] Marc field / subfield for age restriction. E.g. 521 a (Empty AgeRestrictionField - Do not apply age restriction) 1 Field: AgeRestrictionMarker [ ] E.g. FSK|PEGI|Age| (No white space near |). Entry in Marc e.g. PEGI 6 (Empty - Do not apply age restriction) 1 Drop down list: AgeRestrictionOverride [Prevent | Don't prevent] patrons from checking out an item whose age restriction would apply.
Created attachment 9176 [details] [review] Bug 7621 [ENH]- Circulation: Match age restriction of title with borrower's age without using categories Test scenario: 1) Edit preferences Circulation: AgeRestrictionField (521), AgeRestrictionSubField (a), AgeRestrictionMarker (FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Dont prevent) 2) Create a young patron account e.g. with age < 16 3) Create or edit a biblio with e.g. the value FSK 16 in the field 521a 4) Try to check out to young patron 5) Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride)
I like the idea, but the patch is missing a few little things. It needs to do an updatedatabase.pl to add the syspref to the database, as well as updating the syspref.sql Another issue is the use of SELECT ExtractValue, this will fail on older mysql versions (pre 5.1) and is slow. It might be better to adapt the frameworks to link the MARC field to a column in biblioitems. Since you have all the columns in biblioitems available anyway. This would mean it would be the same query whatever MARC flavour, as the appropriate subfield would be linked to the column. Just a thought.
I'm implementing Chris' suggestions, please do not use the patch.
Created attachment 9219 [details] [review] Bug 7621 [ENH]- Circulation: Match age restriction of title with borrower's age without using categories Test scenario: 1) Make sure that you have a column 'agerestriction' in table biblioitems. This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' 2) In the staff client, go to Home . Administration . Koha to MARC mapping and choose biblioitems + OK. In the field list, the field 'agerestriction' should show up. Edit it and map the field e.g. to 521a 3) Go to Home . Administration . System preferences and edit Circulation: AgeRestrictionMarker (add eg.: FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Don't prevent) 4) Create a young patron account e.g. with age < 16 5) Create or edit a biblio with e.g. the value FSK 16 in the field 521a (same field as mapped above) 6) Try to check out to young patron 7) Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride)
I'd like to sign off, but since I recommended the changes probably best if someone else does :)
Created attachment 9979 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: 1) Make sure that you have a column 'agerestriction' in table biblioitems. This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' 2) In the staff client, go to Home . Administration . Koha to MARC mapping and choose biblioitems + OK. In the field list, the field 'agerestriction' should show up. Edit it and map the field e.g. to 521a 3) Go to Home . Administration . System preferences and edit Circulation: AgeRestrictionMarker (add eg.: FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Don't prevent) 4) Create a young patron account e.g. with age < 16 5) Create or edit a biblio with e.g. the value FSK 16 in the field 521a (same field as mapped above) 6) Try to check out to young patron 7) Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride)
Previous patch did not longer apply. Remade patch and tested. Would be nice if somebody could sign off - thanks!
Created attachment 10072 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: 1) Make sure that you have a column 'agerestriction' in table biblioitems. This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' 2) In the staff client, go to Home . Administration . Koha to MARC mapping and choose biblioitems + OK. In the field list, the field 'agerestriction' should show up. Edit it and map the field e.g. to 521a 3) Go to Home . Administration . System preferences and edit Circulation: AgeRestrictionMarker (add eg.: FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Don't prevent) 4) Create a young patron account e.g. with age < 16 5) Create or edit a biblio with e.g. the value FSK 16 in the field 521a (same field as mapped above) 6) Try to check out to young patron 7) Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride) Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Works well, has no effect unless the syspref is on. Safe change.
QA comment: Fails QA for 2 reason, plus one request * Your patch introduce a perlcritic error: C4/Circulation.pm: Integer with leading zeros: "02" at line 976, column 41. See page 58 of PBP. (Severity: 5) * The description of the syspref look a little bit too complex to me: "Do not prevent patrons from checking out an item whose age restriction would apply". Saying "No" means "do not not prevent from ..." That's a typical "no-no" thing. It's much readable to have a yes-yes: "Prevent patrons from checking out..." "Yes/No". * for existing setups, it will be necessary to do some manual operations: - Add the Age Restriction marker and link it to biblioitems.agerestriction - if the Age Rescrition marker is already here, an UPDATE will be needed (something like "UPDATE biblioitems SET agerestriction=ExtractValue('@521$a',marcxml)") to fill the new biblioitems field That's worth adding a wiki page describing that and pointing to it during updatedatabase (I'll take care of this in the Release Notes as well) Note that this script is MARCflavour agnostic, so it should work in UNIMARC as well, (probably with field 333)
Created attachment 10136 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: 1) Make sure that you have a column 'agerestriction' in table biblioitems. This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' 2) In the staff client, go to Home . Administration . Koha to MARC mapping and choose biblioitems + OK. In the field list, the field 'agerestriction' should show up. Edit it and map the field e.g. to 521a 3) Go to Home . Administration . System preferences and edit Circulation: AgeRestrictionMarker (add eg.: FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Don't prevent) 4) Create a young patron account e.g. with age < 16 5) Create or edit a biblio with e.g. the value FSK 16 in the field 521a (same field as mapped above) 6) Try to check out to young patron 7) Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride) Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Wiki page prepared (http://wiki.koha-community.org/wiki/Age_restriction)
Created attachment 10141 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: 1) Make sure that you have a column 'agerestriction' in table biblioitems. This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' 2) In the staff client, go to Home . Administration . Koha to MARC mapping and choose biblioitems + OK. In the field list, the field 'agerestriction' should show up. Edit it and map the field e.g. to 521a 3) Go to Home . Administration . System preferences and edit Circulation: AgeRestrictionMarker (add eg.: FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Don't prevent) 4) Create a young patron account e.g. with age < 16 5) Create or edit a biblio with e.g. the value FSK 16 in the field 521a (same field as mapped above) 6) Try to check out to young patron 7) Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride) Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Wiki page prepared (http://wiki.koha-community.org/wiki/Age_restriction) (Added modified file)
Created attachment 10142 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Wiki page prepared (http://wiki.koha-community.org/wiki/Age_restrict (Added modified files..)
Created attachment 10143 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Wiki page prepared (http://wiki.koha-community.org/wiki/Age_restrict (Added modified files..,) Sorry for that many patches, mistaked with adding files.
Created attachment 10144 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Test scenario: Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Wiki page prepared (http://wiki.koha-community.org/wiki/Age_restrict (Added modified files..,) Sorry for that many patches, mistaked with adding files.
Finally I got all files :-)
Created attachment 10395 [details] [review] [REBASED] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion
i test with a sandbox and an UNIMARC database; i use the tag 333$a where i enter the valeur FSK 16 but it didn't work : the young can checkout the issue. I must update biblioitems.agerestriction ? i must enter un flag in this new column ?... thank you for more information
Hi Stephane, Thank you for testing! I se that teh wiki link is broken, it should be: http://wiki.koha-community.org/wiki/Age_restriction Did you follow the steps there? Marc
Ah I see you are testing in a sandbox. Maybe the prolbem is that you cann not update the database: --Snip Wiki ------- If you use the patch, make sure that you have a column 'agerestriction' in table biblioitems. This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' --End Snip Wiki -------
after apply the patch i can't update the system preference AgeRestrictionMarker and AgeRestrictionOverride i see the system preference in koha but une the table sql systempreferences i don't see them
If the field 'agerestriction'is not in the table, you should run: installer/data/mysql/updatedatabase.pl or as alternative you can do the update directly using the following MySQL statement: ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' ; Can you do that in the sandbox?
mysql> desc biblioitems; +-----------------------+--------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+--------------+------+-----+-------------------+-----------------------------+ | biblioitemnumber | int(11) | NO | PRI | NULL | auto_increment | | biblionumber | int(11) | NO | MUL | 0 | | | volume | mediumtext | YES | | NULL | | | number | mediumtext | YES | | NULL | | | itemtype | varchar(10) | YES | | NULL | | | isbn | varchar(30) | YES | MUL | NULL | | | issn | varchar(9) | YES | MUL | NULL | | | ean | varchar(13) | YES | MUL | NULL | | | publicationyear | text | YES | | NULL | | | publishercode | varchar(255) | YES | MUL | NULL | | | volumedate | date | YES | | NULL | | | volumedesc | text | YES | | NULL | | | collectiontitle | mediumtext | YES | | NULL | | | collectionissn | text | YES | | NULL | | | collectionvolume | mediumtext | YES | | NULL | | | editionstatement | text | YES | | NULL | | | editionresponsibility | text | YES | | NULL | | | timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | illus | varchar(255) | YES | | NULL | | | pages | varchar(255) | YES | | NULL | | | notes | mediumtext | YES | | NULL | | | size | varchar(255) | YES | | NULL | | | place | varchar(255) | YES | | NULL | | | lccn | varchar(25) | YES | | NULL | | | marc | longblob | YES | | NULL | | | url | varchar(255) | YES | | NULL | | | cn_source | varchar(10) | YES | | NULL | | | cn_class | varchar(30) | YES | | NULL | | | cn_item | varchar(10) | YES | | NULL | | | cn_suffix | varchar(10) | YES | | NULL | | | cn_sort | varchar(30) | YES | | NULL | | | agerestriction | varchar(250) | YES | | NULL | | | totalissues | int(10) | YES | | NULL | | | marcxml | longtext | NO | | NULL | | +-----------------------+--------------+------+-----+-------------------+---------------- INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|. See: http://wiki.koha-community.org/wiki/Age_restriction',NULL,'free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo'); select * from biblioitems where biblionumber=1979\G *************************** 1. row *************************** biblioitemnumber: 1979 biblionumber: 1979 volume: NULL number: NULL itemtype: LIVR isbn: 2869672020 issn: NULL ean: NULL publicationyear: 1993 publishercode: Vents d'ouest volumedate: NULL volumedesc: NULL collectiontitle: Grand large. collectionissn: NULL collectionvolume: NULL editionstatement: NULL editionresponsibility: NULL timestamp: 2012-06-27 16:41:24 illus: NULL pages: 46 p. notes: NULL size: 30 cm place: NULL lccn: NULL marc: 00516 2200193 45000010005000000100021000050900009000261000041000352000073000762100024001492150034001732250023002071010008002306150012002386760007002503330011002577000026002687010028002941979 a2869672020d6.10 a1979 a20020311 frey50 1 aLe vol des urubus : La fièvre de l'ordtome 2fEric GutierrezbLIVR 1cVents d'ouestd1993 1a46 p.cBande dessinéed30 cm1 aGrand large.vN°2 afre aFiction 1aBD aFSK 16 192508aGutierrezbEric 192509aMigeatbFrançois url: NULL cn_source: NULL cn_class: NULL cn_item: NULL cn_suffix: NULL cn_sort: agerestriction: FSK 16 totalissues: NULL BUT the user who have 14 years can chekout the biblionumber 1979
What is in the Preferences AgeRestrictionMarker and AgeRestrictionOverride ?
FSK|PEGI|Age and 0
Hmm, maybe a calculation issue with the birth date. What is the birthdate of the patron you tested with?
birthdate of the borrower : 19/05/2001
Thanks again for testing. I have to rebase to the current master, will try to get it done this evening.
it's work!!!... thank you!!
Merveilleux, un grand merci! Marc
Created attachment 10550 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion Rebased version. (Koha version: 3.09.00.018)
Created attachment 10650 [details] [review] [PATCH] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion
(In reply to comment #38) > Created attachment 10650 [details] [review] > [PATCH] BUG 7621 [ENH] Circulation: Match age restriction of title with > borrower's age without using categories > > Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > > New version implementing Paul's advice. > See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion Passing QA on this... - fixed SQL typo in updatedatabase.pl then rebased patch on commit 'ce138ac96f3a5a729568f6d7db2e50ce3653b7bb' - patch passes 'perlcritic' and 'prove xt' tests
Created attachment 10657 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion
Created attachment 10658 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion
> Passing QA on this... > > - fixed SQL typo in updatedatabase.pl then rebased patch on > commit 'ce138ac96f3a5a729568f6d7db2e50ce3653b7bb' > > - patch passes 'perlcritic' and 'prove xt' tests QA comment... - i added 'agerestriction' columns in kohastructure.sql, for biblioitems and deletedbiblioitems tables - and added 'agerestriction' column for deletedbiblioitems in updatedatabase.pl some little gotchas for adding new columns to a table in Koha ;)
Mason, Thanks a lot for passing QA and fixing beginner's mistakes! Marc
QA comments: I can't make it work. Here is what I did: * put "Age" in the AgeRestrictionMarker syspref * set "AgeRestrictionOverride" to allow * update default framework to map 330$a with biblioitems.agerestriction field * create a biblio, with Age 99, with an item * check-out the item to a patron that is born 01/01/1980 => checkout made without any warning. Am I missing something ? (note i've checked that biblioitems.agerestriction contains "Age 99", it does. QA question = shouldn't we update the MARC frameworks (in installer/data/mysql/<language>/marc_flavour/*.sql to connect agerestriction field to biblioitems ? failing QA until I can make it work.
I try again the patch test in a sandbox but I have this error message Applying: BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Auto-merging C4/Circulation.pm Auto-merging installer/data/mysql/kohastructure.sql Auto-merging installer/data/mysql/sysprefs.sql CONFLICT (content): Merge conflict in installer/data/mysql/sysprefs.sql Auto-merging installer/data/mysql/updatedatabase.pl CONFLICT (content): Merge conflict in installer/data/mysql/updatedatabase.pl Failed to merge in the changes. Patch failed at 0001 BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort". Bug 7621 - Circulation: Match age restriction of title with borrower's age without using categories BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Apply? [yn] Patch left in /tmp/BUG-7621-ENH-Circulation-Match-age-restriction-of--YuivIy.patch **** I launch the following commands ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort; ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort; INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|. See: http://wiki.koha-community.org/wiki/Age_restriction',NULL,'free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo'); but i have always the problem , in koha i don't find the new system preference can you rebase the patch?....
Created attachment 10859 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion REBASED to Koha version: 3.09.00.025 Comparision part changed in C4/Circulation.pm
Typo in wiki link above, correct link is: http://wiki.koha-community.org/wiki/Age_restriction
Comment on attachment 10859 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Hmm, seems that I forgot to commit changes. New patch follows.
> > REBASED to Koha version: 3.09.00.025 > Comparision part changed in C4/Circulation.pm Marc, can you provide a git-commit string, rather than the koha-version
Created attachment 10866 [details] [review] Bug 7621 . Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Usage see http://wiki.koha-community.org/wiki/Age_restriction Changes in C4/Circulation.pm; - skip age restriciton part as well if no age restriction info in biblio record - more robust string comparision part (nested for... loops instead of grep and better handling of superfluous white space) - display whole age restriction string as information (e.g. FSK 16 instead of 16)
Ha ! I understang now why I couldn't make it work ! I needed almost 2 hours to understand !!! Try "Age" in the syspref, and enter Age 18 => epic fail In the code, the comparison line says: if (grep {uc($_) eq $value} @marker) { UC ! UC ! UC ! Try AGE, it works ! So, either fix the patch or fix the documentation 2 other reasons for failing QA: * You patch says: + my $td = Date_to_Days(Today); + my $ad = Date_to_Days(@alloweddate); + + if ( Date_to_Days(Today) < Date_to_Days(@alloweddate) -1 ) { => you make no use of $td and $ad * The patch also says: preference('AgeRestrictionOverride ') => the space at the end of the syspref is bad
Paul, Thank you very much for testing and for your findings. I'm really sorry that I wasted your time with a basic Perl error. I'm coming from C++ and PHP and I'm not yet very used to Perl. Yesterday morning, I re-wrote the comparision part using a double for... loop to make the comparision code more readable, and it works now with "Age" (Upper-lower-case). But I could not manage to upload the new patch because git was down. I will try to get a new patch done this week if I find some time and a stable internet connection as well (still on vacation). Marc
(In reply to comment #52) > Paul, > > Thank you very much for testing and for your findings. I'm really sorry that > I wasted your time with a basic Perl error. Don't worry for that, it's in my job ;-) > Yesterday morning, I re-wrote the comparision part using a double for... > loop to make the comparision code more readable, and it works now with "Age" > (Upper-lower-case). But I could not manage to upload the new patch because > git was down. making it case agnostic is a good idea I think. So comparing uc($_) eq uc($value) is probably a good idea imo
Created attachment 10896 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. Recoded comparision part to compare in upper case mode and to remove superfluous blanks. Message shows full reason e.g. PEGI 14 instead of 14. Usage: See http://wiki.koha-community.org/wiki/Age_restriction
Finally managed to upload patch (I have a very bad internet connection at the moment).
Marc's latest patch needs a sign-off here...
Created attachment 11130 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> fix updatedatabase.pl
Created attachment 11550 [details] [review] [SIGNED-OFF] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> fix updatedatabase.pl New fix updatedatabase.pl to apply to current master by Marc Veron veron@veron.ch
(Mit Bezug zu comment 58) > Anhang 11550 angelegt (attachment 11550 [details] [review]) > [SIGNED-OFF] BUG 7621 [ENH] Circulation: Match age restriction of title with > borrower's age without using categories > > Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > > New version implementing Paul's advice. > See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion > > Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > fix updatedatabase.pl > > New fix updatedatabase.pl to apply to current master by Marc Veron > veron@veron.ch The wiki page is actually at http://wiki.koha-community.org/wiki/Age_restriction
Created attachment 11938 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restriction Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> fix updatedatabase.pl New fix updatedatabase.pl to apply to current master by Marc Veron veron@veron.ch
Created attachment 11939 [details] [review] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> New version implementing Paul's advice. See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> fix updatedatabase.pl New fix updatedatabase.pl to apply to current master by Marc Veron veron@veron.ch ...and fixed missing curly bracket after merging updatedatabase.pl
(In reply to comment #61) > Created attachment 11939 [details] [review] > BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's > age without using categories > > Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> looks good, passing QA... $ koha-qa.pl testing 1 commit(s) (applied to commit 52973fc) * b67201f BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories C4/Biblio.pm C4/Circulation.pm installer/data/mysql/kohastructure.sql installer/data/mysql/sysprefs.sql installer/data/mysql/updatedatabase.pl koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt - perlcritic-progressive tests... OK - perl -c syntax tests... OK - xt/tt_valid.t tests... OK - xt/author/valid-template.t tests... OK - t/00-valid-xml.t tests... OK
Patch pushed, well done everyone !!!
Created attachment 12132 [details] [review] Bug 7621: Followup: FIX warnings "Scalar value @values[$take] better written as $values[$take]" The previous patch introduces some perl warnings in log
Created attachment 12133 [details] [review] [SIGNED-OFF] Bug 7621: Followup: FIX warnings "Scalar value @values[$take] better written as $values[$take]" The previous patch introduces some perl warnings in log Signed-off-by: Marc Veron <veron@veron.ch> Tested with age restriction scenarios I used for development. Still works as expected.
Thanks for the follow up, Jonathan. Marc
Comment on attachment 12133 [details] [review] [SIGNED-OFF] Bug 7621: Followup: FIX warnings "Scalar value @values[$take] better written as $values[$take]" Fix with Bug 8761
adapting status
Created attachment 12547 [details] Screenshots regarding usage PDF added to show how to use the Age restriction feature (on request of http://irc.koha-community.org/irclog/koha/2012-09-26#i_1088535)
Created attachment 12558 [details] [review] Bug 7621: Follow up to clarify preference language This patch changes strings only, not functionality. It will clarify the meaning of the AgeRestrictionMarker preference.
Follow up needs sign off. Original is already in master.
Created attachment 12559 [details] [review] Bug 7621: Follow up to clarify preference language This patch changes strings only, not functionality. It will clarify the meaning of the AgeRestrictionMarker preference.
My last patch had typos.
Created attachment 12563 [details] [review] [SIGNED-OFF] Bug 7621: Follow up to clarify preference language This patch changes strings only, not functionality. It will clarify the meaning of the AgeRestrictionMarker preference. Signed-off-by: Marc Veron <veron@veron.ch> Better wording of preference instructions. No code echange involved.
(In reply to comment #74) > Created attachment 12563 [details] [review] > [SIGNED-OFF] Bug 7621: Follow up to clarify preference language > > This patch changes strings only, not functionality. It will > clarify the meaning of the AgeRestrictionMarker preference. > > Signed-off-by: Marc Veron <veron@veron.ch> > > Better wording of preference instructions. No code echange involved. passing QA, trivial patch
follow-up [SIGNED-OFF] Bug 7621: Follow up to clarify preference language pushed