diff --git a/resources/sql/youyesyet.postgres.overrides.sql b/resources/sql/youyesyet.postgres.overrides.sql index dad6bce..d0c7a9b 100644 --- a/resources/sql/youyesyet.postgres.overrides.sql +++ b/resources/sql/youyesyet.postgres.overrides.sql @@ -1,3 +1,22 @@ +------------------------------------------------------------------------ +-- User `youyesyet` (the app, and less secure parts of the site) +-- must have the permissions of `canvassers`. +------------------------------------------------------------------------ +DO +$do$ +BEGIN + IF NOT EXISTS ( + SELECT -- SELECT list can stay empty for this + FROM pg_catalog.pg_roles + WHERE rolname = 'youyesyet') THEN + + CREATE ROLE youyesyet LOGIN PASSWORD 'thisisnotsecure'; + END IF; +END +$do$; + +grant canvassers to youyesyet; + ------------------------------------------------------------------------ -- convenience view lv_followupactions of entity followupactions for -- lists, et cetera @@ -23,3 +42,4 @@ WHERE followupactions.request_id = followuprequests.id AND visits.address_id = addresses.id AND followupactions.actor = canvassers.id ; +GRANT SELECT ON lv_followupactions TO canvassers, issueexperts; diff --git a/resources/templates/issue-expert/request.html b/resources/templates/issue-expert/request.html index 295ba19..6207c25 100644 --- a/resources/templates/issue-expert/request.html +++ b/resources/templates/issue-expert/request.html @@ -36,7 +36,7 @@ {% ifmemberof issueexperts analysts issueeditors admin %} - by {{visit.canvasser_id_expanded}} at {{visit.date}} + by {{visit.canvasser_id_expanded}} on {{visit.date}} {% else %} @@ -46,8 +46,17 @@

+ {% ifmemberof issueexperts analysts issueeditors admin %} + + {{issue.id}} + + {% else %} + + You are not permitted to view visit of followuprequests + + {% endifmemberof %} {% ifmemberof issueexperts admin %}

