diff --git a/project.clj b/project.clj
index 8f52343..7ffe7db 100644
--- a/project.clj
+++ b/project.clj
@@ -8,10 +8,12 @@
[ch.qos.logback/logback-classic "1.2.2"]
[clj-oauth "1.5.5"]
[cljsjs/react-leaflet "0.12.3-4"]
- [cljs-ajax "0.5.8"]
+ [cljs-ajax "0.7.3"]
+ [com.cemerick/url "0.1.1"]
[compojure "1.5.2"]
[conman "0.6.3"]
[cprop "0.1.10"]
+ [day8.re-frame/http-fx "0.1.6"]
[korma "0.4.3"]
[lib-noir "0.9.9" :exclusions [org.clojure/tools.reader]]
[luminus/ring-ttl-session "0.3.1"]
diff --git a/resources/public/img/gender/female.png b/resources/public/img/gender/Female.png
similarity index 100%
rename from resources/public/img/gender/female.png
rename to resources/public/img/gender/Female.png
diff --git a/resources/public/img/gender/male.png b/resources/public/img/gender/Male.png
similarity index 100%
rename from resources/public/img/gender/male.png
rename to resources/public/img/gender/Male.png
diff --git a/resources/public/img/gender/fluid.png b/resources/public/img/gender/Non-binary.png
similarity index 100%
rename from resources/public/img/gender/fluid.png
rename to resources/public/img/gender/Non-binary.png
diff --git a/resources/public/img/gender/unknown.png b/resources/public/img/gender/Unknown.png
similarity index 100%
rename from resources/public/img/gender/unknown.png
rename to resources/public/img/gender/Unknown.png
diff --git a/resources/public/img/option/no-selected.png b/resources/public/img/option/No-selected.png
similarity index 100%
rename from resources/public/img/option/no-selected.png
rename to resources/public/img/option/No-selected.png
diff --git a/resources/public/img/option/no-unselected.png b/resources/public/img/option/No-unselected.png
similarity index 100%
rename from resources/public/img/option/no-unselected.png
rename to resources/public/img/option/No-unselected.png
diff --git a/resources/public/img/option/yes-selected.png b/resources/public/img/option/Yes-selected.png
similarity index 100%
rename from resources/public/img/option/yes-selected.png
rename to resources/public/img/option/Yes-selected.png
diff --git a/resources/public/img/option/yes-unselected.png b/resources/public/img/option/Yes-unselected.png
similarity index 100%
rename from resources/public/img/option/yes-unselected.png
rename to resources/public/img/option/Yes-unselected.png
diff --git a/resources/sql/queries.auto.sql b/resources/sql/queries.auto.sql
index 5d024dc..dab35b5 100644
--- a/resources/sql/queries.auto.sql
+++ b/resources/sql/queries.auto.sql
@@ -1,10 +1,10 @@
------------------------------------------------------------------------
--- File queries.sql
---
--- autogenerated by adl.to-hugsql-queries at 2018-07-01T22:15:28.111Z
---
--- See [Application Description
--- Language](https://github.com/simon-brooke/adl).
+-- File queries.sql
+--
+-- autogenerated by adl.to-hugsql-queries at 2018-07-03T12:23:50.486Z
+--
+-- See [Application Description
+-- Language](https://github.com/simon-brooke/adl).
------------------------------------------------------------------------
-- :name create-address! :! :n
@@ -143,9 +143,11 @@ returning Id
-- :doc creates a new issue record
INSERT INTO issues (url,
current,
+ brief,
id)
VALUES (:url,
:current,
+ :brief,
:id)
returning id
@@ -405,7 +407,7 @@ ORDER BY lv_addresses.address,
-- :name list-addresses-by-district :? :*
-- :doc lists all existing address records related to a given district
-SELECT *
+SELECT *
FROM lv_addresses, addresses
WHERE lv_addresses.id = addresses.id
AND addresses.district_id = :id
@@ -433,7 +435,7 @@ ORDER BY lv_canvassers.username,
-- :name list-canvassers-by-address :? :*
-- :doc lists all existing canvasser records related to a given address
-SELECT *
+SELECT *
FROM lv_canvassers, canvassers
WHERE lv_canvassers.id = canvassers.id
AND canvassers.address_id = :id
@@ -446,7 +448,7 @@ ORDER BY lv_canvassers.username,
-- :name list-canvassers-by-authority :? :*
-- :doc lists all existing canvasser records related to a given authority
-SELECT *
+SELECT *
FROM lv_canvassers, canvassers
WHERE lv_canvassers.id = canvassers.id
AND canvassers.authority_id = :id
@@ -459,7 +461,7 @@ ORDER BY lv_canvassers.username,
-- :name list-canvassers-by-elector :? :*
-- :doc lists all existing canvasser records related to a given elector
-SELECT *
+SELECT *
FROM lv_canvassers, canvassers
WHERE lv_canvassers.id = canvassers.id
AND canvassers.elector_id = :id
@@ -472,7 +474,7 @@ ORDER BY lv_canvassers.username,
-- :name list-canvassers-by-role :? :*
-- :doc links all existing canvasser records related to a given role
-SELECT *
+SELECT *
FROM canvassers, ln_canvassers_roles
WHERE canvassers.id = ln_canvassers_roles.canvasser_id
AND ln_canvassers_roles.role_id = :id
@@ -502,7 +504,7 @@ ORDER BY lv_dwellings.address_id,
-- :name list-dwellings-by-address :? :*
-- :doc lists all existing dwelling records related to a given address
-SELECT *
+SELECT *
FROM lv_dwellings, dwellings
WHERE lv_dwellings.id = dwellings.id
AND dwellings.address_id = :id
@@ -523,7 +525,7 @@ ORDER BY lv_electors.name,
-- :name list-electors-by-dwelling :? :*
-- :doc lists all existing elector records related to a given dwelling
-SELECT *
+SELECT *
FROM lv_electors, electors
WHERE lv_electors.id = electors.id
AND electors.dwelling_id = :id
@@ -535,7 +537,7 @@ ORDER BY lv_electors.name,
-- :name list-electors-by-gender :? :*
-- :doc lists all existing elector records related to a given gender
-SELECT *
+SELECT *
FROM lv_electors, electors
WHERE lv_electors.id = electors.id
AND electors.gender = :id
@@ -556,7 +558,7 @@ ORDER BY lv_followupactions.date,
-- :name list-followupactions-by-canvasser :? :*
-- :doc lists all existing followupaction records related to a given canvasser
-SELECT *
+SELECT *
FROM lv_followupactions, followupactions
WHERE lv_followupactions.id = followupactions.id
AND followupactions.actor = :id
@@ -566,7 +568,7 @@ ORDER BY lv_followupactions.date,
-- :name list-followupactions-by-followuprequest :? :*
-- :doc lists all existing followupaction records related to a given followuprequest
-SELECT *
+SELECT *
FROM lv_followupactions, followupactions
WHERE lv_followupactions.id = followupactions.id
AND followupactions.request_id = :id
@@ -592,7 +594,7 @@ ORDER BY lv_followuprequests.elector_id,
-- :name list-followuprequests-by-elector :? :*
-- :doc lists all existing followuprequest records related to a given elector
-SELECT *
+SELECT *
FROM lv_followuprequests, followuprequests
WHERE lv_followuprequests.id = followuprequests.id
AND followuprequests.elector_id = :id
@@ -603,7 +605,7 @@ ORDER BY lv_followuprequests.elector_id,
-- :name list-followuprequests-by-followupmethod :? :*
-- :doc lists all existing followuprequest records related to a given followupmethod
-SELECT *
+SELECT *
FROM lv_followuprequests, followuprequests
WHERE lv_followuprequests.id = followuprequests.id
AND followuprequests.method_id = :id
@@ -614,7 +616,7 @@ ORDER BY lv_followuprequests.elector_id,
-- :name list-followuprequests-by-issue :? :*
-- :doc lists all existing followuprequest records related to a given issue
-SELECT *
+SELECT *
FROM lv_followuprequests, followuprequests
WHERE lv_followuprequests.id = followuprequests.id
AND followuprequests.issue_id = :id
@@ -625,7 +627,7 @@ ORDER BY lv_followuprequests.elector_id,
-- :name list-followuprequests-by-visit :? :*
-- :doc lists all existing followuprequest records related to a given visit
-SELECT *
+SELECT *
FROM lv_followuprequests, followuprequests
WHERE lv_followuprequests.id = followuprequests.id
AND followuprequests.visit_id = :id
@@ -648,21 +650,21 @@ SELECT DISTINCT * FROM lv_intentions
-- :name list-intentions-by-elector :? :*
-- :doc lists all existing intention records related to a given elector
-SELECT *
+SELECT *
FROM lv_intentions, intentions
WHERE lv_intentions.Id = intentions.Id
AND intentions.elector_id = :id
-- :name list-intentions-by-option :? :*
-- :doc lists all existing intention records related to a given option
-SELECT *
+SELECT *
FROM lv_intentions, intentions
WHERE lv_intentions.Id = intentions.Id
AND intentions.option_id = :id
-- :name list-intentions-by-visit :? :*
-- :doc lists all existing intention records related to a given visit
-SELECT *
+SELECT *
FROM lv_intentions, intentions
WHERE lv_intentions.Id = intentions.Id
AND intentions.visit_id = :id
@@ -689,7 +691,7 @@ ORDER BY lv_roles.name,
-- :name list-roles-by-canvasser :? :*
-- :doc links all existing role records related to a given canvasser
-SELECT *
+SELECT *
FROM roles, ln_canvassers_roles
WHERE roles.id = ln_canvassers_roles.role_id
AND ln_canvassers_roles.canvasser_id = :id
@@ -706,7 +708,7 @@ ORDER BY lv_teams.name,
-- :name list-teams-by-canvasser :? :*
-- :doc links all existing team records related to a given canvasser
-SELECT *
+SELECT *
FROM teams, ln_canvassers_teams
WHERE teams.id = ln_canvassers_teams.team_id
AND ln_canvassers_teams.canvasser_id = :id
@@ -715,7 +717,7 @@ ORDER BY teams.name,
-- :name list-teams-by-district :? :*
-- :doc lists all existing team records related to a given district
-SELECT *
+SELECT *
FROM lv_teams, teams
WHERE lv_teams.id = teams.id
AND teams.district_id = :id
@@ -733,7 +735,7 @@ ORDER BY lv_visits.address_id,
-- :name list-visits-by-address :? :*
-- :doc lists all existing visit records related to a given address
-SELECT *
+SELECT *
FROM lv_visits, visits
WHERE lv_visits.id = visits.id
AND visits.address_id = :id
@@ -743,7 +745,7 @@ ORDER BY lv_visits.address_id,
-- :name list-visits-by-canvasser :? :*
-- :doc lists all existing visit records related to a given canvasser
-SELECT *
+SELECT *
FROM lv_visits, visits
WHERE lv_visits.id = visits.id
AND visits.canvasser_id = :id
@@ -912,6 +914,7 @@ SELECT DISTINCT * FROM lv_issues
WHERE false
--~ (if (:url params) "OR url LIKE '%:url%'")
--~ (if (:current params) "OR current = :current")
+ --~ (if (:brief params) "OR brief LIKE '%:brief%'")
--~ (if (:id params) "OR id LIKE '%:id%'")
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@@ -1055,6 +1058,7 @@ WHERE intentions.Id = :Id
UPDATE issues
SET url = :url,
current = :current,
+ brief = :brief,
id = :id
WHERE issues.id = :id
@@ -1079,4 +1083,4 @@ UPDATE visits
SET address_id = :address_id,
canvasser_id = :canvasser_id,
date = :date
-WHERE visits.id = :id
+WHERE visits.id = :id
\ No newline at end of file
diff --git a/resources/sql/youyesyet.postgres.sql b/resources/sql/youyesyet.postgres.sql
index a8aab30..1375265 100644
--- a/resources/sql/youyesyet.postgres.sql
+++ b/resources/sql/youyesyet.postgres.sql
@@ -5,7 +5,7 @@
--
-- auto-generated by [Application Description Language framework]
--
--- (https://github.com/simon-brooke/adl) at 20180701T221532.672Z
+-- (https://github.com/simon-brooke/adl) at 20180703T122351.367Z
--
--
-- A web-app intended to be used by canvassers campaigning for a
@@ -338,7 +338,8 @@ CREATE TABLE issues
(
id VARCHAR(32) NOT NULL PRIMARY KEY,
url VARCHAR(256),
- current BOOLEAN DEFAULT true
+ current BOOLEAN DEFAULT true,
+ brief TEXT
);
GRANT SELECT ON issues TO admin,
analysts,
@@ -676,6 +677,7 @@ GRANT SELECT ON lv_intentions TO admin,
CREATE VIEW lv_issues AS
SELECT issues.url,
issues.current,
+ issues.brief,
issues.id
FROM issues
;
diff --git a/resources/templates/auto/application-index.html b/resources/templates/auto/application-index.html
index 27f6615..d20b64c 100644
--- a/resources/templates/auto/application-index.html
+++ b/resources/templates/auto/application-index.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-addresses-Address.html b/resources/templates/auto/form-addresses-Address.html
index 6fbbbc4..9ca72aa 100644
--- a/resources/templates/auto/form-addresses-Address.html
+++ b/resources/templates/auto/form-addresses-Address.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-authorities-Authority.html b/resources/templates/auto/form-authorities-Authority.html
index 02749f0..329e3a7 100644
--- a/resources/templates/auto/form-authorities-Authority.html
+++ b/resources/templates/auto/form-authorities-Authority.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-canvassers-Canvasser.html b/resources/templates/auto/form-canvassers-Canvasser.html
index 7e94c21..320c80b 100644
--- a/resources/templates/auto/form-canvassers-Canvasser.html
+++ b/resources/templates/auto/form-canvassers-Canvasser.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-districts-District.html b/resources/templates/auto/form-districts-District.html
index 733f6f2..41fa5f2 100644
--- a/resources/templates/auto/form-districts-District.html
+++ b/resources/templates/auto/form-districts-District.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-dwellings-Dwelling.html b/resources/templates/auto/form-dwellings-Dwelling.html
index 692539f..2b562c7 100644
--- a/resources/templates/auto/form-dwellings-Dwelling.html
+++ b/resources/templates/auto/form-dwellings-Dwelling.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-electors-Elector.html b/resources/templates/auto/form-electors-Elector.html
index 6ad712a..9ea1a40 100644
--- a/resources/templates/auto/form-electors-Elector.html
+++ b/resources/templates/auto/form-electors-Elector.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-followupactions-Followupaction.html b/resources/templates/auto/form-followupactions-Followupaction.html
index ac42a80..eea3de0 100644
--- a/resources/templates/auto/form-followupactions-Followupaction.html
+++ b/resources/templates/auto/form-followupactions-Followupaction.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-followupmethods-Followupmethod.html b/resources/templates/auto/form-followupmethods-Followupmethod.html
index b1810ab..f22b050 100644
--- a/resources/templates/auto/form-followupmethods-Followupmethod.html
+++ b/resources/templates/auto/form-followupmethods-Followupmethod.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-followuprequests-Followuprequest.html b/resources/templates/auto/form-followuprequests-Followuprequest.html
index fc30435..7632816 100644
--- a/resources/templates/auto/form-followuprequests-Followuprequest.html
+++ b/resources/templates/auto/form-followuprequests-Followuprequest.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-genders-Gender.html b/resources/templates/auto/form-genders-Gender.html
index 9beaae3..a62df40 100644
--- a/resources/templates/auto/form-genders-Gender.html
+++ b/resources/templates/auto/form-genders-Gender.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-intentions-Intention.html b/resources/templates/auto/form-intentions-Intention.html
index d04e85a..472abe6 100644
--- a/resources/templates/auto/form-intentions-Intention.html
+++ b/resources/templates/auto/form-intentions-Intention.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-issues-Issue.html b/resources/templates/auto/form-issues-Issue.html
index e2e6ebc..3fde700 100644
--- a/resources/templates/auto/form-issues-Issue.html
+++ b/resources/templates/auto/form-issues-Issue.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
@@ -61,6 +61,24 @@ You are not permitted to view current of issues
{% endifmemberof %}
{% endifmemberof %}
+
+
+brief
+
+{% ifmemberof issueeditors admin %}
+
+{% else %}
+{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
+
+{{record.brief}}
+
+{% else %}
+
+You are not permitted to view brief of issues
+
+{% endifmemberof %}
+{% endifmemberof %}
+
To save this issues record
diff --git a/resources/templates/auto/form-options-Option.html b/resources/templates/auto/form-options-Option.html
index 01647cf..37638d9 100644
--- a/resources/templates/auto/form-options-Option.html
+++ b/resources/templates/auto/form-options-Option.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-roles-Role.html b/resources/templates/auto/form-roles-Role.html
index 6a6986a..9f9a326 100644
--- a/resources/templates/auto/form-roles-Role.html
+++ b/resources/templates/auto/form-roles-Role.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-teams-Team.html b/resources/templates/auto/form-teams-Team.html
index da15535..c3aaa38 100644
--- a/resources/templates/auto/form-teams-Team.html
+++ b/resources/templates/auto/form-teams-Team.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/form-visits-Visit.html b/resources/templates/auto/form-visits-Visit.html
index 0607158..57bb2e2 100644
--- a/resources/templates/auto/form-visits-Visit.html
+++ b/resources/templates/auto/form-visits-Visit.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-
diff --git a/resources/templates/auto/list-addresses-Addresses.html b/resources/templates/auto/list-addresses-Addresses.html
index 532526f..2850e38 100644
--- a/resources/templates/auto/list-addresses-Addresses.html
+++ b/resources/templates/auto/list-addresses-Addresses.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-addresses-Addresses');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset \"0\" %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-authorities-Authorities.html b/resources/templates/auto/list-authorities-Authorities.html
index 6692a65..c546208 100644
--- a/resources/templates/auto/list-authorities-Authorities.html
+++ b/resources/templates/auto/list-authorities-Authorities.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-authorities-Authorities');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-canvassers-Canvassers.html b/resources/templates/auto/list-canvassers-Canvassers.html
index b1a546f..4d27495 100644
--- a/resources/templates/auto/list-canvassers-Canvassers.html
+++ b/resources/templates/auto/list-canvassers-Canvassers.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-canvassers-Canvassers');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-districts-Districts.html b/resources/templates/auto/list-districts-Districts.html
index 75c7410..f686b74 100644
--- a/resources/templates/auto/list-districts-Districts.html
+++ b/resources/templates/auto/list-districts-Districts.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-districts-Districts');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-dwellings-Dwellings.html b/resources/templates/auto/list-dwellings-Dwellings.html
index e71d566..c4044c4 100644
--- a/resources/templates/auto/list-dwellings-Dwellings.html
+++ b/resources/templates/auto/list-dwellings-Dwellings.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-dwellings-Dwellings');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-electors-Electors.html b/resources/templates/auto/list-electors-Electors.html
index 7250f3c..23ec004 100644
--- a/resources/templates/auto/list-electors-Electors.html
+++ b/resources/templates/auto/list-electors-Electors.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-electors-Electors');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-followupactions-Followupactions.html b/resources/templates/auto/list-followupactions-Followupactions.html
index 43967c2..c74d8fc 100644
--- a/resources/templates/auto/list-followupactions-Followupactions.html
+++ b/resources/templates/auto/list-followupactions-Followupactions.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-followupactions-Followupactions');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-followupmethods-Followupmethods.html b/resources/templates/auto/list-followupmethods-Followupmethods.html
index 7a2f684..8ee0a32 100644
--- a/resources/templates/auto/list-followupmethods-Followupmethods.html
+++ b/resources/templates/auto/list-followupmethods-Followupmethods.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-followupmethods-Followupmethods');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-followuprequests-Followuprequests.html b/resources/templates/auto/list-followuprequests-Followuprequests.html
index 20146d0..5f19ae0 100644
--- a/resources/templates/auto/list-followuprequests-Followuprequests.html
+++ b/resources/templates/auto/list-followuprequests-Followuprequests.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-followuprequests-Followuprequests');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-genders-Genders.html b/resources/templates/auto/list-genders-Genders.html
index cd81ff6..07646a6 100644
--- a/resources/templates/auto/list-genders-Genders.html
+++ b/resources/templates/auto/list-genders-Genders.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-genders-Genders');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-intentions-Intentions.html b/resources/templates/auto/list-intentions-Intentions.html
index 5d2e535..6b95886 100644
--- a/resources/templates/auto/list-intentions-Intentions.html
+++ b/resources/templates/auto/list-intentions-Intentions.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-intentions-Intentions');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-issues-Issues.html b/resources/templates/auto/list-issues-Issues.html
index 1cbe0bb..fab0ec7 100644
--- a/resources/templates/auto/list-issues-Issues.html
+++ b/resources/templates/auto/list-issues-Issues.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-issues-Issues');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-options-Options.html b/resources/templates/auto/list-options-Options.html
index 65821ec..b60e786 100644
--- a/resources/templates/auto/list-options-Options.html
+++ b/resources/templates/auto/list-options-Options.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-options-Options');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-roles-Roles.html b/resources/templates/auto/list-roles-Roles.html
index 276d38a..f7aed11 100644
--- a/resources/templates/auto/list-roles-Roles.html
+++ b/resources/templates/auto/list-roles-Roles.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-roles-Roles');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-teams-Teams.html b/resources/templates/auto/list-teams-Teams.html
index a353d40..99630d3 100644
--- a/resources/templates/auto/list-teams-Teams.html
+++ b/resources/templates/auto/list-teams-Teams.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-teams-Teams');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/resources/templates/auto/list-visits-Visits.html b/resources/templates/auto/list-visits-Visits.html
index 70a4964..9a75523 100644
--- a/resources/templates/auto/list-visits-Visits.html
+++ b/resources/templates/auto/list-visits-Visits.html
@@ -1,44 +1,15 @@
{% extends "base.html" %}
-
-{% block back-links %}
-
-
-{% ifunequal params.offset "0" %}
-
-Previous
-
-{% else %}
-
-Back
-
-{% endifunequal %}
-
-
-
-{% endblock %}
-{% block big-links %}
-
-
-{% endblock %}
-{% block content %}
-
{% endblock %}
-{% block extra-script %}
-
- var form = document.getElementById('list-visits-Visits');
- var ow = document.getElementById('offset');
- var lw = document.getElementById('limit');
- form.addEventListener('submit', function() {
- ow.value='0';
- });
-
- {% ifunequal offset 0 %}
- document.getElementById('prev-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)-parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
- {% endifunequal %}
-
- document.getElementById('next-selector').addEventListener('click', function () {
- ow.value=(parseInt(ow.value)+parseInt(lw.value));
- console.log('Updated offset to ' + ow.value);
- form.submit();
- });
-{% endblock %}
diff --git a/src/clj/youyesyet/handler.clj b/src/clj/youyesyet/handler.clj
index 6027a28..a56c2d1 100644
--- a/src/clj/youyesyet/handler.clj
+++ b/src/clj/youyesyet/handler.clj
@@ -72,6 +72,8 @@
(-> #'auto-selmer-routes
(wrap-routes middleware/wrap-csrf)
(wrap-routes middleware/wrap-formats))
+ (-> #'auto-rest-routes
+ (wrap-routes middleware/wrap-formats))
(-> #'rest-routes
(wrap-routes middleware/wrap-formats))
'oauth-routes
diff --git a/src/clj/youyesyet/routes/auto.clj b/src/clj/youyesyet/routes/auto.clj
index 63860d0..975d909 100644
--- a/src/clj/youyesyet/routes/auto.clj
+++ b/src/clj/youyesyet/routes/auto.clj
@@ -1,11 +1,9 @@
(ns
youyesyet.routes.auto
- "User interface routes for Youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180701T221533.599Z"
+ "User interface routes for Youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180703T122351.613Z"
(:require
[adl-support.core :as support]
[clojure.java.io :as io]
- [clojure.set :refer [subset?]]
- [clojure.tools.logging :as log]
[compojure.core :refer [defroutes GET POST]]
[hugsql.core :as hugsql]
[noir.response :as nresponse]
@@ -27,1023 +25,523 @@
list-addresses-Addresses
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"district_id" "postcode" "longitude" "id" "latitude" "address"
- "locality" "phone"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-address db/*db* p)
- :message
- "Error while searching address records"
- :error-return
- {:warnings ["Error while searching address records"]})
- (support/do-or-log-error
- (db/list-addresses db/*db* {})
- :message
- "Error while fetching address records"
- :error-return
- {:warnings ["Error while fetching address records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-addresses-Addresses.html")
- (:session 'r)
- (merge {:title "Addresses", :params p} c))))
+ (:session r)
+ {:title "Addresses",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-address db/*db* p)
+ (db/list-addresses db/*db* {}))})))
(defn
form-addresses-Address
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-address db/*db* p))
- :message
- "Error while fetching address record"
- :error-return
- {:warnings ["Error while fetching address record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :districts
- (support/do-or-log-error
- (db/list-districts db/*db*)
- :message
- "Error while fetching district record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-addresses-Address.html")
- (:session 'r)
- (merge {:title "Address", :params p} c))))
+ (:session r)
+ {:title "Address",
+ :params p,
+ :record
+ (if (empty? (remove nil? (vals p))) [] (db/get-address db/*db* p)),
+ :districts (db/list-districts db/*db*)})))
(defn
list-authorities-Authorities
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"authorize-uri" "request-token-uri" "access-token-uri"
- "consumer-key" "id" "consumer-secret"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-authority db/*db* p)
- :message
- "Error while searching authority records"
- :error-return
- {:warnings ["Error while searching authority records"]})
- (support/do-or-log-error
- (db/list-authorities db/*db* {})
- :message
- "Error while fetching authority records"
- :error-return
- {:warnings ["Error while fetching authority records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-authorities-Authorities.html")
- (:session 'r)
- (merge {:title "Authorities", :params p} c))))
+ (:session r)
+ {:title "Authorities",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-authority db/*db* p)
+ (db/list-authorities db/*db* {}))})))
(defn
form-authorities-Authority
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-authority db/*db* p))
- :message
- "Error while fetching authority record"
- :error-return
- {:warnings ["Error while fetching authority record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil)})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-authorities-Authority.html")
- (:session 'r)
- (merge {:title "Authority", :params p} c))))
+ (:session r)
+ {:title "Authority",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-authority db/*db* p))})))
(defn
list-canvassers-Canvassers
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"username" "address_id" "elector_id" "id" "email"
- "authority_id" "authorised" "phone" "fullname" "roles"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-canvasser db/*db* p)
- :message
- "Error while searching canvasser records"
- :error-return
- {:warnings ["Error while searching canvasser records"]})
- (support/do-or-log-error
- (db/list-canvassers db/*db* {})
- :message
- "Error while fetching canvasser records"
- :error-return
- {:warnings ["Error while fetching canvasser records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-canvassers-Canvassers.html")
- (:session 'r)
- (merge {:title "Canvassers", :params p} c))))
+ (:session r)
+ {:title "Canvassers",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-canvasser db/*db* p)
+ (db/list-canvassers db/*db* {}))})))
(defn
form-canvassers-Canvasser
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-canvasser db/*db* p))
- :message
- "Error while fetching canvasser record"
- :error-return
- {:warnings ["Error while fetching canvasser record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :electors
- (support/do-or-log-error
- (db/list-electors db/*db*)
- :message
- "Error while fetching elector record"),
- :addresses
- (support/do-or-log-error
- (db/list-addresses db/*db*)
- :message
- "Error while fetching address record"),
- :authorities
- (support/do-or-log-error
- (db/list-authorities db/*db*)
- :message
- "Error while fetching authority record"),
- :roles
- (support/do-or-log-error
- (db/list-roles db/*db*)
- :message
- "Error while fetching role record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-canvassers-Canvasser.html")
- (:session 'r)
- (merge {:title "Canvasser", :params p} c))))
+ (:session r)
+ {:title "Canvasser",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-canvasser db/*db* p)),
+ :electors (db/list-electors db/*db*),
+ :addresses (db/list-addresses db/*db*),
+ :authorities (db/list-authorities db/*db*),
+ :roles (db/list-roles db/*db*)})))
(defn
list-districts-Districts
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"id" "name"} (keys p))
- (support/do-or-log-error
- (db/search-strings-district db/*db* p)
- :message
- "Error while searching district records"
- :error-return
- {:warnings ["Error while searching district records"]})
- (support/do-or-log-error
- (db/list-districts db/*db* {})
- :message
- "Error while fetching district records"
- :error-return
- {:warnings ["Error while fetching district records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-districts-Districts.html")
- (:session 'r)
- (merge {:title "Districts", :params p} c))))
+ (:session r)
+ {:title "Districts",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-district db/*db* p)
+ (db/list-districts db/*db* {}))})))
(defn
form-districts-District
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-district db/*db* p))
- :message
- "Error while fetching district record"
- :error-return
- {:warnings ["Error while fetching district record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil)})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-districts-District.html")
- (:session 'r)
- (merge {:title "District", :params p} c))))
+ (:session r)
+ {:title "District",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-district db/*db* p))})))
(defn
list-dwellings-Dwellings
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"sub-address" "address_id" "id"} (keys p))
- (support/do-or-log-error
- (db/search-strings-dwelling db/*db* p)
- :message
- "Error while searching dwelling records"
- :error-return
- {:warnings ["Error while searching dwelling records"]})
- (support/do-or-log-error
- (db/list-dwellings db/*db* {})
- :message
- "Error while fetching dwelling records"
- :error-return
- {:warnings ["Error while fetching dwelling records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-dwellings-Dwellings.html")
- (:session 'r)
- (merge {:title "Dwellings", :params p} c))))
+ (:session r)
+ {:title "Dwellings",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-dwelling db/*db* p)
+ (db/list-dwellings db/*db* {}))})))
(defn
form-dwellings-Dwelling
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-dwelling db/*db* p))
- :message
- "Error while fetching dwelling record"
- :error-return
- {:warnings ["Error while fetching dwelling record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :addresses
- (support/do-or-log-error
- (db/list-addresses db/*db*)
- :message
- "Error while fetching address record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-dwellings-Dwelling.html")
- (:session 'r)
- (merge {:title "Dwelling", :params p} c))))
+ (:session r)
+ {:title "Dwelling",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-dwelling db/*db* p)),
+ :addresses (db/list-addresses db/*db*)})))
(defn
list-electors-Electors
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"id" "gender" "email" "name" "dwelling_id" "phone"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-elector db/*db* p)
- :message
- "Error while searching elector records"
- :error-return
- {:warnings ["Error while searching elector records"]})
- (support/do-or-log-error
- (db/list-electors db/*db* {})
- :message
- "Error while fetching elector records"
- :error-return
- {:warnings ["Error while fetching elector records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-electors-Electors.html")
- (:session 'r)
- (merge {:title "Electors", :params p} c))))
+ (:session r)
+ {:title "Electors",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-elector db/*db* p)
+ (db/list-electors db/*db* {}))})))
(defn
form-electors-Elector
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-elector db/*db* p))
- :message
- "Error while fetching elector record"
- :error-return
- {:warnings ["Error while fetching elector record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :dwellings
- (support/do-or-log-error
- (db/list-dwellings db/*db*)
- :message
- "Error while fetching dwelling record"),
- :genders
- (support/do-or-log-error
- (db/list-genders db/*db*)
- :message
- "Error while fetching gender record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-electors-Elector.html")
- (:session 'r)
- (merge {:title "Elector", :params p} c))))
+ (:session r)
+ {:title "Elector",
+ :params p,
+ :record
+ (if (empty? (remove nil? (vals p))) [] (db/get-elector db/*db* p)),
+ :dwellings (db/list-dwellings db/*db*),
+ :genders (db/list-genders db/*db*)})))
(defn
list-followupactions-Followupactions
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"request_id" "id" "closed" "date" "notes" "actor"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-followupaction db/*db* p)
- :message
- "Error while searching followupaction records"
- :error-return
- {:warnings ["Error while searching followupaction records"]})
- (support/do-or-log-error
- (db/list-followupactions db/*db* {})
- :message
- "Error while fetching followupaction records"
- :error-return
- {:warnings ["Error while fetching followupaction records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template
"list-followupactions-Followupactions.html")
- (:session 'r)
- (merge {:title "Followupactions", :params p} c))))
+ (:session r)
+ {:title "Followupactions",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-followupaction db/*db* p)
+ (db/list-followupactions db/*db* {}))})))
(defn
form-followupactions-Followupaction
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if
- (subset? #{"id"} #{p keys})
- (db/get-followupaction db/*db* p))
- :message
- "Error while fetching followupaction record"
- :error-return
- {:warnings ["Error while fetching followupaction record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :followuprequests
- (support/do-or-log-error
- (db/list-followuprequests db/*db*)
- :message
- "Error while fetching followuprequest record"),
- :canvassers
- (support/do-or-log-error
- (db/list-canvassers db/*db*)
- :message
- "Error while fetching canvasser record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template
"form-followupactions-Followupaction.html")
- (:session 'r)
- (merge {:title "Followupaction", :params p} c))))
+ (:session r)
+ {:title "Followupaction",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-followupaction db/*db* p)),
+ :followuprequests (db/list-followuprequests db/*db*),
+ :canvassers (db/list-canvassers db/*db*)})))
(defn
list-followupmethods-Followupmethods
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"id"} (keys p))
- (support/do-or-log-error
- (db/search-strings-followupmethod db/*db* p)
- :message
- "Error while searching followupmethod records"
- :error-return
- {:warnings ["Error while searching followupmethod records"]})
- (support/do-or-log-error
- (db/list-followupmethods db/*db* {})
- :message
- "Error while fetching followupmethod records"
- :error-return
- {:warnings ["Error while fetching followupmethod records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template
"list-followupmethods-Followupmethods.html")
- (:session 'r)
- (merge {:title "Followupmethods", :params p} c))))
+ (:session r)
+ {:title "Followupmethods",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-followupmethod db/*db* p)
+ (db/list-followupmethods db/*db* {}))})))
(defn
form-followupmethods-Followupmethod
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if
- (subset? #{"id"} #{p keys})
- (db/get-followupmethod db/*db* p))
- :message
- "Error while fetching followupmethod record"
- :error-return
- {:warnings ["Error while fetching followupmethod record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil)})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template
"form-followupmethods-Followupmethod.html")
- (:session 'r)
- (merge {:title "Followupmethod", :params p} c))))
+ (:session r)
+ {:title "Followupmethod",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-followupmethod db/*db* p))})))
(defn
list-followuprequests-Followuprequests
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"elector_id" "id" "issue_id" "visit_id" "method_id"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-followuprequest db/*db* p)
- :message
- "Error while searching followuprequest records"
- :error-return
- {:warnings ["Error while searching followuprequest records"]})
- (support/do-or-log-error
- (db/list-followuprequests db/*db* {})
- :message
- "Error while fetching followuprequest records"
- :error-return
- {:warnings ["Error while fetching followuprequest records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template
"list-followuprequests-Followuprequests.html")
- (:session 'r)
- (merge {:title "Followuprequests", :params p} c))))
+ (:session r)
+ {:title "Followuprequests",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-followuprequest db/*db* p)
+ (db/list-followuprequests db/*db* {}))})))
(defn
form-followuprequests-Followuprequest
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if
- (subset? #{"id"} #{p keys})
- (db/get-followuprequest db/*db* p))
- :message
- "Error while fetching followuprequest record"
- :error-return
- {:warnings ["Error while fetching followuprequest record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :electors
- (support/do-or-log-error
- (db/list-electors db/*db*)
- :message
- "Error while fetching elector record"),
- :visits
- (support/do-or-log-error
- (db/list-visits db/*db*)
- :message
- "Error while fetching visit record"),
- :issues
- (support/do-or-log-error
- (db/list-issues db/*db*)
- :message
- "Error while fetching issue record"),
- :followupmethods
- (support/do-or-log-error
- (db/list-followupmethods db/*db*)
- :message
- "Error while fetching followupmethod record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template
"form-followuprequests-Followuprequest.html")
- (:session 'r)
- (merge {:title "Followuprequest", :params p} c))))
+ (:session r)
+ {:title "Followuprequest",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-followuprequest db/*db* p)),
+ :electors (db/list-electors db/*db*),
+ :visits (db/list-visits db/*db*),
+ :issues (db/list-issues db/*db*),
+ :followupmethods (db/list-followupmethods db/*db*)})))
(defn
list-genders-Genders
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"id"} (keys p))
- (support/do-or-log-error
- (db/search-strings-gender db/*db* p)
- :message
- "Error while searching gender records"
- :error-return
- {:warnings ["Error while searching gender records"]})
- (support/do-or-log-error
- (db/list-genders db/*db* {})
- :message
- "Error while fetching gender records"
- :error-return
- {:warnings ["Error while fetching gender records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-genders-Genders.html")
- (:session 'r)
- (merge {:title "Genders", :params p} c))))
+ (:session r)
+ {:title "Genders",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-gender db/*db* p)
+ (db/list-genders db/*db* {}))})))
(defn
form-genders-Gender
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-gender db/*db* p))
- :message
- "Error while fetching gender record"
- :error-return
- {:warnings ["Error while fetching gender record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil)})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-genders-Gender.html")
- (:session 'r)
- (merge {:title "Gender", :params p} c))))
+ (:session r)
+ {:title "Gender",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-gender db/*db* p))})))
(defn
list-intentions-Intentions
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"Id"}))
- c
- (let
- [records
- (if
- (some
- #{"elector_id" "option_id" "locality" "visit_id" "Id"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-intention db/*db* p)
- :message
- "Error while searching intention records"
- :error-return
- {:warnings ["Error while searching intention records"]})
- (support/do-or-log-error
- (db/list-intentions db/*db* {})
- :message
- "Error while fetching intention records"
- :error-return
- {:warnings ["Error while fetching intention records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-intentions-Intentions.html")
- (:session 'r)
- (merge {:title "Intentions", :params p} c))))
+ (:session r)
+ {:title "Intentions",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-intention db/*db* p)
+ (db/list-intentions db/*db* {}))})))
(defn
form-intentions-Intention
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"Id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"Id"} #{p keys}) (db/get-intention db/*db* p))
- :message
- "Error while fetching intention record"
- :error-return
- {:warnings ["Error while fetching intention record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :visits
- (support/do-or-log-error
- (db/list-visits db/*db*)
- :message
- "Error while fetching visit record"),
- :electors
- (support/do-or-log-error
- (db/list-electors db/*db*)
- :message
- "Error while fetching elector record"),
- :options
- (support/do-or-log-error
- (db/list-options db/*db*)
- :message
- "Error while fetching option record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-intentions-Intention.html")
- (:session 'r)
- (merge {:title "Intention", :params p} c))))
+ (:session r)
+ {:title "Intention",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-intention db/*db* p)),
+ :visits (db/list-visits db/*db*),
+ :electors (db/list-electors db/*db*),
+ :options (db/list-options db/*db*)})))
(defn
list-issues-Issues
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"url" "id" "current"} (keys p))
- (support/do-or-log-error
- (db/search-strings-issue db/*db* p)
- :message
- "Error while searching issue records"
- :error-return
- {:warnings ["Error while searching issue records"]})
- (support/do-or-log-error
- (db/list-issues db/*db* {})
- :message
- "Error while fetching issue records"
- :error-return
- {:warnings ["Error while fetching issue records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-issues-Issues.html")
- (:session 'r)
- (merge {:title "Issues", :params p} c))))
+ (:session r)
+ {:title "Issues",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-issue db/*db* p)
+ (db/list-issues db/*db* {}))})))
(defn
form-issues-Issue
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-issue db/*db* p))
- :message
- "Error while fetching issue record"
- :error-return
- {:warnings ["Error while fetching issue record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil)})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-issues-Issue.html")
- (:session 'r)
- (merge {:title "Issue", :params p} c))))
+ (:session r)
+ {:title "Issue",
+ :params p,
+ :record
+ (if (empty? (remove nil? (vals p))) [] (db/get-issue db/*db* p))})))
(defn
list-options-Options
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"id"} (keys p))
- (support/do-or-log-error
- (db/search-strings-option db/*db* p)
- :message
- "Error while searching option records"
- :error-return
- {:warnings ["Error while searching option records"]})
- (support/do-or-log-error
- (db/list-options db/*db* {})
- :message
- "Error while fetching option records"
- :error-return
- {:warnings ["Error while fetching option records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-options-Options.html")
- (:session 'r)
- (merge {:title "Options", :params p} c))))
+ (:session r)
+ {:title "Options",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-option db/*db* p)
+ (db/list-options db/*db* {}))})))
(defn
form-options-Option
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-option db/*db* p))
- :message
- "Error while fetching option record"
- :error-return
- {:warnings ["Error while fetching option record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil)})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-options-Option.html")
- (:session 'r)
- (merge {:title "Option", :params p} c))))
+ (:session r)
+ {:title "Option",
+ :params p,
+ :record
+ (if
+ (empty? (remove nil? (vals p)))
+ []
+ (db/get-option db/*db* p))})))
(defn
list-roles-Roles
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"members" "id" "name"} (keys p))
- (support/do-or-log-error
- (db/search-strings-role db/*db* p)
- :message
- "Error while searching role records"
- :error-return
- {:warnings ["Error while searching role records"]})
- (support/do-or-log-error
- (db/list-roles db/*db* {})
- :message
- "Error while fetching role records"
- :error-return
- {:warnings ["Error while fetching role records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-roles-Roles.html")
- (:session 'r)
- (merge {:title "Roles", :params p} c))))
+ (:session r)
+ {:title "Roles",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-role db/*db* p)
+ (db/list-roles db/*db* {}))})))
(defn
form-roles-Role
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-role db/*db* p))
- :message
- "Error while fetching role record"
- :error-return
- {:warnings ["Error while fetching role record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :canvassers
- (support/do-or-log-error
- (db/list-canvassers db/*db*)
- :message
- "Error while fetching canvasser record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-roles-Role.html")
- (:session 'r)
- (merge {:title "Role", :params p} c))))
+ (:session r)
+ {:title "Role",
+ :params p,
+ :record
+ (if (empty? (remove nil? (vals p))) [] (db/get-role db/*db* p)),
+ :canvassers (db/list-canvassers db/*db*)})))
(defn
list-teams-Teams
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some
- #{"organisers" "district_id" "members" "longitude" "id"
- "latitude" "name"}
- (keys p))
- (support/do-or-log-error
- (db/search-strings-team db/*db* p)
- :message
- "Error while searching team records"
- :error-return
- {:warnings ["Error while searching team records"]})
- (support/do-or-log-error
- (db/list-teams db/*db* {})
- :message
- "Error while fetching team records"
- :error-return
- {:warnings ["Error while fetching team records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-teams-Teams.html")
- (:session 'r)
- (merge {:title "Teams", :params p} c))))
+ (:session r)
+ {:title "Teams",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-team db/*db* p)
+ (db/list-teams db/*db* {}))})))
(defn
form-teams-Team
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-team db/*db* p))
- :message
- "Error while fetching team record"
- :error-return
- {:warnings ["Error while fetching team record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :districts
- (support/do-or-log-error
- (db/list-districts db/*db*)
- :message
- "Error while fetching district record"),
- :canvassers
- (support/do-or-log-error
- (db/list-canvassers db/*db*)
- :message
- "Error while fetching canvasser record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-teams-Team.html")
- (:session 'r)
- (merge {:title "Team", :params p} c))))
+ (:session r)
+ {:title "Team",
+ :params p,
+ :record
+ (if (empty? (remove nil? (vals p))) [] (db/get-team db/*db* p)),
+ :districts (db/list-districts db/*db*),
+ :canvassers (db/list-canvassers db/*db*)})))
(defn
list-visits-Visits
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [records
- (if
- (some #{"address_id" "id" "canvasser_id" "date"} (keys p))
- (support/do-or-log-error
- (db/search-strings-visit db/*db* p)
- :message
- "Error while searching visit records"
- :error-return
- {:warnings ["Error while searching visit records"]})
- (support/do-or-log-error
- (db/list-visits db/*db* {})
- :message
- "Error while fetching visit records"
- :error-return
- {:warnings ["Error while fetching visit records"]}))]
- (if (:warnings records) records {:records records}))]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "list-visits-Visits.html")
- (:session 'r)
- (merge {:title "Visits", :params p} c))))
+ (:session r)
+ {:title "Visits",
+ :params p,
+ :records
+ (if
+ (not (empty? (remove nil? (vals p))))
+ (db/search-strings-visit db/*db* p)
+ (db/list-visits db/*db* {}))})))
(defn
form-visits-Visit
[r]
(let
- [p
- (merge
- {:offset 0, :limit 25}
- (support/massage-params (:params r) (:form-params r) #{"id"}))
- c
- (let
- [record
- (support/do-or-log-error
- (if (subset? #{"id"} #{p keys}) (db/get-visit db/*db* p))
- :message
- "Error while fetching visit record"
- :error-return
- {:warnings ["Error while fetching visit record"]})]
- {:warnings (:warnings record),
- :record (assoc record :warnings nil),
- :addresses
- (support/do-or-log-error
- (db/list-addresses db/*db*)
- :message
- "Error while fetching address record"),
- :canvassers
- (support/do-or-log-error
- (db/list-canvassers db/*db*)
- :message
- "Error while fetching canvasser record")})]
+ [p (support/massage-params (:params r))]
(l/render
(support/resolve-template "form-visits-Visit.html")
- (:session 'r)
- (merge {:title "Visit", :params p} c))))
+ (:session r)
+ {:title "Visit",
+ :params p,
+ :record
+ (if (empty? (remove nil? (vals p))) [] (db/get-visit db/*db* p)),
+ :addresses (db/list-addresses db/*db*),
+ :canvassers (db/list-canvassers db/*db*)})))
(defn
raw-resolve-handler
diff --git a/src/clj/youyesyet/routes/auto_json.clj b/src/clj/youyesyet/routes/auto_json.clj
index 9c7234b..c53888d 100644
--- a/src/clj/youyesyet/routes/auto_json.clj
+++ b/src/clj/youyesyet/routes/auto_json.clj
@@ -1,11 +1,10 @@
(ns
youyesyet.routes.auto-json
- "JSON routes for youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180701T221528.540Z"
+ "JSON routes for youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180703T122350.619Z"
(:require
[adl-support.core :as support]
- [clojure.core.memoize :as memo]
[clojure.java.io :as io]
- [clojure.tools.logging :as log]
+ [clojure.core.memoize :as memo]
[compojure.core :refer [defroutes GET POST]]
[hugsql.core :as hugsql]
[noir.response :as nresponse]
@@ -17,585 +16,240 @@
create-address!
"Auto-generated method to insert one record to the `addresses` table. Expects the following key(s) to be present in `params`: `(:address :postcode :phone :district_id :latitude :longitude :locality)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-address!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"postcode" "address"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/create-address! params)))
+ (let
+ [result (db/create-address! db/*db* params)]
+ (response/ok result)))
(defn
create-authority!
"Auto-generated method to insert one record to the `authorities` table. Expects the following key(s) to be present in `params`: `(:request-token-uri :access-token-uri :authorize-uri :consumer-key :consumer-secret :id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-authority!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-authority! params)))
+ (let
+ [result (db/create-authority! db/*db* params)]
+ (response/ok result)))
(defn
create-canvasser!
"Auto-generated method to insert one record to the `canvassers` table. Expects the following key(s) to be present in `params`: `(:username :fullname :elector_id :address_id :phone :email :authority_id :authorised)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-canvasser!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/create-canvasser! params)))
+ (let
+ [result (db/create-canvasser! db/*db* params)]
+ (response/ok result)))
(defn
create-district!
"Auto-generated method to insert one record to the `districts` table. Expects the following key(s) to be present in `params`: `(:name)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-district!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-district! params)))
+ (let
+ [result (db/create-district! db/*db* params)]
+ (response/ok result)))
(defn
create-dwelling!
"Auto-generated method to insert one record to the `dwellings` table. Expects the following key(s) to be present in `params`: `(:address_id :sub-address)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-dwelling!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"sub-address" "address_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/create-dwelling! params)))
+ (let
+ [result (db/create-dwelling! db/*db* params)]
+ (response/ok result)))
(defn
create-elector!
"Auto-generated method to insert one record to the `electors` table. Expects the following key(s) to be present in `params`: `(:name :dwelling_id :phone :email :gender)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-elector!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"gender" "email" "name" "phone"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/create-elector! params)))
+ (let
+ [result (db/create-elector! db/*db* params)]
+ (response/ok result)))
(defn
create-followupaction!
"Auto-generated method to insert one record to the `followupactions` table. Expects the following key(s) to be present in `params`: `(:request_id :actor :date :notes :closed)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-followupaction!"
- "' with params "
- (map
- (fn
- [p]
- (if (#{"date" "notes"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-followupaction! params)))
+ (let
+ [result (db/create-followupaction! db/*db* params)]
+ (response/ok result)))
(defn
create-followupmethod!
"Auto-generated method to insert one record to the `followupmethods` table. Expects the following key(s) to be present in `params`: `(:id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-followupmethod!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-followupmethod! params)))
+ (let
+ [result (db/create-followupmethod! db/*db* params)]
+ (response/ok result)))
(defn
create-followuprequest!
"Auto-generated method to insert one record to the `followuprequests` table. Expects the following key(s) to be present in `params`: `(:elector_id :visit_id :issue_id :method_id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-followuprequest!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"elector_id" "issue_id" "visit_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/create-followuprequest! params)))
+ (let
+ [result (db/create-followuprequest! db/*db* params)]
+ (response/ok result)))
(defn
create-gender!
"Auto-generated method to insert one record to the `genders` table. Expects the following key(s) to be present in `params`: `(:id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-gender!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-gender! params)))
+ (let [result (db/create-gender! db/*db* params)] (response/ok result)))
(defn
create-intention!
"Auto-generated method to insert one record to the `intentions` table. Expects the following key(s) to be present in `params`: `(:visit_id :elector_id :option_id :locality)`. Returns a map containing the keys `#{\"Id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-intention!"
- "' with params "
- (map
- (fn [p] (if (#{} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-intention! params)))
+ (let
+ [result (db/create-intention! db/*db* params)]
+ (response/ok result)))
(defn
create-issue!
- "Auto-generated method to insert one record to the `issues` table. Expects the following key(s) to be present in `params`: `(:url :current :id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
+ "Auto-generated method to insert one record to the `issues` table. Expects the following key(s) to be present in `params`: `(:url :current :brief :id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-issue!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-issue! params)))
+ (let [result (db/create-issue! db/*db* params)] (response/ok result)))
(defn
create-option!
"Auto-generated method to insert one record to the `options` table. Expects the following key(s) to be present in `params`: `(:id)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-option!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-option! params)))
+ (let [result (db/create-option! db/*db* params)] (response/ok result)))
(defn
create-role!
"Auto-generated method to insert one record to the `roles` table. Expects the following key(s) to be present in `params`: `(:name)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-role!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-role! params)))
+ (let [result (db/create-role! db/*db* params)] (response/ok result)))
(defn
create-team!
"Auto-generated method to insert one record to the `teams` table. Expects the following key(s) to be present in `params`: `(:name :district_id :latitude :longitude)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-team!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/create-team! params)))
+ (let [result (db/create-team! db/*db* params)] (response/ok result)))
(defn
create-visit!
"Auto-generated method to insert one record to the `visits` table. Expects the following key(s) to be present in `params`: `(:address_id :canvasser_id :date)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "create-visit!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"address_id" "date"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/create-visit! params)))
+ (let [result (db/create-visit! db/*db* params)] (response/ok result)))
(defn
delete-address!
"Auto-generated method to delete one record from the `addresses` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-address!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"postcode" "address"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/delete-address! params))
- (response/found "/"))
+ (let
+ [result (db/delete-address! db/*db* params)]
+ (response/found "/")))
(defn
delete-authority!
"Auto-generated method to delete one record from the `authorities` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-authority!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-authority! params))
- (response/found "/"))
+ (let
+ [result (db/delete-authority! db/*db* params)]
+ (response/found "/")))
(defn
delete-canvasser!
"Auto-generated method to delete one record from the `canvassers` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-canvasser!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/delete-canvasser! params))
- (response/found "/"))
+ (let
+ [result (db/delete-canvasser! db/*db* params)]
+ (response/found "/")))
(defn
delete-district!
"Auto-generated method to delete one record from the `districts` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-district!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-district! params))
- (response/found "/"))
+ (let
+ [result (db/delete-district! db/*db* params)]
+ (response/found "/")))
(defn
delete-dwelling!
"Auto-generated method to delete one record from the `dwellings` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-dwelling!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"sub-address" "address_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/delete-dwelling! params))
- (response/found "/"))
+ (let
+ [result (db/delete-dwelling! db/*db* params)]
+ (response/found "/")))
(defn
delete-elector!
"Auto-generated method to delete one record from the `electors` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-elector!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"gender" "email" "name" "phone"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/delete-elector! params))
- (response/found "/"))
+ (let
+ [result (db/delete-elector! db/*db* params)]
+ (response/found "/")))
(defn
delete-followupaction!
"Auto-generated method to delete one record from the `followupactions` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-followupaction!"
- "' with params "
- (map
- (fn
- [p]
- (if (#{"date" "notes"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-followupaction! params))
- (response/found "/"))
+ (let
+ [result (db/delete-followupaction! db/*db* params)]
+ (response/found "/")))
(defn
delete-followupmethod!
"Auto-generated method to delete one record from the `followupmethods` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-followupmethod!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-followupmethod! params))
- (response/found "/"))
+ (let
+ [result (db/delete-followupmethod! db/*db* params)]
+ (response/found "/")))
(defn
delete-followuprequest!
"Auto-generated method to delete one record from the `followuprequests` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-followuprequest!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"elector_id" "issue_id" "visit_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/delete-followuprequest! params))
- (response/found "/"))
+ (let
+ [result (db/delete-followuprequest! db/*db* params)]
+ (response/found "/")))
(defn
delete-gender!
"Auto-generated method to delete one record from the `genders` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-gender!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-gender! params))
- (response/found "/"))
+ (let [result (db/delete-gender! db/*db* params)] (response/found "/")))
(defn
delete-intention!
"Auto-generated method to delete one record from the `intentions` table. Expects the following key(s) to be present in `params`: `#{\"Id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-intention!"
- "' with params "
- (map
- (fn [p] (if (#{} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-intention! params))
- (response/found "/"))
+ (let
+ [result (db/delete-intention! db/*db* params)]
+ (response/found "/")))
(defn
delete-issue!
"Auto-generated method to delete one record from the `issues` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-issue!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-issue! params))
- (response/found "/"))
+ (let [result (db/delete-issue! db/*db* params)] (response/found "/")))
(defn
delete-option!
"Auto-generated method to delete one record from the `options` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-option!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-option! params))
- (response/found "/"))
+ (let [result (db/delete-option! db/*db* params)] (response/found "/")))
(defn
delete-role!
"Auto-generated method to delete one record from the `roles` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-role!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-role! params))
- (response/found "/"))
+ (let [result (db/delete-role! db/*db* params)] (response/found "/")))
(defn
delete-team!
"Auto-generated method to delete one record from the `teams` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-team!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/delete-team! params))
- (response/found "/"))
+ (let [result (db/delete-team! db/*db* params)] (response/found "/")))
(defn
delete-visit!
"Auto-generated method to delete one record from the `visits` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "delete-visit!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"address_id" "date"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/delete-visit! params))
- (response/found "/"))
+ (let [result (db/delete-visit! db/*db* params)] (response/found "/")))
(def
get-address
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-address"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"postcode" "address"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-address params))
- nil)
+ (let [result (db/get-address db/*db* params)] (response/ok result)))
:ttl/threshold
1000000000))
@@ -604,17 +258,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-authority"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-authority params))
- nil)
+ (let
+ [result (db/get-authority db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -623,23 +269,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-canvasser"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-canvasser params))
- nil)
+ (let
+ [result (db/get-canvasser db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000))
@@ -648,23 +280,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-canvasser-by-username"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-canvasser-by-username params))
- nil)
+ (let
+ [result (db/get-canvasser-by-username db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000))
@@ -673,17 +291,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-district"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-district params))
- nil)
+ (let
+ [result (db/get-district db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -692,22 +302,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-dwelling"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"sub-address" "address_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-dwelling params))
- nil)
+ (let
+ [result (db/get-dwelling db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -716,22 +313,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-elector"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"gender" "email" "name" "phone"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-elector params))
- nil)
+ (let [result (db/get-elector db/*db* params)] (response/ok result)))
:ttl/threshold
100000000))
@@ -739,35 +321,18 @@
get-followupaction
"Auto-generated method to select one record from the `followupactions` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`. Returns a map containing the following keys: `clojure.lang.LazySeq@6b32af0e`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-followupaction"
- "' with params "
- (map
- (fn
- [p]
- (if (#{"date" "notes"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-followupaction params)))
+ (let
+ [result (db/get-followupaction db/*db* params)]
+ (response/ok result)))
(def
get-followupmethod
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-followupmethod"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-followupmethod params))
- nil)
+ (let
+ [result (db/get-followupmethod db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -776,22 +341,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-followuprequest"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"elector_id" "issue_id" "visit_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-followuprequest params))
- nil)
+ (let
+ [result (db/get-followuprequest db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -800,17 +352,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-gender"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-gender params))
- nil)
+ (let [result (db/get-gender db/*db* params)] (response/ok result)))
:ttl/threshold
1000000000))
@@ -819,17 +361,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-intention"
- "' with params "
- (map
- (fn [p] (if (#{} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-intention params))
- nil)
+ (let
+ [result (db/get-intention db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -838,17 +372,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-issue"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-issue params))
- nil)
+ (let [result (db/get-issue db/*db* params)] (response/ok result)))
:ttl/threshold
1000000))
@@ -857,17 +381,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-option"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-option params))
- nil)
+ (let [result (db/get-option db/*db* params)] (response/ok result)))
:ttl/threshold
10000000000))
@@ -876,17 +390,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-role"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-role params))
- nil)
+ (let [result (db/get-role db/*db* params)] (response/ok result)))
:ttl/threshold
10000000000))
@@ -895,17 +399,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-role-by-name"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-role-by-name params))
- nil)
+ (let
+ [result (db/get-role-by-name db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -914,17 +410,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-team"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/get-team params))
- nil)
+ (let [result (db/get-team db/*db* params)] (response/ok result)))
:ttl/threshold
10000000))
@@ -933,22 +419,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "get-visit"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"address_id" "date"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/get-visit params))
- nil)
+ (let [result (db/get-visit db/*db* params)] (response/ok result)))
:ttl/threshold
100000))
@@ -957,22 +428,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-addresses"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"postcode" "address"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/list-addresses params))
- nil)
+ (let
+ [result (db/list-addresses db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -986,17 +444,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-authorities"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-authorities params))
- nil)
+ (let
+ [result (db/list-authorities db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1005,23 +455,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-canvassers"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/list-canvassers params))
- nil)
+ (let
+ [result (db/list-canvassers db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000))
@@ -1050,17 +486,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-districts"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-districts params))
- nil)
+ (let
+ [result (db/list-districts db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1069,22 +497,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-dwellings"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"sub-address" "address_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/list-dwellings params))
- nil)
+ (let
+ [result (db/list-dwellings db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -1098,22 +513,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-electors"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"gender" "email" "name" "phone"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/list-electors params))
- nil)
+ (let
+ [result (db/list-electors db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000000))
@@ -1131,18 +533,9 @@
list-followupactions
"Auto-generated method to select all records from the `followupactions` table. If the keys `(:limit :offset)` are present in the request then they will be used to page through the data. Returns a sequence of maps each containing the following keys: `(:request_id :actor :date :notes :closed :id)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-followupactions"
- "' with params "
- (map
- (fn
- [p]
- (if (#{"date" "notes"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-followupactions params)))
+ (let
+ [result (db/list-followupactions db/*db* params)]
+ (response/ok result)))
(defn
list-followupactions-by-canvasser
@@ -1159,17 +552,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-followupmethods"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-followupmethods params))
- nil)
+ (let
+ [result (db/list-followupmethods db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1178,22 +563,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-followuprequests"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"elector_id" "issue_id" "visit_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/list-followuprequests params))
- nil)
+ (let
+ [result (db/list-followuprequests db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -1222,17 +594,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-genders"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-genders params))
- nil)
+ (let
+ [result (db/list-genders db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -1241,17 +605,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-intentions"
- "' with params "
- (map
- (fn [p] (if (#{} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-intentions params))
- nil)
+ (let
+ [result (db/list-intentions db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -1275,17 +631,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-issues"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-issues params))
- nil)
+ (let [result (db/list-issues db/*db* params)] (response/ok result)))
:ttl/threshold
1000000))
@@ -1294,17 +640,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-options"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-options params))
- nil)
+ (let
+ [result (db/list-options db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1313,17 +651,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-roles"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-roles params))
- nil)
+ (let [result (db/list-roles db/*db* params)] (response/ok result)))
:ttl/threshold
10000000000))
@@ -1337,17 +665,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-teams"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/list-teams params))
- nil)
+ (let [result (db/list-teams db/*db* params)] (response/ok result)))
:ttl/threshold
10000000))
@@ -1366,22 +684,7 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "list-visits"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"address_id" "date"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/list-visits params))
- nil)
+ (let [result (db/list-visits db/*db* params)] (response/ok result)))
:ttl/threshold
100000))
@@ -1400,22 +703,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-address"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"postcode" "address"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/search-strings-address params))
- nil)
+ (let
+ [result (db/search-strings-address db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -1424,17 +714,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-authority"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-authority params))
- nil)
+ (let
+ [result (db/search-strings-authority db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1443,23 +725,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-canvasser"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/search-strings-canvasser params))
- nil)
+ (let
+ [result (db/search-strings-canvasser db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000))
@@ -1468,17 +736,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-district"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-district params))
- nil)
+ (let
+ [result (db/search-strings-district db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1487,22 +747,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-dwelling"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"sub-address" "address_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/search-strings-dwelling params))
- nil)
+ (let
+ [result (db/search-strings-dwelling db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -1511,22 +758,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-elector"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"gender" "email" "name" "phone"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/search-strings-elector params))
- nil)
+ (let
+ [result (db/search-strings-elector db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000000))
@@ -1534,35 +768,18 @@
search-strings-followupaction
"Auto-generated method to select all records from the `followupactions` table with any text field matching the value of the key `:pattern` which should be in the request. If the keys `(:limit :offset)` are present in the request then they will be used to page through the data. Returns a sequence of maps each containing the following keys: `(:request_id :actor :date :notes :closed :id)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-followupaction"
- "' with params "
- (map
- (fn
- [p]
- (if (#{"date" "notes"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-followupaction params)))
+ (let
+ [result (db/search-strings-followupaction db/*db* params)]
+ (response/ok result)))
(def
search-strings-followupmethod
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-followupmethod"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-followupmethod params))
- nil)
+ (let
+ [result (db/search-strings-followupmethod db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1571,22 +788,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-followuprequest"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"elector_id" "issue_id" "visit_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/search-strings-followuprequest params))
- nil)
+ (let
+ [result (db/search-strings-followuprequest db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -1595,17 +799,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-gender"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-gender params))
- nil)
+ (let
+ [result (db/search-strings-gender db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000000))
@@ -1614,17 +810,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-intention"
- "' with params "
- (map
- (fn [p] (if (#{} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-intention params))
- nil)
+ (let
+ [result (db/search-strings-intention db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -1633,17 +821,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-issue"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-issue params))
- nil)
+ (let
+ [result (db/search-strings-issue db/*db* params)]
+ (response/ok result)))
:ttl/threshold
1000000))
@@ -1652,17 +832,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-option"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-option params))
- nil)
+ (let
+ [result (db/search-strings-option db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1671,17 +843,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-role"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-role params))
- nil)
+ (let
+ [result (db/search-strings-role db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000000))
@@ -1690,17 +854,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-team"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/search-strings-team params))
- nil)
+ (let
+ [result (db/search-strings-team db/*db* params)]
+ (response/ok result)))
:ttl/threshold
10000000))
@@ -1709,22 +865,9 @@
(memo/ttl
(fn
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "search-strings-visit"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"address_id" "date"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/search-strings-visit params))
- nil)
+ (let
+ [result (db/search-strings-visit db/*db* params)]
+ (response/ok result)))
:ttl/threshold
100000))
@@ -1732,242 +875,97 @@
update-address!
"Auto-generated method to update one record in the `addresses` table. Expects the following key(s) to be present in `params`: `(:address :district_id :id :latitude :locality :longitude :phone :postcode)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-address!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"postcode" "address"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/update-address! params))
- (response/found "/"))
+ (let
+ [result (db/update-address! db/*db* params)]
+ (response/found "/")))
(defn
update-authority!
"Auto-generated method to update one record in the `authorities` table. Expects the following key(s) to be present in `params`: `(:access-token-uri :authorize-uri :consumer-key :consumer-secret :id :request-token-uri)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-authority!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-authority! params))
- (response/found "/"))
+ (let
+ [result (db/update-authority! db/*db* params)]
+ (response/found "/")))
(defn
update-canvasser!
"Auto-generated method to update one record in the `canvassers` table. Expects the following key(s) to be present in `params`: `(:address_id :authorised :authority_id :elector_id :email :fullname :id :phone :username)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-canvasser!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"username" "address_id" "email" "phone" "fullname"}
- (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/update-canvasser! params))
- (response/found "/"))
+ (let
+ [result (db/update-canvasser! db/*db* params)]
+ (response/found "/")))
(defn
update-district!
"Auto-generated method to update one record in the `districts` table. Expects the following key(s) to be present in `params`: `(:id :name)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-district!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-district! params))
- (response/found "/"))
+ (let
+ [result (db/update-district! db/*db* params)]
+ (response/found "/")))
(defn
update-dwelling!
"Auto-generated method to update one record in the `dwellings` table. Expects the following key(s) to be present in `params`: `(:address_id :id :sub-address)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-dwelling!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"sub-address" "address_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/update-dwelling! params))
- (response/found "/"))
+ (let
+ [result (db/update-dwelling! db/*db* params)]
+ (response/found "/")))
(defn
update-elector!
"Auto-generated method to update one record in the `electors` table. Expects the following key(s) to be present in `params`: `(:dwelling_id :email :gender :id :name :phone)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-elector!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"gender" "email" "name" "phone"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/update-elector! params))
- (response/found "/"))
+ (let
+ [result (db/update-elector! db/*db* params)]
+ (response/found "/")))
(defn
update-followupaction!
"Auto-generated method to update one record in the `followupactions` table. Expects the following key(s) to be present in `params`: `(:actor :closed :date :id :notes :request_id)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-followupaction!"
- "' with params "
- (map
- (fn
- [p]
- (if (#{"date" "notes"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-followupaction! params))
- (response/found "/"))
+ (let
+ [result (db/update-followupaction! db/*db* params)]
+ (response/found "/")))
(defn
update-followuprequest!
"Auto-generated method to update one record in the `followuprequests` table. Expects the following key(s) to be present in `params`: `(:elector_id :id :issue_id :method_id :visit_id)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-followuprequest!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"elector_id" "issue_id" "visit_id"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/update-followuprequest! params))
- (response/found "/"))
+ (let
+ [result (db/update-followuprequest! db/*db* params)]
+ (response/found "/")))
(defn
update-intention!
"Auto-generated method to update one record in the `intentions` table. Expects the following key(s) to be present in `params`: `(:Id :elector_id :locality :option_id :visit_id)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-intention!"
- "' with params "
- (map
- (fn [p] (if (#{} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-intention! params))
- (response/found "/"))
+ (let
+ [result (db/update-intention! db/*db* params)]
+ (response/found "/")))
(defn
update-issue!
- "Auto-generated method to update one record in the `issues` table. Expects the following key(s) to be present in `params`: `(:current :id :url)`."
+ "Auto-generated method to update one record in the `issues` table. Expects the following key(s) to be present in `params`: `(:brief :current :id :url)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-issue!"
- "' with params "
- (map
- (fn [p] (if (#{"id"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-issue! params))
- (response/found "/"))
+ (let [result (db/update-issue! db/*db* params)] (response/found "/")))
(defn
update-role!
"Auto-generated method to update one record in the `roles` table. Expects the following key(s) to be present in `params`: `(:id :name)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-role!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-role! params))
- (response/found "/"))
+ (let [result (db/update-role! db/*db* params)] (response/found "/")))
(defn
update-team!
"Auto-generated method to update one record in the `teams` table. Expects the following key(s) to be present in `params`: `(:district_id :id :latitude :longitude :name)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-team!"
- "' with params "
- (map
- (fn [p] (if (#{"name"} (str (name p))) (params p) "[ELIDED]"))
- (keys params))))
- (db/update-team! params))
- (response/found "/"))
+ (let [result (db/update-team! db/*db* params)] (response/found "/")))
(defn
update-visit!
"Auto-generated method to update one record in the `visits` table. Expects the following key(s) to be present in `params`: `(:address_id :canvasser_id :date :id)`."
[{:keys [params]}]
- (do
- (log/debug
- (str
- "Calling query '"
- "update-visit!"
- "' with params "
- (map
- (fn
- [p]
- (if
- (#{"address_id" "date"} (str (name p)))
- (params p)
- "[ELIDED]"))
- (keys params))))
- (db/update-visit! params))
- (response/found "/"))
+ (let [result (db/update-visit! db/*db* params)] (response/found "/")))
(defroutes
auto-rest-routes
diff --git a/src/clj/youyesyet/routes/rest.clj b/src/clj/youyesyet/routes/rest.clj
index b38a878..71aad48 100644
--- a/src/clj/youyesyet/routes/rest.clj
+++ b/src/clj/youyesyet/routes/rest.clj
@@ -1,4 +1,4 @@
-(ns ^{:doc "Routes which handle data transfer to/from the canvasser app."
+(ns ^{:doc "Manually maintained routes which handle data transfer to/from the canvasser app."
:author "Simon Brooke"} youyesyet.routes.rest
(:require [clojure.core.memoize :as memo]
[clojure.java.io :as io]
@@ -36,6 +36,7 @@
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; See also src/clj/youyesyet/routes/auto-json.clj
(def in-get-local-data
"Local data is volatile, because hopefully canvassers are updating it as they
@@ -82,13 +83,8 @@
(in-get-local-data here)))
-
-(defn get-issues
- "Get current issues. No arguments expected."
- [request])
-
(defroutes rest-routes
- (GET "/rest/get-local-data" request (get-local-data request))
+ (GET "/rest/get-local-data" request (route/restricted (get-local-data request)))
;; (GET "/rest/get-issues" request (route/restricted (get-issues request)))
;; (GET "/rest/set-intention" request (route/restricted (set-intention request)))
;; (GET "/rest/request-followup" request (route/restricted (request-followup request))))
diff --git a/src/cljc/youyesyet/utils.cljc b/src/cljc/youyesyet/utils.cljc
index 41c9cb9..fd07386 100644
--- a/src/cljc/youyesyet/utils.cljc
+++ b/src/cljc/youyesyet/utils.cljc
@@ -1,10 +1,10 @@
(ns youyesyet.utils
- #?(:clj (require [clojure.tools.logging :as log]))
- )
+ #?(:clj (:require [clojure.tools.logging :as log])
+ :cljs (:require [cljs.reader :refer [read-string]])))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
-;;;; youyesyet.locality: small utility functions.
+;;;; youyesyet.utils: small utility functions.
;;;;
;;;; This program is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU General Public License
@@ -27,9 +27,11 @@
(defn coerce-to-number [v]
"If it is possible to do so, coerce `v` to a number"
+ ;; TODO: this doesn't work in cljs.
(if (number? v) v
(try
(read-string (str v))
#?(:clj (catch Exception any
(log/error (str "Could not coerce '" v "' to number: " any)))
- :cljs (js/console.log (str "Could not coerce '" v "' to number: " any))))))
+ :cljs (catch js/Object any
+ (js/console.log (str "Could not coerce '" v "' to number: " any)))))))
diff --git a/src/cljs/youyesyet/canvasser_app/core.cljs b/src/cljs/youyesyet/canvasser_app/core.cljs
index e1e4347..355bdba 100644
--- a/src/cljs/youyesyet/canvasser_app/core.cljs
+++ b/src/cljs/youyesyet/canvasser_app/core.cljs
@@ -104,8 +104,10 @@
(if content [content]
[:div.error (str "No content in page " @(rf/subscribe [:page]))])
[:footer
- [:div.error {:style [:display (if error "block" "none")]} (str error)]
- [:div.feedback {:style [:display (if feedback :block :none)]} (str feedback)]
+ [:div.error {:style [:display (if (empty? error) :none :block)]} (apply str error)]
+ [:div.feedback
+ {:style [:display (if (empty? feedback) :none :block)]}
+ (apply str (map #(h/feedback-messages %) (distinct feedback)))]
[:div.queue (if
(nil? outqueue) ""
(str (count outqueue) " items queued to send"))]]]))
@@ -190,6 +192,9 @@
(defn init! []
(rf/dispatch-sync [:initialize-db])
(h/get-current-location)
+ (rf/dispatch [:fetch-locality])
+ (rf/dispatch [:fetch-options])
+ (rf/dispatch [:fetch-issues])
(load-interceptors!)
(hook-browser-navigation!)
(mount-components))
diff --git a/src/cljs/youyesyet/canvasser_app/handlers.cljs b/src/cljs/youyesyet/canvasser_app/handlers.cljs
index 45edcd1..634e7cf 100644
--- a/src/cljs/youyesyet/canvasser_app/handlers.cljs
+++ b/src/cljs/youyesyet/canvasser_app/handlers.cljs
@@ -2,9 +2,12 @@
:author "Simon Brooke"}
youyesyet.canvasser-app.handlers
(:require [cljs.reader :refer [read-string]]
- [re-frame.core :refer [dispatch reg-event-db]]
+ [cemerick.url :refer (url url-encode)]
+ [day8.re-frame.http-fx]
+ [re-frame.core :refer [dispatch reg-event-db reg-event-fx subscribe]]
+ [ajax.core :refer [GET]]
+ [ajax.json :refer [json-request-format json-response-format]]
[youyesyet.canvasser-app.state :as db]
- [youyesyet.utils :refer :all]
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -34,9 +37,47 @@
"Return a state like this state except with the error and feedback messages
set nil"
[state]
- (merge state {:error nil :feedback nil}))
+ (merge state {:error '() :feedback '()}))
+(def source-host (assoc
+ (url js/window.location)
+ :path "/"
+ :query nil
+ :anchor nil))
+
+
+(def feedback-messages
+ {:fetch-locality "Fetching local data."
+ :send-request "Request has been queued."
+ })
+
+
+(defn add-to-feedback
+ "Add the value of `k` in `feedback-messages` to the feedback in this `db`."
+ [db k]
+ (assoc db :feedback (cons k (:feedback db))))
+
+
+(defn remove-from-feedback
+ "Remove the value of `k` in `feedback-messages` to the feedback in this `db`."
+ [db k]
+ (assoc db
+ :feedback
+ (remove
+ #(= % k)
+ (:feedback db))))
+
+
+(defn coerce-to-number [v]
+ "If it is possible to do so, coerce `v` to a number.
+ NOTE: I tried to do this in *cljc*, but it did not work. Leave it alone."
+ (if (number? v) v
+ (try
+ (read-string (str v))
+ (catch js/Object any
+ (js/console.log (str "Could not coerce '" v "' to number: " any))
+ v))))
(defn get-elector
@@ -60,17 +101,250 @@
(:electors state) "'")))))
+;; map stuff. If we do this in canvasser-app.views.map we get circular
+;; references, so do it here.
+(defn pin-image
+ "select the name of a suitable pin image for this address"
+ [address]
+ (let [intentions
+ (set
+ (remove
+ nil?
+ (map
+ :intention
+ (mapcat :electors
+ (:dwellings address)))))]
+ (case (count intentions)
+ 0 "unknown-pin"
+ 1 (str (name (first intentions)) "-pin")
+ "mixed-pin")))
+
+
+(defn map-pin-click-handler
+ "On clicking on the pin, navigate to the electors at the address.
+ This way of doing it adds an antry in the browser location history,
+ so back links work."
+ [id]
+ (js/console.log (str "Click handler for address #" id))
+ (let [view @(subscribe [:view])
+ centre (.getCenter view)]
+ (dispatch [:set-zoom (.getZoom view)])
+ (dispatch [:set-latitude (.-lat centre)])
+ (dispatch [:set-longitude (.-lng centre)]))
+ (set! window.location.href (str "#building/" id)))
+
+
+(defn add-map-pin
+ "Add a map-pin at this address in this map view"
+ [address view]
+ (let [lat (:latitude address)
+ lng (:longitude address)
+ pin (.icon js/L
+ (clj->js
+ {:iconAnchor [16 41]
+ :iconSize [32 42]
+ :iconUrl (str "img/map-pins/" (pin-image address) ".png")
+ :riseOnHover true
+ :shadowAnchor [16 23]
+ :shadowSize [57 24]
+ :shadowUrl "img/map-pins/shadow_pin.png"}))
+ marker (.marker js/L
+ (.latLng js/L lat lng)
+ (clj->js {:icon pin
+ :title (:address address)}))]
+ (.on (.addTo marker view) "click" (fn [_] (map-pin-click-handler (str (:id address)))))
+ marker))
+
+
+(defn map-remove-pins
+ "Remove all pins from this map `view`. Side-effecty; liable to be problematic."
+ [view]
+ (try
+ (if
+ view
+ (.eachLayer
+ view
+ (fn [layer]
+ (if
+ (instance? layer js/L.Marker)
+ (.removeLayer view layer)))))
+ (catch js/Object any (js/console.log (str "Failed to remove pins from map: " any))))
+ view)
+
+
+(defn refresh-map-pins
+ "Refresh the map pins on this map. Side-effecty; liable to be problematic."
+ []
+ (let [view (map-remove-pins @(subscribe [:view]))
+ addresses @(subscribe [:addresses])]
+ (if
+ view
+ (do
+ (js/console.log (str "Adding " (count addresses) " pins"))
+ (doall (map #(add-map-pin % view) addresses)))
+ (js/console.log "View is not yet ready"))
+ view))
+
+
(reg-event-db
:initialize-db
(fn [_ _]
db/default-db))
+(defn get-current-location []
+ "Get the current location from the device."
+ (try
+ (if (.-geolocation js/navigator)
+ (.getCurrentPosition
+ (.-geolocation js/navigator)
+ (fn [position]
+ (js/console.log "Current location is: " + position)
+ (dispatch [:set-latitude (.-latitude (.-coords position))])
+ (dispatch [:set-longitude (.-longitude (.-coords position))])))
+ (js/console.log "Geolocation not available"))
+ (catch js/Object any
+ (js/console.log "Exception while trying to access location: " + any))))
+
+
+;; (reg-event-fx
+;; :feedback
+;; (fn [x y]
+;; (js/console.log (str "Feedback event called with x = " x "; y = " y))
+;; (:db x)))
+
+
+;; (reg-event-fx
+;; :issues
+;; (fn [x y]
+;; (js/console.log (str "Issues event called with x = " x "; y = " y))
+;; (:db x)))
+
+
+;; (reg-event-fx
+;; :options
+;; (fn [x y]
+;; (js/console.log (str "Options event called with x = " x "; y = " y))
+;; (:db x)))
+
+
+;; (reg-event-fx
+;; :event
+;; (fn [x y]
+;; (js/console.log (str "Event event called with x = " x "; y = " y))
+;; (:db x)))
+
+
+(reg-event-fx
+ :fetch-locality
+ (fn [{db :db} _]
+ (js/console.log "Fetching locality data")
+ ;; we return a map of (side) effects
+ {:http-xhrio {:method :get
+ :uri (str source-host
+ "rest/get-local-data?latitude="
+ (:latitude db)
+ "&longitude="
+ (:longitude db))
+ :format (json-request-format)
+ :response-format (json-response-format {:keywords? true})
+ :on-success [:process-locality]
+ :on-failure [:bad-locality]}
+ :db (add-to-feedback db :fetch-locality)}))
+
+
+(reg-event-db
+ :process-locality
+ (fn
+ [db [_ response]]
+ (js/console.log "Updating locality data")
+ (assoc
+ (remove-from-feedback db :fetch-locality)
+ (refresh-map-pins)
+ :addresses (js->clj response))))
+
+
+(reg-event-db
+ :bad-locality
+ (fn [db _]
+ ;; TODO: signal something has failed? It doesn't matter very much, unless it keeps failing.
+ (js/console.log "Failed to fetch locality data")
+ (assoc
+ (remove-from-feedback db :fetch-locality)
+ :error (cons :fetch-locality (:error db)))))
+
+
+(reg-event-fx
+ :fetch-options
+ (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-options")
+ :format (json-request-format)
+ :response-format (json-response-format {:keywords? true})
+ :on-success [:process-options]
+ :on-failure [:bad-options]}
+ :db (add-to-feedback db :fetch-options)}))
+
+
+(reg-event-db
+ :process-options
+ (fn
+ [db [_ response]]
+ (js/console.log "Updating options")
+ (assoc
+ (remove-from-feedback db :fetch-options)
+ :options (js->clj response))))
+
+
+(reg-event-db
+ :bad-options
+ (fn [db _]
+ (js/console.log "Failed to fetch options")
+ (assoc
+ (remove-from-feedback db :fetch-options)
+ :error (cons :fetch-options (:error db)))))
+
+
+(reg-event-fx
+ :fetch-issues
+ (fn [{db :db} _]
+ (js/console.log "Fetching issues")
+ ;; we return a map of (side) effects
+ {:http-xhrio {:method :get
+ :uri (str source-host "json/auto/list-issues")
+ :format (json-request-format)
+ :response-format (json-response-format {:keywords? true})
+ :on-success [:process-issues]
+ :on-failure [:bad-issues]}
+ :db (add-to-feedback db :fetch-issues)}))
+
+
+(reg-event-db
+ :process-issues
+ (fn
+ [db [_ response]]
+ (js/console.log "Updating issues")
+ (assoc
+ (remove-from-feedback db :fetch-issues)
+ :issues (js->clj response))))
+
+
+(reg-event-db
+ :bad-issues
+ (fn [db _]
+ (js/console.log "Failed to fetch issues")
+ (assoc
+ (remove-from-feedback db :fetch-issues)
+ :error (cons :fetch-issues (:error db)))))
+
+
(reg-event-db
:send-intention
(fn [db [_ args]]
(let [intention (:intention args)
- elector-id (coerce-to-number (:elector-id args))
+ elector-id (:elector-id args)
old-elector (first
(remove nil?
(map
@@ -97,11 +371,11 @@
(:dwellings old-address))))]
(cond
(nil? old-elector)
- (assoc db :error "No elector found; not setting intention")
- (= intention (:intention old-elector))
- (do
- (js/console.log "Elector's intention hasn't changed; not setting intention")
- db)
+ (assoc db :error (cons "No elector found; not setting intention" (:error db))
+ (= intention (:intention old-elector))
+ (do
+ (js/console.log "Elector's intention hasn't changed; not setting intention")
+ db))
true
(do
(js/console.log (str "Setting intention of elector " old-elector " to " intention))
@@ -125,8 +399,7 @@
(if (and (:elector db) (:issue db) (:telephone db))
(do
(js/console.log "Sending request")
- (assoc db
- :feedback "Request has been queued"
+ (assoc (add-to-feedback db :send-request)
:outqueue (cons
{:elector-id (:id (:elector db))
:issue (:issue db)
@@ -136,15 +409,16 @@
(reg-event-db
:set-active-page
- (fn [db [_ page]]
- (if page
- (assoc (clear-messages db) :page page))))
+ (fn [db [_ k]]
+ (if k
+ (assoc (clear-messages db) :page k)
+ db)))
(reg-event-db
:set-address
(fn [db [_ address-id]]
- (let [id (coerce-to-number address-id)
+ (let [id (coerce-to-number address-id)
address (first (remove nil? (map #(if (= id (:id %)) %) (:addresses db))))]
(if
(= (count (:dwellings address)) 1)
@@ -167,7 +441,7 @@
consent (:consent args)
elector-id (coerce-to-number (:elector-id args))
elector (get-elector elector-id db)]
- (js/console.log (str "Setting page to " page ", consent to " consent " for " elector))
+ (js/console.log (str "Setting page to " page ", consent to " consent " for " (:name elector)))
(assoc (clear-messages db) :elector (assoc elector :consent true) :page page))))
@@ -200,7 +474,7 @@
:set-elector-and-page
(fn [db [_ args]]
(let [page (:page args)
- elector-id (coerce-to-number (:elector-id args))
+ elector-id (:elector-id args)
elector (get-elector elector-id db)]
(js/console.log (str "Setting page to " page ", elector to " elector))
(assoc (clear-messages db) :elector elector :page page))))
@@ -252,18 +526,3 @@
(if (integer? zoom)
(assoc db :zoom zoom)
db)))
-
-
-(defn get-current-location []
- "Get the current location from the device."
- (try
- (if (.-geolocation js/navigator)
- (.getCurrentPosition
- (.-geolocation js/navigator)
- (fn [position]
- (js/console.log "Current location is: " + position)
- (dispatch [:set-latitude (.-latitude (.-coords position))])
- (dispatch [:set-longitude (.-longitude (.-coords position))])))
- (js/console.log "Geolocation not available"))
- (catch js/Object any
- (js/console.log "Exception while trying to access location: " + any))))
diff --git a/src/cljs/youyesyet/canvasser_app/state.cljs b/src/cljs/youyesyet/canvasser_app/state.cljs
index 7cb01de..c01f85d 100644
--- a/src/cljs/youyesyet/canvasser_app/state.cljs
+++ b/src/cljs/youyesyet/canvasser_app/state.cljs
@@ -29,59 +29,128 @@
;;; The atom gets updated by 'events' registered in handler.cljs, q.v.
(def default-db
- {;;; the currently selected address, if any.
- :address {:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2569057
- :dwellings [{:id 1
- :electors [{:id 1 :name "Alan Anderson" :gender :male :intention :no}
- {:id 2 :name "Ann Anderson" :gender :female}
- {:id 3 :name "Alex Anderson" :gender :fluid :intention :yes}
- {:id 4 :name "Andy Anderson" :intention :yes}]}]}
- ;;; a list of the addresses in the current location at which there
- ;;; are electors registered.
- :addresses [{:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2570944
- :dwellings [{:id 1
- :electors [{:id 1 :name "Alan Anderson" :gender :male :intention :no}
- {:id 2 :name "Ann Anderson" :gender :female}
- {:id 3 :name "Alex Anderson" :gender :fluid :intention :yes}
- {:id 4 :name "Andy Anderson" :intention :yes}]}]}
- {:id 2 :address "15 Imaginary Terrace, IM1 3TE" :latitude 55.8252354 :longitude -4.2572778
- :dwellings [{:id 2
- :electors [{:id 5 :name "Beryl Brown" :gender :female}
- {:id 6 :name "Betty Black" :gender :female}]}]}
+ {
+ :addresses
+ [{:locality 548223905,
+ :address
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF",
+ :phone nil,
+ :postcode "DG7 1RF",
+ :longitude -3.905045374625994,
+ :district_id 1,
+ :dwellings
+ [{:address_id_expanded
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF, DG7 1RF",
+ :address_id 18,
+ :sub_address "",
+ :id 17,
+ :id_2 17,
+ :address_id_2 18,
+ :sub_address_2 "",
+ :electors
+ [{:email nil,
+ :dwelling_id_2 17,
+ :dwelling_id_expanded
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF, DG7 1RF, ",
+ :intentions
+ [{:locality 548223905,
+ :visit_id_expanded
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF, DG7 1RF, 2018-06-14 20:29:34.721522",
+ :option_id_expanded "Yes",
+ :option_id "Yes",
+ :option_id_2 "Yes",
+ :visit_id_2 1,
+ :elector_id_2 61,
+ :visit_id 1,
+ :elector_id 61,
+ :id 1,
+ :elector_id_expanded nil,
+ :id_2 1}],
+ :phone nil,
+ :phone_2 nil,
+ :gender_expanded "Female",
+ :name "Alice Sutherland",
+ :dwelling_id 17,
+ :id 61,
+ :gender "Female",
+ :gender_2 "Female",
+ :name_2 "Alice Sutherland",
+ :email_2 nil,
+ :id_2 61}
+ {:email nil,
+ :dwelling_id_2 17,
+ :dwelling_id_expanded
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF, DG7 1RF, ",
+ :intentions [],
+ :phone nil,
+ :phone_2 nil,
+ :gender_expanded "Female",
+ :name "Charlie Sutherland",
+ :dwelling_id 17,
+ :id 62,
+ :gender "Female",
+ :gender_2 "Female",
+ :name_2 "Charlie Sutherland",
+ :email_2 nil,
+ :id_2 62}
+ {:email nil,
+ :dwelling_id_2 17,
+ :dwelling_id_expanded
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF, DG7 1RF, ",
+ :intentions [],
+ :phone nil,
+ :phone_2 nil,
+ :gender_expanded "Male",
+ :name "Keith Sutherland",
+ :dwelling_id 17,
+ :id 64,
+ :gender "Male",
+ :gender_2 "Male",
+ :name_2 "Keith Sutherland",
+ :email_2 nil,
+ :id_2 64}
+ {:email nil,
+ :dwelling_id_2 17,
+ :dwelling_id_expanded
+ "HAZELFIELD HOUSE, CASTLE DOUGLAS, DG7 1RF, DG7 1RF, ",
+ :intentions [],
+ :phone nil,
+ :phone_2 nil,
+ :gender_expanded "Female",
+ :name "Lucy Sutherland",
+ :dwelling_id 17,
+ :id 63,
+ :gender "Female",
+ :gender_2 "Female",
+ :name_2 "Lucy Sutherland",
+ :email_2 nil,
+ :id_2 63}]}],
+ :id 18,
+ :latitude 54.8222716877376}]
- {:id 3 :address "17 Imaginary Terrace, IM1 3TE" :latitude 55.825166 :longitude -4.257026
- :dwellings [{:id 3 :sub-address "Flat 1"
- :electors [{:id 7 :name "Catriona Crathie" :gender :female :intention :yes}
- {:id 8 :name "Colin Caruthers" :gender :male :intention :yes}
- {:id 9 :name "Calum Crathie" :intention :yes}]}
- {:id 4 :sub-address "Flat 2"
- :electors [{:id 1 :name "David Dewar" :gender :male :intention :no}]}]}]
+ ;;; the currently selected address, if any.
+ :address nil
;;; electors at the currently selected dwelling
- :electors [{:id 1 :name "Alan Anderson" :gender :male :intention :no}
- {:id 2 :name "Ann Anderson" :gender :female}
- {:id 3 :name "Alex Anderson" :gender :fluid :intention :yes}
- {:id 4 :name "Andy Anderson" :intention :yes}]
+ :electors nil
;;; any error to display
:error nil
;;; the issue from among the issues which is currently selected.
;;; any confirmation message to display
- :feedback nil
+ :feedback '()
;;; the currently selected issue
- :issue "Currency"
+ :issue nil
;;; the issues selected for the issues page on this day.
- :issues {"Currency" "Scotland could keep the Pound, or use the Euro. But we could also set up a new currency of our own. Yada yada yada"
- "Monarchy" "Scotland could keep the Queen. This is an issue to be decided after independence. Yada yada yada"
- "Defence" "Scotland will not have nuclear weapons, and will probably not choose to engage in far-off wars. But we could remain members of NATO"}
+ :issues nil
;;; message of the day
:motd "This is a test version only. There is no real data."
;;; the options from among which electors can select.
- :options [{:id :yes :description "Yes"} {:id :no :description "No"}]
+ :options nil
;;; the queue of items waiting to be transmitted.
:outqueue ()
;;; the currently displayed page within the app.
:page :home
:view nil
- :latitude 55.82
- :longitude -4.25
+ :latitude 54.82
+ :longitude -3.90
:zoom 12})
diff --git a/src/cljs/youyesyet/canvasser_app/ui_utils.cljs b/src/cljs/youyesyet/canvasser_app/ui_utils.cljs
index 2f6a52b..12ab66f 100644
--- a/src/cljs/youyesyet/canvasser_app/ui_utils.cljs
+++ b/src/cljs/youyesyet/canvasser_app/ui_utils.cljs
@@ -37,15 +37,16 @@
[:div.back-link-container {:key (gensym "back-link")}
[:a.back-link {:href target} "Back"]]))
+
(defn big-link
[text & {:keys [target handler]}]
- (js/console.log (str "Constructing big link; target is '" target "'; handler is '" handler "'"))
[:div.big-link-container {:key (gensym "big-link")}
[:a.big-link (merge
(if target {:href target}{})
(if handler {:on-click handler}{}))
text]])
+
(defn nav-link [uri title page collapsed?]
(let [selected-page @(rf/subscribe [:page])]
[:li.nav-item
diff --git a/src/cljs/youyesyet/canvasser_app/views/dwelling.cljs b/src/cljs/youyesyet/canvasser_app/views/dwelling.cljs
index 97c0143..73f28b3 100644
--- a/src/cljs/youyesyet/canvasser_app/views/dwelling.cljs
+++ b/src/cljs/youyesyet/canvasser_app/views/dwelling.cljs
@@ -50,12 +50,10 @@
(defn gender-cell
[elector]
(let [gender (:gender elector)
- image (if gender (name gender) "unknown")]
+ image (if gender (name gender) "Unknown")]
[:td {:key (str "gender-" (:id elector))}
[:a {:href (str "#gdpr/" (:id elector))}
- [:img {:src (str "img/gender/" image ".png") :alt image
- ;; :on-click #(go-to-gdpr-for-elector elector)
- }]]]))
+ [:img {:src (str "img/gender/" image ".png") :alt image}]]]))
(defn genders-row
diff --git a/src/cljs/youyesyet/canvasser_app/views/elector.cljs b/src/cljs/youyesyet/canvasser_app/views/elector.cljs
index 89d132c..119ac44 100644
--- a/src/cljs/youyesyet/canvasser_app/views/elector.cljs
+++ b/src/cljs/youyesyet/canvasser_app/views/elector.cljs
@@ -70,7 +70,7 @@
[elector]
[:tr
[:td {:key (:id elector)}
- [:a {:href (str "#/issues/" (:id elector))}
+ [:a {:href (str "#issues/" (:id elector))}
[:img {:src "img/issues.png" :alt "Issues"}]]]])
diff --git a/src/cljs/youyesyet/canvasser_app/views/issue.cljs b/src/cljs/youyesyet/canvasser_app/views/issue.cljs
index 46b16b2..579c249 100644
--- a/src/cljs/youyesyet/canvasser_app/views/issue.cljs
+++ b/src/cljs/youyesyet/canvasser_app/views/issue.cljs
@@ -38,14 +38,13 @@
(defn panel
"Generate the issue panel."
[]
- (let [issue @(subscribe [:issue])
- issues @(subscribe [:issues])]
+ (let [issue @(subscribe [:issue])]
[:div
- [:h1 issue]
+ [:h1 (:id issue)]
[:div.container {:id "main-container"}
[:div {:id "issue"}
[:div {:id "issue-text"
:dangerouslySetInnerHTML
- {:__html (md->html (issues issue))}}]]
+ {:__html (md->html (:brief issue))}}]]
(ui/big-link "Request call" :target "#/followup")
(ui/back-link)]]))
diff --git a/src/cljs/youyesyet/canvasser_app/views/issues.cljs b/src/cljs/youyesyet/canvasser_app/views/issues.cljs
index 9253a75..6515ab5 100644
--- a/src/cljs/youyesyet/canvasser_app/views/issues.cljs
+++ b/src/cljs/youyesyet/canvasser_app/views/issues.cljs
@@ -46,5 +46,5 @@
[:div.container {:id "main-container"}
(ui/back-link)
[:div {:id "issue-list"}
- (map (fn [k] (ui/big-link k :target (str "#/issue/" k))) (keys issues))]]]
+ (map (fn [i] (ui/big-link (:id i) :target (str "#issue/" (:id i)))) issues)]]]
(ui/error-panel "No issues loaded"))))
diff --git a/src/cljs/youyesyet/canvasser_app/views/map.cljs b/src/cljs/youyesyet/canvasser_app/views/map.cljs
index e7a6c24..97b0c44 100644
--- a/src/cljs/youyesyet/canvasser_app/views/map.cljs
+++ b/src/cljs/youyesyet/canvasser_app/views/map.cljs
@@ -1,9 +1,9 @@
(ns ^{:doc "Canvasser app map view panel."
:author "Simon Brooke"}
youyesyet.canvasser-app.views.map
- (:require [re-frame.core :refer [reg-sub subscribe dispatch]]
+ (:require [re-frame.core :refer [reg-sub subscribe dispatch dispatch-sync]]
[reagent.core :as reagent]
- [youyesyet.canvasser-app.handlers :refer [get-current-location]]))
+ [youyesyet.canvasser-app.handlers :refer [get-current-location refresh-map-pins]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
@@ -54,66 +54,6 @@
(def osm-url "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
(def osm-attrib "Map data © OpenStreetMap contributors")
-
-(defn pin-image
- "select the name of a suitable pin image for this address"
- [address]
- (let [intentions
- (set
- (remove
- nil?
- (map
- :intention
- (mapcat :electors
- (:dwellings address)))))]
- (case (count intentions)
- 0 "unknown-pin"
- 1 (str (name (first intentions)) "-pin")
- "mixed-pin")))
-
-
-(defn map-pin-click-handler
- "On clicking on the pin, navigate to the electors at the address.
- This way of doing it adds an antry in the browser location history,
- so back links work."
- [id]
- (js/console.log (str "Click handler for address #" id))
- (let [view @(subscribe [:view])
- centre (.getCenter view)]
- (dispatch [:set-zoom (.getZoom view)])
- (dispatch [:set-latitude (.-lat centre)])
- (dispatch [:set-longitude (.-lng centre)]))
- (set! window.location.href (str "#building/" id)))
-;; This way is probably more idiomatic React, but history doesn't work:
-;; (defn map-pin-click-handler
-;; [id]
-;; (dispatch [:set-address id]))
-
-
-(defn add-map-pin
- "Add a map-pin at this address in this map view"
- [address view]
- (let [lat (:latitude address)
- lng (:longitude address)
- pin (.icon js/L
- (clj->js
- {:iconAnchor [16 41]
- :iconSize [32 42]
- :iconUrl (str "img/map-pins/" (pin-image address) ".png")
- :riseOnHover true
- :shadowAnchor [16 23]
- :shadowSize [57 24]
- :shadowUrl "img/map-pins/shadow_pin.png"}))
- marker (.marker js/L
- (.latLng js/L lat lng)
- (clj->js {:icon pin
- :title (:address address)}))
- ]
-
- (.on (.addTo marker view) "click" (fn [_] (map-pin-click-handler (str (:id address)))))
- ))
-
-
;; My gods mapbox is user-hostile!
(defn map-did-mount-mapbox
"Did-mount function loading map tile data from MapBox (proprietary)."
@@ -123,8 +63,8 @@
;; NEED TO REPLACE FIXME with your mapID!
(.addTo (.tileLayer js/L "http://{s}.tiles.mapbox.com/v3/FIXME/{z}/{x}/{y}.png"
(clj->js {:attribution "Map data © [...]"
- :maxZoom 18}))
- view)))
+ :maxZoom 18})))
+ view))
(defn map-did-mount-osm
@@ -132,28 +72,24 @@
[]
(get-current-location)
(let [view (.setView
- (.map js/L "map" (clj->js {:zoomControl false}))
+ (.map js/L
+ "map"
+ (clj->js {:zoomControl false}))
#js [@(subscribe [:latitude]) @(subscribe [:longitude])]
- @(subscribe [:zoom]))
- addresses @(subscribe [:addresses])]
- (js/console.log (str "Adding " (count addresses) " pins"))
- (doall (map #(add-map-pin % view) addresses))
- (.addTo (.tileLayer js/L osm-url
- (clj->js {:attribution osm-attrib
- :maxZoom 18}))
- view)
- (dispatch [:set-view view])
+ @(subscribe [:zoom]))]
+ (dispatch-sync [:set-view view])
+ (refresh-map-pins)
view))
(defn map-did-mount
"Select the actual map provider to use."
[]
- (case *map-provider*
- :mapbox (map-did-mount-mapbox)
- :osm (map-did-mount-osm))
- ;; potentially others
- )
+ (dispatch-sync [:set-view (case *map-provider*
+ :mapbox (map-did-mount-mapbox)
+ :osm (map-did-mount-osm)
+ ;; potentially others
+ )]))
(defn map-render
diff --git a/youyesyet.canonical.adl.xml b/youyesyet.canonical.adl.xml
index 60c7984..1a4dad5 100644
--- a/youyesyet.canonical.adl.xml
+++ b/youyesyet.canonical.adl.xml
@@ -290,8 +290,11 @@
-
-
+
+
+
+
+