started verification review UI, also SCHEMA CHANGES
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 6 Sep 2012 20:16:16 +0000 (16:16 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 21 Sep 2012 15:07:00 +0000 (11:07 -0400)
It just doesn't work for me to not have url_verify.url directly related
to url_verify.session.  When dealing with the "root" URL in a redirect chain,
you can get the related session through url_selector, but not when
you have any later URL in the chain.  The only way for IDL perms to work
would be to have a link to a view using a CTE to find the "root" URL.

That's too complex, so instead of that I've just added a session fkey on
url_verify.url.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
12 files changed:
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm
Open-ILS/src/sql/Pg/075.schema.url_verify.sql
Open-ILS/src/sql/Pg/076.functions.url_verify.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.url_verify.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.functions.url_verify.sql
Open-ILS/src/templates/url_verify/review_attempt.tt2 [new file with mode: 0644]
Open-ILS/src/templates/url_verify/select_urls.tt2
Open-ILS/web/js/dojo/openils/URLVerify/ReviewAttempt.js [new file with mode: 0644]
Open-ILS/web/js/dojo/openils/URLVerify/SelectURLs.js
Open-ILS/web/js/dojo/openils/URLVerify/nls/URLVerify.js
Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js

index 65b2939..3405dde 100644 (file)
@@ -9338,7 +9338,7 @@ SELECT  usr,
         reporter:label="URL Verification Session"
     >
         <fields oils_persist:primary="id" oils_persist:sequence="url_verify.session_id_seq">
-            <field reporter:label="ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="Session ID" name="id" reporter:datatype="id"/>
             <field reporter:label="Name" name="name" reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="Owning Library" name="owning_lib" reporter:datatype="org_unit" oils_obj:required="true"/>
             <field reporter:label="Creator" name="creator" reporter:datatype="link" oils_obj:required="true"/>
@@ -9404,7 +9404,7 @@ SELECT  usr,
         reporter:label="URL Verification URL Selector"
     >
         <fields oils_persist:primary="id" oils_persist:sequence="url_verify.url_selector_id_seq">
-            <field reporter:label="ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="URL Selector ID" name="id" reporter:datatype="id"/>
             <field reporter:label="XPath" name="xpath" reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="Session" name="session" reporter:datatype="link" oils_obj:required="true"/>
             <field reporter:label="URLs" name="urls" reporter:datatype="link" oils_persist:virtual="true"/>
@@ -9442,9 +9442,10 @@ SELECT  usr,
         reporter:label="URL Verification URL"
     >
         <fields oils_persist:primary="id" oils_persist:sequence="url_verify.url_id_seq">
-            <field reporter:label="ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="URL ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="Redirected From" name="redirect_from" reporter:datatype="link"/>
                        <field reporter:label="Container Item" name="item" reporter:datatype="link" oils_obj:required="true"/>
+                       <field reporter:label="Session" name="session" reporter:datatype="link" oils_obj:required="true"/>
                        <field reporter:label="URL Selector" name="url_selector" reporter:datatype="link"/>
             <field reporter:label="Tag" name="tag" reporter:datatype="text"/>
             <field reporter:label="Subfield" name="subfield" reporter:datatype="text"/>
@@ -9463,7 +9464,8 @@ SELECT  usr,
 
         <links>
             <link field="redirect_from" reltype="has_a" key="id" map="" class="uvu"/>
-            <link field="item" reltype="has_a" key="id" map="" class="uvsbrem" /><!-- surprise! -->
+            <link field="item" reltype="has_a" key="id" map="" class="uvsbrem" />
+            <link field="session" reltype="has_a" key="id" map="" class="uvs"/>
             <link field="url_selector" reltype="has_a" key="id" map="" class="uvus"/>
             <link field="verifications" reltype="has_many" key="url" map="" class="uvuv"/>
         </links>
@@ -9471,16 +9473,16 @@ SELECT  usr,
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
                 <create permission="URL_VERIFY">
-                    <context link="url_selector" jump="session" field="owning_lib"/>
+                    <context link="session" field="owning_lib"/>
                 </create>
                 <retrieve permission="URL_VERIFY">
-                    <context link="url_selector" jump="session" field="owning_lib"/>
+                    <context link="session" field="owning_lib"/>
                 </retrieve>
                 <update permission="URL_VERIFY">
-                    <context link="url_selector" jump="session" field="owning_lib"/>
+                    <context link="session" field="owning_lib"/>
                 </update>
                 <delete permission="URL_VERIFY">
-                    <context link="url_selector" jump="session" field="owning_lib"/>
+                    <context link="session" field="owning_lib"/>
                 </delete>
             </actions>
         </permacrud>
@@ -9495,7 +9497,7 @@ SELECT  usr,
         reporter:label="URL Verification Attempt"
     >
         <fields oils_persist:primary="id" oils_persist:sequence="url_verify.verification_attempt_id_seq">
-            <field reporter:label="ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="Attempt ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="User" name="usr" reporter:datatype="link"/>
                        <field reporter:label="Session" name="session" reporter:datatype="link"/>
             <field reporter:label="Start Time" name="start_time" reporter:datatype="timestamp"/>
@@ -9534,7 +9536,7 @@ SELECT  usr,
         reporter:label="URL Verification"
     >
         <fields oils_persist:primary="id" oils_persist:sequence="url_verify.url_verification_id_seq">
-            <field reporter:label="ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="Verification ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="URL" name="url" reporter:datatype="link"/>
                        <field reporter:label="Attempt" name="attempt" reporter:datatype="link"/>
             <field reporter:label="Request Time" name="req_time" reporter:datatype="timestamp"/>
index 0e49a00..4b4e3ba 100644 (file)
@@ -589,6 +589,7 @@ sub verify_one_url {
 
         if (my $loc = $res->headers->{location}) {
             $redir_url = Fieldmapper::url_verify::url->new;
+            $redir_url->session($attempt->session);
             $redir_url->redirect_from($url->id);
             $redir_url->full_url($loc);
 
index db42861..653d028 100644 (file)
@@ -42,6 +42,7 @@ CREATE TABLE url_verify.url (
     id              SERIAL  PRIMARY KEY,
     redirect_from   INT     REFERENCES url_verify.url(id) DEFERRABLE INITIALLY DEFERRED,
     item            INT     REFERENCES container.biblio_record_entry_bucket_item (id) DEFERRABLE INITIALLY DEFERRED,
+    session         INT     REFERENCES url_verify.session (id) DEFERRABLE INITIALLY DEFERRED,
     url_selector    INT     REFERENCES url_verify.url_selector (id) DEFERRABLE INITIALLY DEFERRED,
     tag             TEXT,    
     subfield        TEXT,    
index a49e5fc..5443d51 100644 (file)
@@ -91,8 +91,8 @@ BEGIN
                     JOIN container.biblio_record_entry_bucket_item c ON (c.target_biblio_record_entry = b.id)
               WHERE c.id = item_id;
 
-            INSERT INTO url_verify.url (item, url_selector, tag, subfield, ord, full_url)
-              VALUES ( item_id, current_selector.id, current_tag, current_sf, current_ord, current_url);
+            INSERT INTO url_verify.url (session, item, url_selector, tag, subfield, ord, full_url)
+              VALUES ( session_id, item_id, current_selector.id, current_tag, current_sf, current_ord, current_url);
 
             current_url_pos := current_url_pos + 1;
             current_ord := current_ord + 1;
index 82da8ee..42e5444 100644 (file)
@@ -29,6 +29,7 @@ CREATE TABLE url_verify.url (
     redirect_from   INT     REFERENCES url_verify.url(id) DEFERRABLE INITIALLY DEFERRED,
     item            INT     REFERENCES container.biblio_record_entry_bucket_item (id) DEFERRABLE INITIALLY DEFERRED,
     url_selector    INT     REFERENCES url_verify.url_selector (id) DEFERRABLE INITIALLY DEFERRED,
+    session         INT     REFERENCES url_verify.session (id) DEFERRABLE INITIALLY DEFERRED,
     tag             TEXT,
     subfield        TEXT,
     ord             INT,
index f8a5bad..bed0ae3 100644 (file)
@@ -75,8 +75,8 @@ BEGIN
                     JOIN container.biblio_record_entry_bucket_item c ON (c.target_biblio_record_entry = b.id)
               WHERE c.id = item_id;
 
-            INSERT INTO url_verify.url (item, url_selector, tag, subfield, ord, full_url)
-              VALUES ( item_id, current_selector.id, current_tag, current_sf, current_ord, current_url);
+            INSERT INTO url_verify.url (session, item, url_selector, tag, subfield, ord, full_url)
+              VALUES ( session_id, item_id, current_selector.id, current_tag, current_sf, current_ord, current_url);
 
             current_url_pos := current_url_pos + 1;
             current_ord := current_ord + 1;
diff --git a/Open-ILS/src/templates/url_verify/review_attempt.tt2 b/Open-ILS/src/templates/url_verify/review_attempt.tt2
new file mode 100644 (file)
index 0000000..093d63c
--- /dev/null
@@ -0,0 +1,64 @@
+[% WRAPPER base.tt2 %]
+[% ctx.page_title = "Link Checker - Review Verification Attempt" %]
+<script type="text/javascript">
+    dojo.require("dijit.form.Button");
+    dojo.require("openils.widget.FlattenerGrid");
+    dojo.require("openils.widget.ProgressDialog");
+    dojo.require("openils.Util");
+    dojo.require("openils.CGI");
+    dojo.require("openils.URLVerify.ReviewAttempt");
+
+    /* Minimize namespace pollution, but save us some typing later. */
+    var module = openils.URLVerify.ReviewAttempt;
+
+    openils.Util.addOnLoad(
+        function() {
+            module.setup(grid, progress_dialog);
+        }
+    );
+</script>
+<style type="text/css">
+    .url-verify-attempt-info { font-style: italic; }
+</style>
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+    <div dojoType="dijit.layout.ContentPane"
+         layoutAlign="top" class="oils-header-panel">
+        <div>[% ctx.page_title %]</div>
+        <div>
+            <!-- buttons here -->
+        </div>
+    </div>
+    <div class="oils-acq-basic-roomy">
+        <!-- any blurb to precede grid can go here -->
+    </div>
+    <table
+        jsid="grid"
+        dojoType="openils.widget.FlattenerGrid"
+        columnPersistKey='"url_verify.review_attempt"'
+        autoHeight="10"
+        editOnEnter="false"
+        autoFieldFields="['url']"
+        autoFieldFieldsUnsorted="['url']"
+        autoCoreFields="true"
+        autoCoreFieldsFilter="true"
+        autoCoreFieldsUnsorted="true"
+        fetchLock="true"
+        mapExtras="{attempt_id:{path:'attempt.id',filter:true,_label:'[% l("Attempt ID") %]'}}"
+        showLoadFilter="true"
+        fmClass="'uvuv'">
+        <thead>
+            <tr>
+                <th field="url_redirect_from" fpath="url.redirect_from"></th>
+                <th field="title" fpath="url.item.target_biblio_record_entry.simple_record.title"></th>
+                <th field="author" fpath="url.item.target_biblio_record_entry.simple_record.author"></th>
+                <th field="isbn" fpath="url.item.target_biblio_record_entry.simple_record.isbn" _visible="false"></th>
+                <th field="issn" fpath="url.item.target_biblio_record_entry.simple_record.issn" _visible="false"></th>
+                <th field="bib_id" fpath="url.item.target_biblio_record_entry.id" _visible="false"></th>
+            </tr>
+        </thead>
+    </table>
+</div>
+<div class="hidden">
+    <div dojoType="openils.widget.ProgressDialog" jsId="progress_dialog"></div>
+</div>
+[% END %]
index 525bd45..c8d94ff 100644 (file)
@@ -42,7 +42,6 @@
         columnPersistKey='"url_verify.select_url"'
         autoHeight="10"
         editOnEnter="false"
-        autoFieldFields="null"
         autoCoreFields="true"
         autoCoreFieldsFilter="true"
         autoCoreFieldsUnsorted="true"
diff --git a/Open-ILS/web/js/dojo/openils/URLVerify/ReviewAttempt.js b/Open-ILS/web/js/dojo/openils/URLVerify/ReviewAttempt.js
new file mode 100644 (file)
index 0000000..ac5d30b
--- /dev/null
@@ -0,0 +1,40 @@
+if (!dojo._hasResource["openils.URLVerify.ReviewAttempt"]) {
+    dojo.require("dojo.string");
+    dojo.require("openils.CGI");
+    dojo.require("openils.Util");
+
+    dojo.requireLocalization("openils.URLVerify", "URLVerify");
+
+    dojo._hasResource["openils.URLVerify.ReviewAttempt"] = true;
+    dojo.provide("openils.URLVerify.ReviewAttempt");
+
+    dojo.declare("openils.URLVerify.ReviewAttempt", null, {});
+
+    /* Take care that we add nothing to the global namespace.
+     * This is not an OO module so much as a container for
+     * functions needed by a specific interface. */
+
+(function() {
+    var module = openils.URLVerify.ReviewAttempt;
+    var localeStrings =
+        dojo.i18n.getLocalization("openils.URLVerify", "URLVerify");
+
+    module.setup = function(grid, progress_dialog) {
+        var cgi = new openils.CGI();
+        module.attempt_id = cgi.param("attempt_id");
+
+        module.grid = grid;
+
+        module.grid.setBaseQuery({"attempt_id": module.attempt_id});
+
+        module.grid.refresh();
+        // Alternative to grid.refresh() once filter is set up
+        //module.grid.fetchLock = false;
+        //module.grid.filterUi.doApply();
+
+        module.progress_dialog = progress_dialog;
+    };
+
+}());
+
+}
index b4c6de1..bd7b733 100644 (file)
@@ -65,8 +65,10 @@ if (!dojo._hasResource["openils.URLVerify.SelectURLs"]) {
                             "progress": r.total_excluding_redirects
                         });
 
-                        if (r.attempt)
+                        if (r.attempt) {
                             module.update_attempt_display(r.attempt);
+                            module.attempt = r.attempt;
+                        }
                     }
                 },
                 "oncomplete": function() {
@@ -74,7 +76,9 @@ if (!dojo._hasResource["openils.URLVerify.SelectURLs"]) {
                         "title", localeStrings.REDIRECTING
                     );
                     module.progress_dialog.show(true);
-                    console.error("would redirect here XXX TODO"); // XXX TODO
+                    location.href = oilsBasePath +
+                        "/url_verify/review_attempt?attempt_id=" +
+                        module.attempt.id();
                 }
             }
         )
