https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17499
Marcel de Rooy <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #64035|0 |1 is obsolete| | Attachment #64036|0 |1 is obsolete| | Attachment #64037|0 |1 is obsolete| | Attachment #64038|0 |1 is obsolete| | Attachment #64039|0 |1 is obsolete| | Attachment #64040|0 |1 is obsolete| | Attachment #64041|0 |1 is obsolete| | Attachment #64042|0 |1 is obsolete| | Attachment #64043|0 |1 is obsolete| | Attachment #64044|0 |1 is obsolete| | Attachment #64795|0 |1 is obsolete| | --- Comment #48 from Marcel de Rooy <[email protected]> --- Created attachment 66686 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=66686&action=edit Bug 17499: Add Koha-objects for messaging preferences This patch adds Koha-objects for messaging preferences. This patch does not add any extra logic into these objects. Includes test coverage for basic usage. To test: 1. prove t/db_dependent/Koha/Patron/Message/* Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Add useful Koha::Exceptions This patch adds some basic Koha::Exceptions that will be useful. Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Add basic validation for messaging preference This patch adds simple validation for messaging preferences. The validation includes - check that only either borrowernumber or categorycode is given, but not both - throw exception if patron for the given borrowernumber is not found - throw exception if category for the given categorycode is not found - throw exception if days in advance cannot be configured - throw exception if days in advance configuration is invalid (value between 0-30) - throw exception if digest is not available To test: 1. Run t/db_dependent/Koha/Patron/Message/Preferences.t Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Throw an exception on duplicate messaging preference When trying to add a duplicate messaging preference that has the same borrowernumber or category, and message_attribute_id as another preference, throw Koha::Exceptions::DuplicateObject. To test: 1. Run t/db_dependent/Koha/Patron/Message/Preferences.t Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Add a method for getting messaging options This patch adds a method for getting available messaging options. To test: 1. Run t/db_dependent/Koha/Patron/Message/Preferences.t Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Add a method for setting default messaging preferences This patch adds a method Koha::Patron::Message::Preference->new_from_default that can be used to add category's default messaging preferences to patron for a given message type. Example call: Koha::Patron::Message::Preference->new_from_default({ borrowernumber => 123, categorycode => "ABC", message_attribute_id => 1, }); Also adds a simple method for Koha::Patron, set_default_messaging_preferences. Usage: $patron->set_default_messaging_preferences() To test: 1. Run t/db_dependent/Koha/Patron/Message/Preferences.t Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Improve object usability by enabling direct access to transport preferences Since messaging preference is a feature that has multiple related database tables, usage via Koha-objects is sometimes frustrating. This patch adds a feature for Koha::Patron::Message::Preference which enables access to message transport preferences directly via this object. It allows us to skip calls to Koha::Patron::Message::Transport::Preference(s) because we can now get and set via K::P::M::Preference. Get: $preference->message_transport_types Returns a hashref, where each key is stored transport type and value for the key is letter code for the transport. Set: $preference->set({ message_transport_types => ['sms'] }) or $preference->message_transport_types('email', 'sms') or $preference->message_transport_types(['email', 'sms']) Returns $self (Koha::Patron::Message::Preference object) To test: 1. Run t/db_dependent/Koha/Patron/Message/Preferences.t Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: Simplify searching by message_name This patch adds optional search & find parameter message_name for Koha::Patron::Message::Preferences->search and ->find. This simplifies object usage by allowing us to skip joins or finding the attribute id ourselves. prove -v t/db_dependent/Koha/Patron/Message/Preferences.t turns green Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: (follow-up) Bugfix for validation - Bugfix for days_in_advance and wants_digest validation. Have to check definedness of value instead the value itself. - Fixes broken tests caused by above update. - Adding a missing unit test for wants_digest validation - Minor edits to exception messages. - Throwing exception for invalid message_attribute_id. Incl. unit test Tested again, prove -v t/db_dependent/Koha/Patron/Message/Preferences.t turns green prove -v t/db_dependent/Koha/Patron/Message/* turns green Signed-off-by: Marc Véron <[email protected]> Signed-off-by: Josef Moravec <[email protected]> Bug 17499: (follow-up) Bugfix for validation, 2 Remove duplicate validation for digest availability. This is already checked in $preference->validate(). Set values for current object before validating messaging transport types, not the other way around as it was before this patch. Also prevents a crash when patron has messaging transport type selected for a message for which it should not be available. This patch logs it with as a warning, and only throws an exception when attempting to set it. To test: 1. prove t/db_dependent/Koha/Patron/Message/* Signed-off-by: Josef Moravec <[email protected]> Bug 17499: (follow-up) Add information on digest being the only option to get_options If a library wants to force digest on a message type, add this information to Koha::Patron::Message::Preferences->get_options. Signed-off-by: Marcel de Rooy <[email protected]> Squashed 11 commits during QA. -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
