From 0c4e237e47681d1ea809795e4fd7f820288b47cf Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Wed, 24 Mar 2021 09:12:07 -0400 Subject: [PATCH] lp1908440 editing the photo url in the staff client Signed-off-by: Rogan Hamby Signed-off-by: Seth Erickson Signed-off-by: Jason Boyer --- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 9 +++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 31 +++++++- Open-ILS/src/sql/Pg/upgrade/xxxx.au_photo_url.sql | 84 ++++++++++++++++++++++ .../src/templates/actor/user/register_table.tt2 | 1 + .../src/templates/staff/circ/patron/t_edit.tt2 | 11 +++ Open-ILS/web/js/ui/default/actor/user/register.js | 18 +++++ .../web/js/ui/default/staff/circ/patron/regctl.js | 4 ++ docs/RELEASE_NOTES_NEXT/Circulation/photo_url.adoc | 3 + 8 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.au_photo_url.sql create mode 100644 docs/RELEASE_NOTES_NEXT/Circulation/photo_url.adoc diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 23021c7063..4f0a78258c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -489,6 +489,10 @@ sub update_patron { return $e->die_event unless $e->allowed('BAR_PATRON', $patron->home_ou); } + if(($patron->photo_url)) { + return $e->die_event unless + $e->allowed('UPDATE_USER_PHOTO_URL', $patron->home_ou); + } } else { $new_patron = $patron; @@ -506,6 +510,11 @@ sub update_patron { 'au.barred' : 'au.unbarred'; } + if($old_patron->photo_url ne $new_patron->photo_url) { + my $perm = 'UPDATE_USER_PHOTO_URL'; + return $e->die_event unless $e->allowed($perm, $patron->home_ou); + } + # update the password by itself to avoid the password protection magic if ($patron->passwd && $patron->passwd ne $old_patron->passwd) { modify_migrated_user_password($e, $patron->id, $patron->passwd); diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index c694c9ad84..85d9aced85 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1958,7 +1958,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( 630, 'VIEW_GEOLOCATION_SERVICES', oils_i18n_gettext(630, 'View geographic location services', 'ppl', 'description')), ( 631, 'ADMIN_GEOLOCATION_SERVICES', oils_i18n_gettext(631, - 'Administer geographic location services', 'ppl', 'description')) + 'Administer geographic location services', 'ppl', 'description')), + ( 632, 'UPDATE_USER_PHOTO_URL', oils_i18n_gettext(632, + 'Update the user photo url field in patron registration and editor', 'ppl', 'description')) ; @@ -2439,7 +2441,8 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) 'PATRON_EXCEEDS_FINES.override', 'PATRON_EXCEEDS_OVERDUE_COUNT.override', 'RETRIEVE_RESERVATION_PULL_LIST', - 'UPDATE_HOLD'); + 'UPDATE_HOLD', + 'UPDATE_USER_PHOTO_URL'); -- Add advanced circulation permissions to the Circulation Admin group @@ -5688,6 +5691,30 @@ INSERT into config.org_unit_setting_type 'For staff-placed holds, in the absence of a patron preferred pickup location, fall back to using the staff workstation OU (rather than patron home OU)', 'coust', 'description'), 'bool', null) +,( 'ui.patron.edit.au.photo_url.require', 'gui', + oils_i18n_gettext('ui.patron.edit.au.photo_url.require', + 'Require Photo URL field on patron registration', + 'coust', 'label'), + oils_i18n_gettext('ui.patron.edit.au.photo_url.require', + 'The Photo URL field will be required on the patron registration screen.', + 'coust', 'description'), + 'bool', null) +,( 'ui.patron.edit.au.photo_url.show', 'gui', + oils_i18n_gettext('ui.patron.edit.au.photo_url.show', + 'Show Photo URL field on patron registration', + 'coust', 'label'), + oils_i18n_gettext('ui.patron.edit.au.photo_url.show', + 'The Photo URL field will be shown on the patron registration screen. Showing a field makes it appear with required fields even when not required. If the field is required this setting is ignored.', + 'coust', 'description'), + 'bool', null) +,( 'ui.patron.edit.au.photo_url.suggest', 'gui', + oils_i18n_gettext('ui.patron.edit.au.photo_url.suggest', + 'Suggest Photo URL field on patron registration', + 'coust', 'label'), + oils_i18n_gettext('ui.patron.edit.au.photo_url.suggest', + 'The Photo URL field will be suggested on the patron registration screen. Suggesting a field makes it appear when suggested fields are shown. If the field is shown or required this setting is ignored.', + 'coust', 'description'), + 'bool', null) ; UPDATE config.org_unit_setting_type diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.au_photo_url.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.au_photo_url.sql new file mode 100644 index 0000000000..b631e1f68b --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.au_photo_url.sql @@ -0,0 +1,84 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'ui.patron.edit.au.photo_url.require', + 'gui', + oils_i18n_gettext( + 'ui.patron.edit.au.photo_url.require', + 'Require Photo URL field on patron registration', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'ui.patron.edit.au.photo_url.require', + 'The Photo URL field will be required on the patron registration screen.', + 'coust', + 'description' + ), + 'bool' + ); + +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'ui.patron.edit.au.photo_url.show', + 'gui', + oils_i18n_gettext( + 'ui.patron.edit.au.photo_url.show', + 'Show Photo URL field on patron registration', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'ui.patron.edit.au.photo_url.show', + 'The Photo URL field will be shown on the patron registration screen. Showing a field makes it appear with required fields even when not required. If the field is required this setting is ignored.', + 'coust', + 'description' + ), + 'bool' + ); + +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'ui.patron.edit.au.photo_url.suggest', + 'gui', + oils_i18n_gettext( + 'ui.patron.edit.au.photo_url.suggest', + 'Suggest Photo URL field on patron registration', + 'coust', + 'label' + ), + + oils_i18n_gettext( + 'ui.patron.edit.au.photo_url.suggest', + 'The Photo URL field will be suggested on the patron registration screen. Suggesting a field makes it appear when suggested fields are shown. If the field is shown or required this setting is ignored.', + 'coust', + 'description' + ), + 'bool' + ); + +INSERT INTO permission.perm_list ( id, code, description ) VALUES +( 632, 'UPDATE_USER_PHOTO_URL', oils_i18n_gettext( 632, + 'Update the user photo url field in patron registration and editor', 'ppl', 'description' )) +; + +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) + SELECT + pgt.id, perm.id, aout.depth, FALSE + FROM + permission.grp_tree pgt, + permission.perm_list perm, + actor.org_unit_type aout + WHERE + pgt.name = 'Circulators' AND + aout.name = 'System' AND + perm.code = 'UPDATE_USER_PHOTO_URL' +; + +COMMIT; diff --git a/Open-ILS/src/templates/actor/user/register_table.tt2 b/Open-ILS/src/templates/actor/user/register_table.tt2 index 8235c65772..5ad5dfd785 100644 --- a/Open-ILS/src/templates/actor/user/register_table.tt2 +++ b/Open-ILS/src/templates/actor/user/register_table.tt2 @@ -35,6 +35,7 @@ + diff --git a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 index d15538e1b0..052fafd7f4 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -456,6 +456,17 @@ within the "form" by name for validation. + +
+ [% draw_field_label('au', 'photo_url') %] + [% draw_form_input('au', 'photo_url', '', 'photo_url') %] +
+ + [% l('Example: [_1]', + "{{org_settings['ui.patron.edit.au.photo_url.example']}}") %] + +
+
diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index 0e9ae91a54..9b3677a3cc 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -153,6 +153,9 @@ function load() { 'ui.patron.edit.au.ident_value.suggest', 'ui.patron.edit.au.ident_value2.show', 'ui.patron.edit.au.ident_value2.suggest', + 'ui.patron.edit.au.photo_url.require', + 'ui.patron.edit.au.photo_url.show', + 'ui.patron.edit.au.photo_url.suggest', 'ui.patron.edit.au.email.require', 'ui.patron.edit.au.email.show', 'ui.patron.edit.au.email.suggest', @@ -1207,6 +1210,21 @@ function fleshFMRow(row, fmcls, args) { } } break; + if(fmfield == 'photo_url') { + // Are we allowed to update the photo url? + var permission = 'UPDATE_USER_PHOTO_URL'; + var ou = staff.ws_ou(); + if(fmObject.home_ou() != null) { + ou = fmObject.home_ou(); + } + var resp = fieldmapper.standardRequest( + ['open-ils.actor', 'open-ils.actor.user.perm.check'], + { params : [openils.User.authtoken, staff.id(), ou, [permission] ] } + ); + if(resp[0]) { // No permission to edit the photo url + disabled = true; + } + } case 'ac' : if(!editCard) editCard = patron.card(); fmObject = editCard; break; case 'aua' : fmObject = patron.addresses().filter( diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js index 0d6394db55..d80385cc4a 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js @@ -358,6 +358,9 @@ angular.module('egCoreMod') 'ui.patron.edit.au.ident_value.suggest', 'ui.patron.edit.au.ident_value2.show', 'ui.patron.edit.au.ident_value2.suggest', + 'ui.patron.edit.au.photo_url.require', + 'ui.patron.edit.au.photo_url.show', + 'ui.patron.edit.au.photo_url.suggest', 'ui.patron.edit.au.email.require', 'ui.patron.edit.au.email.show', 'ui.patron.edit.au.email.suggest', @@ -1517,6 +1520,7 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , 'au.pref_family_name' : 2, 'au.ident_type' : 3, 'au.ident_type2' : 2, + 'au.photo_url' : 2, 'au.home_ou' : 3, 'au.profile' : 3, 'au.expire_date' : 3, diff --git a/docs/RELEASE_NOTES_NEXT/Circulation/photo_url.adoc b/docs/RELEASE_NOTES_NEXT/Circulation/photo_url.adoc new file mode 100644 index 0000000000..b9912a72f3 --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Circulation/photo_url.adoc @@ -0,0 +1,3 @@ +== Photo URL == + +Editing of the patron's photo URL can now be done in the staff client's patron registration and edit screen. A new permission UPDATE_USER_PHOTO_URL controls the ability to actually edit the field. -- 2.11.0