Add user and ou setting types to data seed values.
authorJason Stephenson <jason@sigio.com>
Sat, 26 May 2012 18:54:56 +0000 (14:54 -0400)
committerJason Stephenson <jason@sigio.com>
Wed, 27 Jun 2012 23:15:34 +0000 (19:15 -0400)
Add coust for opac.patron_temporary_list_warn to let an ou enable
warning users when adding records to a temporary book bag.

Add cust opac.temporary_list_no_warn to let patrons disable
the warning for themselves.

Add the opac.default_list usr_setting_type. This will be used to track a
user's default bookbag.

Add the upgrade script to create new coust and custs.

Insert coust (opac.patron.temporary_list_warn) and cust
(opac.temporary_list_no_warn, opac.default_list) into the respective
tables.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.add-to-permanent-bookbag.sql [new file with mode: 0644]
Open-ILS/src/templates/opac/myopac/prefs_settings.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

index f716f1d..7429f84 100644 (file)
@@ -282,6 +282,17 @@ sub _load_lists_and_settings {
         };
         my $r = $e->json_query($q);
         $self->ctx->{bookbag_count} = $r->[0]->{'count'};
+        # Someone has requested that we use the default list's name
+        # rather than "Default List."
+        if ($exclude) {
+            $q = {
+                'select' => {'cbreb' => ['name']},
+                'from' => 'cbreb',
+                'where' => {'id' => $exclude}
+            };
+            $r = $e->json_query($q);
+            $self->ctx->{default_bookbag} = $r->[0]->{'name'};
+        }
     } else {
         return $stat;
     }
@@ -382,7 +393,7 @@ sub load_myopac_prefs_settings {
         opac.hits_per_page
         opac.default_search_location
         opac.default_pickup_location
-        opac.temporary_list_warn
+        opac.temporary_list_no_warn
     /;
 
     my $stat = $self->_load_user_with_prefs;
index db660fe..1733d49 100644 (file)
@@ -545,4 +545,24 @@ sub load_search_filter_groups {
 }
 
 
+sub check_for_temp_list_warning {
+    my $self = shift;
+    my $ctx = $self->ctx;
+    my $cgi = $self->cgi;
+
+    my $lib = $self->_get_search_lib;
+    my $warn = ($ctx->{get_org_setting}->($lib, 'opac.patron_temporary_list_warn')) ? 1 : 0;
+
+    if ($warn && $ctx->{user}) {
+        $self->_load_user_with_prefs;
+        my $map = $ctx->{user_setting_map};
+        $warn = 0 if ($$map{'opac.temporary_list_no_warn'});
+    }
+
+    # Check for a cookie disabling the warning.
+    $warn = 0 if ($warn && $cgi->cookie('no_temp_list_warn'));
+
+    return $warn;
+}
+
 1;
index 1c54059..d988a09 100644 (file)
@@ -11634,3 +11634,64 @@ INSERT into config.org_unit_setting_type
         'bool'
     );
 