index 900f125..2db8ca8 100644 (file)
@@ -8,7 +8,7 @@
     "INTERFACE_SETUP": "Setting up interface ...",
     "VERIFY_ALL": "Click 'OK' to verify ALL the URLs found in this session.  Click 'Cancel' if the selected, visible URLs are the only ones you want verified.",
     "VERIFICATION_DIALOG": "Verifying URLs ...",
-    "VERIFICATION_ATTEMPT_ID": "Last verification attempt ID: ${0}",
+    "VERIFICATION_ATTEMPT_ID": "Verification attempt ID: ${0}",
     "VERIFICATION_ATTEMPT_START": "Attempt start time: ${0}",
     "VERIFICATION_ATTEMPT_FINISH": "Attempt finish time: ${0}"
 }
index 1bb4a92..7adeb65 100644 (file)
@@ -20,6 +20,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
             "autoCoreFieldsUnsorted": false,
             "autoCoreFieldsFilter": false,
             "autoFieldFields": null,
+            "autoFieldFieldsUnsorted": null, /* array, subset of autoFieldFields */
             "showLoadFilter": false,    /* use FlattenerFilter(Dialog|Pane) */
             "filterAlwaysInDiv": null,  /* use FlattenerFilterPane and put its
                                            content in this HTML element */