{{issue.brief|safe}} diff --git a/src/cljs/youyesyet/canvasser_app/core.cljs b/src/cljs/youyesyet/canvasser_app/core.cljs index 2dbbe2e..f6daa12 100644 --- a/src/cljs/youyesyet/canvasser_app/core.cljs +++ b/src/cljs/youyesyet/canvasser_app/core.cljs @@ -193,6 +193,7 @@ (rf/dispatch [:fetch-locality]) (rf/dispatch [:fetch-options]) (rf/dispatch [:fetch-issues]) + (rf/dispatch [:fetch-followupmethods]) (rf/dispatch [:dispatch-later [{:ms 60000 :dispatch [:process-queue]}]]) (load-interceptors!) (hook-browser-navigation!) diff --git a/src/cljs/youyesyet/canvasser_app/handlers.cljs b/src/cljs/youyesyet/canvasser_app/handlers.cljs index 8c853d5..18c0662 100644 --- a/src/cljs/youyesyet/canvasser_app/handlers.cljs +++ b/src/cljs/youyesyet/canvasser_app/handlers.cljs @@ -236,6 +236,41 @@ :error (:response response)))) +(reg-event-fx + :fetch-followupmethods + (fn [{db :db} _] + (js/console.log "Fetching options") + ;; we return a map of (side) effects + {:http-xhrio {:method :get + :uri (str source-host "json/auto/list-followupmethods") + :format (json-request-format) + :response-format (json-response-format {:keywords? true}) + :on-success [:process-followupmethods] + :on-failure [:bad-followupmethods]} + :db (add-to-feedback db :fetch-followupmethods)})) + + +(reg-event-db + :process-followupmethods + (fn + [db [_ response]] + (let [followupmethods (js->clj response)] + (js/console.log (str "Updating followupmethods: " followupmethods)) + (assoc + (remove-from-feedback db :fetch-followupmethods) + :followupmethods followupmethods)))) + + +(reg-event-db + :bad-followupmethods + (fn [db [_ response]] + (js/console.log "Failed to fetch followupmethods") + (dispatch [:dispatch-later [{:ms 60000 :dispatch [:fetch-followupmethods]}]]) + (assoc + db + :error (:response response)))) + + (reg-event-fx :fetch-issues (fn [{db :db} _] @@ -419,6 +454,13 @@ (assoc (clear-messages db) :elector elector)))) +(reg-event-db + :set-followupmethod + (fn [db [_ method-id]] + (js/console.log (str "Setting followupmethod to " method-id)) + (assoc db :followupmethod method-id))) + + (reg-event-db :set-issue (fn [db [_ issue]] diff --git a/src/cljs/youyesyet/canvasser_app/subscriptions.cljs b/src/cljs/youyesyet/canvasser_app/subscriptions.cljs index 8fd4218..64a0cb1 100644 --- a/src/cljs/youyesyet/canvasser_app/subscriptions.cljs +++ b/src/cljs/youyesyet/canvasser_app/subscriptions.cljs @@ -66,6 +66,16 @@ (fn [db _] (:feedback db))) +(reg-sub + :followupmethod + (fn [db _] + (:followupmethod db))) + +(reg-sub + :followupmethods + (fn [db _] + (:followupmethods db))) + (reg-sub :issue (fn [db _] diff --git a/src/cljs/youyesyet/canvasser_app/views/followup.cljs b/src/cljs/youyesyet/canvasser_app/views/followup.cljs index 115fd15..2013901 100644 --- a/src/cljs/youyesyet/canvasser_app/views/followup.cljs +++ b/src/cljs/youyesyet/canvasser_app/views/followup.cljs @@ -41,8 +41,9 @@ (let [issue @(subscribe [:issue]) issues @(subscribe [:issues]) elector @(subscribe [:elector]) - dwelling @(subscribe [:dwelling])] - (js/console.log (str "Issue is " issue "; elector is " elector)) + dwelling @(subscribe [:dwelling]) + method @(subscribe [:followupmethod])] + (js/console.log (str "followup/panel; Issue is " issue "; elector is " elector "; method is " method)) (cond (nil? dwelling) (ui/error-panel "No dwelling selected") @@ -68,8 +69,19 @@ (map #(let [] [:option {:key % :value %} %]) (keys issues))]] + (if (= issue :Other) + [:p.widget + [:label {:for "issue_detail"} "Issue detail"] + [:input {:type "text" :id "issue_detail" :name "issue_detail"}]]) [:p.widget - [:label {:for "method_detail"} "Telephone number"] + [:label {:for "method"} "Method"] + [:select {:id "method" :name "method" :defaultValue "Phone" + :on-change #(dispatch [:set-followupmethod (.-value (.-target %))])} + (map + #(let [] + [:option {:value (:id %) :key (:id %)} (:id %)]) @(subscribe [:followupmethods]))]] + [:p.widget + [:label {:for "method_detail"} (if (= @(subscribe [:followupmethod]) "Phone") "Telephone number" "EMail Address")] [:input {:type "text" :id "method_detail" :name "method_detail" :on-change #(dispatch [:set-method-detail (.-value (.-target %))])}]] [:p.widget diff --git a/youyesyet.adl.xml b/youyesyet.adl.xml index 1ac1fe3..60a5adb 100644 --- a/youyesyet.adl.xml +++ b/youyesyet.adl.xml @@ -44,7 +44,7 @@ version="0.1.1"> People expert on particular issues. Able to read followup requests, and the electors to which they relate; able - to access (read/write) the issues wiki; able to write followuop + to access (read/write) the issues wiki; able to write followup action records. @@ -694,6 +694,9 @@ version="0.1.1"> column="issue_id" entity="issues" farkey="id" distinct="user"> + + +