lp1908440 editing the photo url in the staff client
authorRogan Hamby <rogan.hamby@gmail.com>
Wed, 24 Mar 2021 13:12:07 +0000 (09:12 -0400)
committerJason Boyer <JBoyer@EquinoxInitiative.org>
Tue, 11 May 2021 23:46:46 +0000 (19:46 -0400)
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
Signed-off-by: Seth Erickson <serickson@tds.lib.mn.us>
Signed-off-by: Jason Boyer <JBoyer@EquinoxInitiative.org>

Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.au_photo_url.sql [new file with mode: 0644]
Open-ILS/src/templates/actor/user/register_table.tt2
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/web/js/ui/default/actor/user/register.js
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
docs/RELEASE_NOTES_NEXT/Circulation/photo_url.adoc [new file with mode: 0644]

index 23021c7..4f0a782 100644 (file)
@@ -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);
index c694c9a..85d9ace 100644 (file)
@@ -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 (file)
index 0000000..b631e1f
--- /dev/null
@@ -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;
index 8235c65..5ad5dfd 100644 (file)
@@ -35,6 +35,7 @@
     <tr fmclass='au' fmfield='ident_type' required='required'></tr>
     <tr fmclass='au' fmfield='ident_value'></tr>
     <tr fmclass='au' fmfield='ident_value2'><td></td><td id='parentGuardian'></td></t></tr>
+    <tr fmclass='au' fmfield='photo_url'></tr>
     <tr fmclass='au' fmfield='email'></tr>
     <tr fmclass='au' fmfield='day_phone'></tr>
     <tr fmclass='au' fmfield='evening_phone'></tr>
index d15538e..052fafd 100644 (file)
@@ -456,6 +456,17 @@ within the "form" by name for validation.
   </div>
 </div>
 
+<!-- PHOTO_URL -->
+<div class="row reg-field-row" ng-show="show_field('au.photo_url')">
+  [% draw_field_label('au', 'photo_url') %]
+  [% draw_form_input('au', 'photo_url', '', 'photo_url') %]
+  <div class="col-md-3 patron-reg-example">
+    <span ng-if="org_settings['ui.patron.edit.au.photo_url.example']">
+      [% l('Example: [_1]',
+        "{{org_settings['ui.patron.edit.au.photo_url.example']}}") %]
+    </span>
+  </div>
+</div>
 
 <!-- EMAIL -->
 <div class="row reg-field-row" ng-show="show_field('au.email')">
index 0e9ae91..9b3677a 100644 (file)
@@ -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(
index 0d6394d..d80385c 100644 (file)
@@ -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 (file)
index 0000000..b9912a7
--- /dev/null
@@ -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.