+INSERT into config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'opac.patron.temporary_list_warn',
+        'opac',
+        oils_i18n_gettext(
+            'opac.patron.temporary_list_warn',
+            'Warn patrons when adding to a temporary book list',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'opac.patron.temporary_list_warn',
+            'Present a warning dialog to the patron when a patron adds a book to a temporary book bag.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    );
+
+INSERT INTO config.usr_setting_type
+    (name,grp,opac_visible,label,description,datatype)
+VALUES (
+    'opac.temporary_list_no_warn',
+    'opac',
+    TRUE,
+    oils_i18n_gettext(
+        'opac.temporary_list_no_warn',
+        'Opt out of warning when adding a book to a temporary book list',
+        'cust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.temporary_list_no_warn',
+        'Opt out of warning when adding a book to a temporary book list',
+        'cust',
+        'description'
+    ),
+    'bool'
+);
+
+INSERT INTO config.usr_setting_type
+    (name,grp,opac_visible,label,description,datatype)
+VALUES (
+    'opac.default_list',
+    'opac',
+    FALSE,
+    oils_i18n_gettext(
+        'opac.default_list',
+        'Default list to use when adding to a bookbag',
+        'cust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.default_list',
+        'Default list to use when adding to a bookbag',
+        'cust',
+        'description'
+    ),
+    'integer'
+);
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.add-to-permanent-bookbag.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.add-to-permanent-bookbag.sql
new file mode 100644 (file)
index 0000000..5c16367
--- /dev/null
@@ -0,0 +1,68 @@
+BEGIN;
+
+-- Check for the upgrade deps block
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT into config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'opac.patron.temporary_list_warn',
+        'opac',
+        oils_i18n_gettext(
+            'opac.patron.temporary_list_warn',
+            'Warn patrons when adding to a temporary book list',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'opac.patron.temporary_list_warn',
+            'Present a warning dialog to the patron when a patron adds a book to a temporary book bag.',
+            'coust',
+            'description'
+        ),
+        'bool'
+    );
+
+INSERT INTO config.usr_setting_type
+    (name,grp,opac_visible,label,description,datatype)
+VALUES (
+    'opac.temporary_list_no_warn',
+    'opac',
+    TRUE,
+    oils_i18n_gettext(
+        'opac.temporary_list_no_warn',
+        'Opt out of warning when adding a book to a temporary book list',
+        'cust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.temporary_list_no_warn',
+        'Opt out of warning when adding a book to a temporary book list',
+        'cust',
+        'description'
+    ),
+    'bool'
+);
+
+INSERT INTO config.usr_setting_type
+    (name,grp,opac_visible,label,description,datatype)
+VALUES (
+    'opac.default_list',
+    'opac',
+    FALSE,
+    oils_i18n_gettext(
+        'opac.default_list',
+        'Default list to use when adding to a bookbag',
+        'cust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.default_list',
+        'Default list to use when adding to a bookbag',
+        'cust',
+        'description'
+    ),
+    'integer'
+);
+
+COMMIT;
index 864ca99..6157130 100644 (file)
@@ -78,9 +78,9 @@
                     </td>
                 </tr>
                 <tr>
-                    <td>[% l('Warn when adding to temporary book list?') %]</td>
+                    <td>[% l('Skip warning when adding to temporary book list?') %]</td>
                     <td>
-                        [% setting = 'opac.temporary_list_warn' %]
+                        [% setting = 'opac.temporary_list_no_warn' %]
                         <input name='[% setting %]' type="checkbox"
                             [% IF ctx.user_setting_map.$setting %] checked='checked' [% END %]/>
                     </td>
index 201a4e9..16e55cf 100644 (file)
                 <a href="[% href %]">[% l('Temporary List') %]</a>
             </li>
             [% IF ctx.user_setting_map.$dsetting;
+               label = (ctx.default_bookbag) ? ctx.default_bookbag : l('Default List');
                class = (ctx.bookbags.size) ? "default divider" : "default";
                href = mkurl(ctx.opac_root _ '/myopac/list/update',
                             {action => 'add_rec', list => ctx.user_setting_map.$dsetting,
                              record => ctx.bre_id, anchor => ctx.bre_id}, stop_parms);
             %]
             <li class="[% class %]">
-                <a href="[% href %]">[% l('Default List') %]</a>
+                <a href="[% href %]">[% label %]</a>
             </li>
             [% END %]
             [% IF ctx.bookbags.size;
index 0a753b0..e16852b 100644 (file)
                                                                     </li>
                                                                     [% IF ctx.user_setting_map.$dsetting;
                                                                        class = (ctx.bookbags.size) ? "default divider" : "default";
+                                                                       label = (ctx.default_bookbag) ? ctx.default_bookbag : l('Default List');
                                                                        href = mkurl(ctx.opac_root _ '/myopac/list/update',
                                                                                 {action => 'add_rec', list => ctx.user_setting_map.$dsetting,
                                                                                  record => rec.id, anchor => 'record_' _ rec.id}, 1);
                                                                     %]
                                                                     <li class="[% class %]">
-                                                                    <a href="[% href %]">[% l('Default List') %]</a>
+                                                                    <a href="[% href %]">[% label %]</a>
                                                                     </li>
                                                                     [% END %]
                                                                     [% IF ctx.bookbags.size;
                                                                     </li>
                                                                     <li class="new">
                                                                     <a href="[% mkurl(ctx.opac_root _ '/myopac/lists',
-                                                                                     {add_rec => rec.id, anchor => 'record_' _ rec.id}, 0) %]">
+                                                                                      {add_rec => rec.id, anchor => 'record_' _ rec.id}, 0) %]">
                                                                     [% l('Add to new list') %]
                                                                     </a>
                                                                     </li>