Progress on #2, #5; oauth isn't working but not far off

Using the Noir session doesn't seem to be the right thing to do. I should be using the Ring session, but I'm having a hard time getting my head round it. @yogthos is too bloody clever!
This commit is contained in:
Simon Brooke 2018-06-29 17:14:55 +01:00
parent 88468461fd
commit 4e296537c4
52 changed files with 465 additions and 114 deletions

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------
-- File queries.sql
--
-- autogenerated by adl.to-hugsql-queries at 2018-06-29T10:10:58.177Z
-- autogenerated by adl.to-hugsql-queries at 2018-06-29T14:15:37.324Z
--
-- See [Application Description
-- Language](https://github.com/simon-brooke/adl).
@ -27,8 +27,18 @@ returning id
-- :name create-authority! :! :n
-- :doc creates a new authority record
INSERT INTO authorities (id)
VALUES (:id)
INSERT INTO authorities (request_token_uri,
access_token_uri,
authorize_uri,
consumer_key,
consumer_secret,
id)
VALUES (:request_token_uri,
:access_token_uri,
:authorize_uri,
:consumer_key,
:consumer_secret,
:id)
returning id
-- :name create-canvasser! :! :n
@ -121,10 +131,12 @@ returning id
-- :doc creates a new intention record
INSERT INTO intentions (visit_id,
elector_id,
option_id)
option_id,
locality)
VALUES (:visit_id,
:elector_id,
:option_id)
:option_id,
:locality)
returning Id
-- :name create-issue! :! :n
@ -747,6 +759,11 @@ ORDER BY lv_addresses.address,
-- :doc selects existing authority records having any string field matching the parameter of the same name by substring match
SELECT * FROM lv_authorities
WHERE false
--~ (if (:request-token-uri params) "OR request_token_uri LIKE '%:request-token-uri%'")
--~ (if (:access-token-uri params) "OR access_token_uri LIKE '%:access-token-uri%'")
--~ (if (:authorize-uri params) "OR authorize_uri LIKE '%:authorize-uri%'")
--~ (if (:consumer-key params) "OR consumer_key LIKE '%:consumer-key%'")
--~ (if (:consumer-secret params) "OR consumer_secret LIKE '%:consumer-secret%'")
--~ (if (:id params) "OR id LIKE '%:id%'")
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -868,6 +885,7 @@ WHERE false
--~ (if (:visit_id params) "OR visit_id = :visit_id")
--~ (if (:elector_id params) "OR elector_id = :elector_id")
--~ (if (:option_id params) "OR option_id = :option_id")
--~ (if (:locality params) "OR locality = :locality")
--~ (if (:Id params) "OR Id = :Id")
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -941,6 +959,17 @@ SET address = :address,
locality = :locality
WHERE addresses.id = :id
-- :name update-authority! :! :n
-- :doc updates an existing authority record
UPDATE authorities
SET request_token_uri = :request-token-uri,
access_token_uri = :access-token-uri,
authorize_uri = :authorize-uri,
consumer_key = :consumer-key,
consumer_secret = :consumer-secret,
id = :id
WHERE authorities.id = :id
-- :name update-canvasser! :! :n
-- :doc updates an existing canvasser record
UPDATE canvassers
@ -1001,7 +1030,8 @@ WHERE followuprequests.id = :id
UPDATE intentions
SET visit_id = :visit_id,
elector_id = :elector_id,
option_id = :option_id
option_id = :option_id,
locality = :locality
WHERE intentions.Id = :Id
-- :name update-issue! :! :n

View file

@ -5,7 +5,7 @@
--
-- auto-generated by [Application Description Language framework]
--
-- (https://github.com/simon-brooke/adl) at 20180629T101059.126Z
-- (https://github.com/simon-brooke/adl) at 20180629T141538.194Z
--
--
-- A web-app intended to be used by canvassers campaigning for a
@ -99,7 +99,12 @@ GRANT DELETE ON addresses TO admin ;
------------------------------------------------------------------------
CREATE TABLE authorities
(
id VARCHAR(32) NOT NULL PRIMARY KEY
id VARCHAR(32) NOT NULL PRIMARY KEY,
request_token_uri VARCHAR(256) NOT NULL,
access_token_uri VARCHAR(256) NOT NULL,
authorize_uri VARCHAR(256) NOT NULL,
consumer_key VARCHAR(32) DEFAULT 'youyesyet' NOT NULL,
consumer_secret VARCHAR(256) NOT NULL
);
GRANT SELECT ON authorities TO admin,
analysts,
@ -167,8 +172,15 @@ GRANT DELETE ON districts TO admin ;
------------------------------------------------------------------------
-- primary table dwellings for entity dwellings
--
-- All dwellings within addresses in the system; a dwelling is a house,
-- flat or appartment in which electors live.
-- All dwellings within addresses in the system; a dwelling is a
-- house, flat or appartment in which electors live. Every address
-- should have
-- at least one dwelling; essentially, an address maps onto a
-- street door and
-- dwellings map onto what's behind that door. So a tenement or a
-- block of flats
-- would be one address with many dwellings.
--
------------------------------------------------------------------------
CREATE TABLE dwellings
(
@ -298,14 +310,15 @@ GRANT DELETE ON genders TO admin ;
------------------------------------------------------------------------
-- primary table intentions for entity intentions
--
-- Link table.
-- Intentions of electors to vote for options elicited in visits.
------------------------------------------------------------------------
CREATE TABLE intentions
(
Id SERIAL NOT NULL PRIMARY KEY,
visit_id INTEGER NOT NULL,
elector_id INTEGER NOT NULL,
option_id VARCHAR(32) NOT NULL
elector_id INTEGER,
option_id VARCHAR(32) NOT NULL,
locality INTEGER NOT NULL
);
GRANT SELECT ON intentions TO admin,
analysts,
@ -455,7 +468,12 @@ GRANT SELECT ON lv_addresses TO admin,
-- cetera
------------------------------------------------------------------------
CREATE VIEW lv_authorities AS
SELECT authorities.id
SELECT authorities.request_token_uri,
authorities.access_token_uri,
authorities.authorize_uri,
authorities.consumer_key,
authorities.consumer_secret,
authorities.id
FROM authorities
;
GRANT SELECT ON lv_authorities TO admin,
@ -641,6 +659,7 @@ SELECT addresses.address ||', '|| addresses.postcode ||', '|| visits.date AS vis
intentions.elector_id,
options.id AS option_id_expanded,
intentions.option_id,
intentions.locality,
intentions.Id
FROM visits, intentions, addresses, genders, electors, options
WHERE intentions.visit_id = visits.id