Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Simon Brooke 2018-09-14 21:22:10 +01:00
commit 046aa2660f
7 changed files with 103 additions and 6 deletions

View file

@ -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;

View file

@ -36,7 +36,7 @@
</label>
{% ifmemberof issueexperts analysts issueeditors admin %}
<span id='visit' name='visit' class='pseudo-widget disabled'>
by {{visit.canvasser_id_expanded}} at {{visit.date}}
by {{visit.canvasser_id_expanded}} on {{visit.date}}
</span>
{% else %}
<span id='visit_id' name='visit_id' class='pseudo-widget not-authorised'>
@ -46,8 +46,17 @@
</p>
<p class='widget'>
<label for='issue_id'>
{{issue.id}}
Issue
</label>
{% ifmemberof issueexperts analysts issueeditors admin %}
<span id='visit' name='visit' class='pseudo-widget disabled'>
{{issue.id}}
</span>
{% else %}
<span id='visit_id' name='visit_id' class='pseudo-widget not-authorised'>
You are not permitted to view visit of followuprequests
</span>
{% endifmemberof %}
{% ifmemberof issueexperts admin %}
<div id="issue-brief">
{{issue.brief|safe}}

View file

@ -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!)

View file

@ -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]]

View file

@ -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 _]

View file

@ -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

View file

@ -44,7 +44,7 @@ version="0.1.1">
<group name="issueexperts" parent="public">
<documentation>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.</documentation>
</group>
<group name="analysts" parent="public">
@ -694,6 +694,9 @@ version="0.1.1">
column="issue_id" entity="issues" farkey="id" distinct="user">
<prompt prompt="issue_id" locale="en_GB.UTF-8"/>
</property>
<property type="string" name="issue_detail">
<prompt prompt="Issue detail" locale="en_GB.UTF-8"/>
</property>
<property required="true" type="entity" name="method_id"
column="method_id" entity="followupmethods" farkey="id">
<prompt prompt="method_id" locale="en_GB.UTF-8"/>