@@ -284,15 +285,22 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
             },
 
             "_getAutoFieldFields": function(fmclass) {
-                return dojo.clone(
+                var field_list = dojo.clone(
                     fieldmapper.IDL.fmclasses[fmclass].fields)
                 .filter(
-                    function(field) {
-                        return !field.virtual && field.datatype != "link";
-                    }
-                ).sort(
-                    function(a, b) { return a.label > b.label ? 1 : -1; }
+                    function(f) { return !f.virtual && f.datatype != "link"; }
                 );
+                
+                /* Sort fields unless the class is named in grid property
+                 * 'autoFieldFieldsUnsorted' (array). */
+                if (!dojo.isArray(this.autoFieldFieldsUnsorted) ||
+                        !this.autoFieldFieldsUnsorted[fmclass]) {
+                    field_list = field_list.sort(
+                        function(a, b) { return a.label > b.label ? 1 : -1; }
+                    );
+                }
+
+                return field_list;
             },
 
             /* Take our core class (this.fmClass) and add table columns for
@@ -311,7 +319,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                 }
 
                 dojo.forEach(
-                    fields, function(f) {
+                    fields, dojo.hitch(this, function(f) {
                         if (f.datatype == "link" || f.virtual)
                             return;
 
@@ -329,7 +337,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                             "fsort": true,
                             "ffilter": this.autoCoreFieldsFilter
                         });
-                    }
+                    })
                 );
             },
 
@@ -922,7 +930,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) {
                                                    that always gets mixed in
                                                    with whatever you do in the
                                                    filter dialog */
-                this._baseQuery = dojo.clone(this.attr("query", query));
+                this._baseQuery = dojo.clone(this.query = query);
             }
         }
     );