Tactical commit; much progress but not ready for release.

This commit is contained in:
Simon Brooke 2018-07-07 10:21:09 +01:00
parent fc2bd86cff
commit 0026218993
61 changed files with 2920 additions and 1031 deletions

3
.gitignore vendored
View file

@ -23,5 +23,8 @@ pom.xml.asc
profiles\.clj
.bowerrc
bower.json
.idea
src/clj/youyesyet/scratchpad\.clj
*.iml

View file

@ -3,4 +3,5 @@
;; when :nrepl-port is set the application starts the nREPL server on load
:nrepl-port 7000
:site-title "Project Hope"
:site-logo "img/ProjectHopeLogo.png"}
:site-logo "img/ProjectHopeLogo.png"
:motd "motd.md"}

9
resources/motd.md Normal file
View file

@ -0,0 +1,9 @@
## Welcome to Project Hope
### Alpha test code
This is a voter intention information system intended to be used by the 'Yes' side in the next Scottish independence referendum.
Design documentation is [here](https://github.com/simon-brooke/youyesyet/blob/master/doc/specification/userspec.md).
Although addresses in the database mostly are real, all personal data in the database is randomly generated and does not represent real people.

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------
-- File queries.sql
--
-- autogenerated by adl.to-hugsql-queries at 2018-07-05T10:14:16.954Z
-- autogenerated by adl.to-hugsql-queries at 2018-07-07T08:09:48.253Z
--
-- See [Application Description
-- Language](https://github.com/simon-brooke/adl).
@ -45,6 +45,8 @@ returning id
-- :doc creates a new canvasser record
INSERT INTO canvassers (username,
fullname,
avatar,
bio,
elector_id,
address_id,
phone,
@ -53,6 +55,8 @@ INSERT INTO canvassers (username,
authorised)
VALUES (:username,
:fullname,
:avatar,
:bio,
:elector_id,
:address_id,
:phone,
@ -89,6 +93,20 @@ VALUES (:name,
:gender)
returning id
-- :name create-event! :! :n
-- :doc creates a new event record
INSERT INTO events (name,
date,
time,
decription,
cancelled)
VALUES (:name,
:date,
:time,
:decription,
:cancelled)
returning id
-- :name create-followupaction! :! :n
-- :doc creates a new followupaction record
INSERT INTO followupactions (request_id,
@ -137,7 +155,7 @@ VALUES (:visit_id,
:elector_id,
:option_id,
:locality)
returning Id
returning id
-- :name create-issue! :! :n
-- :doc creates a new issue record
@ -215,6 +233,11 @@ WHERE dwellings.id = :id
DELETE FROM electors
WHERE electors.id = :id
-- :name delete-event! :! :n
-- :doc updates an existing event record
DELETE FROM events
WHERE events.id = :id
-- :name delete-followupaction! :! :n
-- :doc updates an existing followupaction record
DELETE FROM followupactions
@ -238,7 +261,7 @@ WHERE genders.id = :id
-- :name delete-intention! :! :n
-- :doc updates an existing intention record
DELETE FROM intentions
WHERE intentions.Id = :Id
WHERE intentions.id = :id
-- :name delete-issue! :! :n
-- :doc updates an existing issue record
@ -325,6 +348,15 @@ ORDER BY electors.name,
electors.gender,
electors.id
-- :name get-event :? :1
-- :doc selects an existing event record
SELECT * FROM events
WHERE events.id = :id
ORDER BY events.name,
events.date,
events.time,
events.id
-- :name get-followupaction :? :1
-- :doc selects an existing followupaction record
SELECT * FROM followupactions
@ -355,7 +387,7 @@ WHERE genders.id = :id
-- :name get-intention :? :1
-- :doc selects an existing intention record
SELECT * FROM intentions
WHERE intentions.Id = :Id
WHERE intentions.id = :id
-- :name get-issue :? :1
-- :doc selects an existing issue record
@ -475,9 +507,9 @@ ORDER BY lv_canvassers.username,
-- :name list-canvassers-by-role :? :*
-- :doc links all existing canvasser records related to a given role
SELECT *
FROM canvassers, ln_canvassers_roles
WHERE canvassers.id = ln_canvassers_roles.canvasser_id
AND ln_canvassers_roles.role_id = :id
FROM canvassers, ln_roles_canvassers_roles
WHERE canvassers.id = ln_roles_canvassers_roles.canvasser_id
AND ln_roles_canvassers_roles.role_id = :id
ORDER BY canvassers.username,
canvassers.fullname,
canvassers.address_id,
@ -547,6 +579,27 @@ ORDER BY lv_electors.name,
lv_electors.gender,
lv_electors.id
-- :name list-events :? :*
-- :doc lists all existing event records
SELECT DISTINCT * FROM lv_events
ORDER BY lv_events.name,
lv_events.date,
lv_events.time,
lv_events.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name list-events-by-team :? :*
-- :doc links all existing event records related to a given team
SELECT *
FROM events, ln_teams_events_teams
WHERE events.id = ln_teams_events_teams.event_id
AND ln_teams_events_teams.team_id = :id
ORDER BY events.name,
events.date,
events.time,
events.id
-- :name list-followupactions :? :*
-- :doc lists all existing followupaction records
SELECT DISTINCT * FROM lv_followupactions
@ -652,21 +705,21 @@ SELECT DISTINCT * FROM lv_intentions
-- :doc lists all existing intention records related to a given elector
SELECT *
FROM lv_intentions, intentions
WHERE lv_intentions.Id = intentions.Id
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 *
FROM lv_intentions, intentions
WHERE lv_intentions.Id = intentions.Id
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 *
FROM lv_intentions, intentions
WHERE lv_intentions.Id = intentions.Id
WHERE lv_intentions.id = intentions.id
AND intentions.visit_id = :id
-- :name list-issues :? :*
@ -692,9 +745,9 @@ ORDER BY lv_roles.name,
-- :name list-roles-by-canvasser :? :*
-- :doc links all existing role records related to a given canvasser
SELECT *
FROM roles, ln_canvassers_roles
WHERE roles.id = ln_canvassers_roles.role_id
AND ln_canvassers_roles.canvasser_id = :id
FROM roles, ln_members_roles_canvassers
WHERE roles.id = ln_members_roles_canvassers.role_id
AND ln_members_roles_canvassers.canvasser_id = :id
ORDER BY roles.name,
roles.id
@ -709,9 +762,9 @@ ORDER BY lv_teams.name,
-- :name list-teams-by-canvasser :? :*
-- :doc links all existing team records related to a given canvasser
SELECT *
FROM teams, ln_canvassers_teams
WHERE teams.id = ln_canvassers_teams.team_id
AND ln_canvassers_teams.canvasser_id = :id
FROM teams, ln_organisers_teams_canvassers
WHERE teams.id = ln_organisers_teams_canvassers.team_id
AND ln_organisers_teams_canvassers.canvasser_id = :id
ORDER BY teams.name,
teams.id
@ -790,6 +843,8 @@ SELECT DISTINCT * FROM lv_canvassers
WHERE false
--~ (if (:username params) "OR username LIKE '%:username%'")
--~ (if (:fullname params) "OR fullname LIKE '%:fullname%'")
--~ (if (:avatar params) "OR avatar = :avatar")
--~ (if (:bio params) "OR bio LIKE '%:bio%'")
--~ (if (:elector_id params) "OR elector_id = :elector_id")
--~ (if (:address_id params) "OR address_id = :address_id")
--~ (if (:phone params) "OR phone LIKE '%:phone%'")
@ -848,6 +903,23 @@ ORDER BY lv_electors.name,
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-events :? :1
-- :doc selects existing event records having any string field matching the parameter of the same name by substring match
SELECT DISTINCT * FROM lv_events
WHERE false
--~ (if (:name params) "OR name LIKE '%:name%'")
--~ (if (:date params) "OR date = ':date'")
--~ (if (:time params) "OR time = ':time'")
--~ (if (:decription params) "OR decription LIKE '%:decription%'")
--~ (if (:cancelled params) "OR cancelled = :cancelled")
--~ (if (:id params) "OR id = :id")
ORDER BY lv_events.name,
lv_events.date,
lv_events.time,
lv_events.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-followupactions :? :1
-- :doc selects existing followupaction records having any string field matching the parameter of the same name by substring match
SELECT DISTINCT * FROM lv_followupactions
@ -904,7 +976,7 @@ WHERE false
--~ (if (:elector_id params) "OR elector_id = :elector_id")
--~ (if (:option_id params) "OR option_id LIKE '%:option_id%'")
--~ (if (:locality params) "OR locality = :locality")
--~ (if (:Id params) "OR Id = :Id")
--~ (if (:id params) "OR id = :id")
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -994,6 +1066,8 @@ WHERE authorities.id = :id
UPDATE canvassers
SET username = :username,
fullname = :fullname,
avatar = :avatar,
bio = :bio,
elector_id = :elector_id,
address_id = :address_id,
phone = :phone,
@ -1025,6 +1099,16 @@ SET name = :name,
gender = :gender
WHERE electors.id = :id
-- :name update-event! :! :n
-- :doc updates an existing event record
UPDATE events
SET name = :name,
date = :date,
time = :time,
decription = :decription,
cancelled = :cancelled
WHERE events.id = :id
-- :name update-followupaction! :! :n
-- :doc updates an existing followupaction record
UPDATE followupactions
@ -1063,7 +1147,7 @@ SET visit_id = :visit_id,
elector_id = :elector_id,
option_id = :option_id,
locality = :locality
WHERE intentions.Id = :Id
WHERE intentions.id = :id
-- :name update-issue! :! :n
-- :doc updates an existing issue record

View file

@ -0,0 +1,65 @@
insert into canvassers (username, fullname, elector_id, address_id, authority_id)
values ('test_admin', 'Michael Thomson', 14, 4, 'Twitter');
insert into canvassers (username, fullname, elector_id, address_id, authority_id)
values ('test_analyst', 'Jack Lang', 13, 4, 'Twitter');
insert into canvassers (username, fullname, elector_id, address_id, authority_id)
values ('test_canvasser', 'Catriona Lang', 12, 4, 'Twitter');
insert into canvassers (username, fullname, elector_id, address_id, authority_id)
values ('test_editor', 'Ursula Lang', 11, 4, 'Twitter');
insert into canvassers (username, fullname, elector_id, address_id, authority_id)
values ('test_expert', 'Charlie Gourlay', 18, 5, 'Twitter');
insert into canvassers (username, fullname, elector_id, address_id, authority_id)
values ('test_organiser', 'Jude Morrison', 15, 5, 'Twitter');
insert into ln_members_roles_canvassers
values (1, (select id from canvassers where username='test_admin'));
insert into ln_members_roles_canvassers
values (2, (select id from canvassers where username='test_analyst'));
insert into ln_members_roles_canvassers
values (3, (select id from canvassers where username='test_editor'));
insert into ln_members_roles_canvassers
values (4, (select id from canvassers where username='test_organiser'));
insert into ln_members_roles_canvassers
values (5, (select id from canvassers where username='test_expert'));
insert into ln_members_roles_canvassers
values (6, (select id from canvassers where username='test_canvasser'));
insert into teams (name, district_id, latitude, longitude)
values ('Yes Stewartry', 1, 54.94, -3.94);
insert into ln_members_teams_canvassers
values (
(select id from teams where name='Yes Stewartry'),
(select id from canvassers where username='test_admin'));
insert into ln_members_teams_canvassers
values (
(select id from teams where name='Yes Stewartry'),
(select id from canvassers where username='test_analyst'));
insert into ln_members_teams_canvassers
values (
(select id from teams where name='Yes Stewartry'),
(select id from canvassers where username='test_editor'));
insert into ln_members_teams_canvassers
values (
(select id from teams where name='Yes Stewartry'),
(select id from canvassers where username='test_organiser'));
insert into ln_members_teams_canvassers
values (
(select id from teams where name='Yes Stewartry'),
(select id from canvassers where username='test_expert'));
insert into ln_members_teams_canvassers
values (
(select id from teams where name='Yes Stewartry'),
(select id from canvassers where username='test_canvasser'));

View file

@ -5,23 +5,19 @@
--
-- auto-generated by [Application Description Language framework]
--
-- (https://github.com/simon-brooke/adl) at 20180705T101417.868Z
--
--
-- A web-app intended to be used by canvassers campaigning for a
-- 'Yes' vote in the second independence referendum.
--
-- The web-app will be delivered to canvassers out knocking doors
-- primarily through an HTML5/React single-page app designed to work on a
-- mobile phone; it's possible that someone else may do an Android of
-- iPhone native app to address the same back end but at present I have
-- no plans for this.
--
-- There must also be an administrative interface through which
-- privileged users can set the system up and authorise canvassers, and a
-- 'followup' interface through which issue-expert specialist canvassers
-- can address particular electors' queries.
-- (https://github.com/simon-brooke/adl) at 20180707T080949.294Z
--
-- A web-app intended to be used by canvassers
-- campaigning for a 'Yes' vote in the second independence
-- referendum. The web-app will be delivered to canvassers out
-- knocking doors primarily through an HTML5/React single-page app
-- designed to work on a mobile phone; it's possible that someone
-- else may do an Android of iPhone native app to address the same
-- back end but at present I have no plans for this. There must also
-- be an administrative interface through which privileged users can
-- set the system up and authorise canvassers, and a 'followup'
-- interface through which issue-expert specialist canvassers can
-- address particular electors' queries.
------------------------------------------------------------------------
------------------------------------------------------------------------
@ -69,7 +65,8 @@ CREATE GROUP teamorganisers;
------------------------------------------------------------------------
-- primary table addresses for entity addresses
--
-- Addresses of all buildings which contain dwellings.
-- Addresses of all buildings which contain
-- dwellings.
------------------------------------------------------------------------
CREATE TABLE addresses
(
@ -95,7 +92,8 @@ GRANT DELETE ON addresses TO admin ;
------------------------------------------------------------------------
-- primary table authorities for entity authorities
--
-- Authorities which may authenticate canvassers to the system.
-- Authorities which may authenticate canvassers to
-- the system.
------------------------------------------------------------------------
CREATE TABLE authorities
(
@ -119,13 +117,16 @@ GRANT DELETE ON authorities TO admin ;
------------------------------------------------------------------------
-- primary table canvassers for entity canvassers
--
-- Primary users of the system: those actually interviewing electors.
-- Primary users of the system: those actually
-- interviewing electors.
------------------------------------------------------------------------
CREATE TABLE canvassers
(
id SERIAL NOT NULL PRIMARY KEY,
username VARCHAR(32) NOT NULL,
fullname VARCHAR(64) NOT NULL,
avatar VARCHAR(),
bio TEXT,
elector_id INTEGER,
address_id INTEGER NOT NULL,
phone VARCHAR(16),
@ -150,8 +151,9 @@ GRANT DELETE ON canvassers TO admin ;
------------------------------------------------------------------------
-- primary table districts for entity districts
--
-- Electoral districts: TODO: Shape (polygon) information will need to be
-- added, for use in maps.
-- Electoral districts: TODO: Shape (polygon)
-- information will need to be added, for use in
-- maps.
------------------------------------------------------------------------
CREATE TABLE districts
(
@ -172,15 +174,12 @@ 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. 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.
--
-- 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
(
@ -201,8 +200,9 @@ GRANT DELETE ON dwellings TO admin ;
------------------------------------------------------------------------
-- primary table electors for entity electors
--
-- All electors known to the system; electors are people believed to be
-- entitled to vote in the current campaign.
-- All electors known to the system; electors are
-- people believed to be entitled to vote in the current
-- campaign.
------------------------------------------------------------------------
CREATE TABLE electors
(
@ -223,10 +223,42 @@ GRANT INSERT ON electors TO admin ;
GRANT UPDATE ON electors TO admin ;
GRANT DELETE ON electors TO admin ;
------------------------------------------------------------------------
-- primary table events for entity events
--
--
-- An event to which a team or teams are invited. Typically created
-- by the team organiser(s).
-- May be a training event, a social event or a canvassing
-- session.
--
------------------------------------------------------------------------
CREATE TABLE events
(
id SERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
date DATE,
time TIME,
decription TEXT,
cancelled BOOLEAN DEFAULT false
);
GRANT SELECT ON events TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
GRANT INSERT ON events TO admin,
teamorganisers ;
GRANT UPDATE ON events TO admin,
teamorganisers ;
GRANT DELETE ON events TO admin ;
------------------------------------------------------------------------
-- primary table followupactions for entity followupactions
--
-- Actions taken on followup requests.
-- Actions taken on followup
-- requests.
------------------------------------------------------------------------
CREATE TABLE followupactions
(
@ -267,7 +299,8 @@ GRANT DELETE ON followupmethods TO admin ;
------------------------------------------------------------------------
-- primary table followuprequests for entity followuprequests
--
-- Requests for a followup with an issue expert
-- Requests for a followup with an issue
-- expert
------------------------------------------------------------------------
CREATE TABLE followuprequests
(
@ -291,7 +324,8 @@ GRANT DELETE ON followuprequests TO admin ;
------------------------------------------------------------------------
-- primary table genders for entity genders
--
-- All genders which may be assigned to electors.
-- All genders which may be assigned to
-- electors.
------------------------------------------------------------------------
CREATE TABLE genders
(
@ -310,11 +344,12 @@ GRANT DELETE ON genders TO admin ;
------------------------------------------------------------------------
-- primary table intentions for entity intentions
--
-- Intentions of electors to vote for options elicited in visits.
-- Intentions of electors to vote for options
-- elicited in visits.
------------------------------------------------------------------------
CREATE TABLE intentions
(
Id SERIAL NOT NULL PRIMARY KEY,
id SERIAL NOT NULL PRIMARY KEY,
visit_id INTEGER NOT NULL,
elector_id INTEGER,
option_id VARCHAR(32) NOT NULL,
@ -331,8 +366,8 @@ GRANT DELETE ON intentions TO admin ;
------------------------------------------------------------------------
-- primary table issues for entity issues
--
-- Issues believed to be of interest to electors, about which they may
-- have questions.
-- Issues believed to be of interest to electors,
-- about which they may have questions.
------------------------------------------------------------------------
CREATE TABLE issues
(
@ -356,7 +391,8 @@ GRANT DELETE ON issues TO admin ;
------------------------------------------------------------------------
-- primary table options for entity options
--
-- Options in the election or referendum being canvassed on
-- Options in the election or referendum being
-- canvassed on
------------------------------------------------------------------------
CREATE TABLE options
(
@ -375,8 +411,9 @@ GRANT DELETE ON options TO admin ;
------------------------------------------------------------------------
-- primary table roles for entity roles
--
-- A role (essentially, the same as a group, but application layer rather
-- than database layer) of which a user may be a member.
-- A role (essentially, the same as a group, but
-- application layer rather than database layer) of which a user
-- may be a member.
------------------------------------------------------------------------
CREATE TABLE roles
(
@ -419,8 +456,8 @@ GRANT DELETE ON teams TO admin ;
------------------------------------------------------------------------
-- primary table visits for entity visits
--
-- All visits made by canvassers to dwellings in which opinions were
-- recorded.
-- All visits made by canvassers to dwellings in
-- which opinions were recorded.
------------------------------------------------------------------------
CREATE TABLE visits
(
@ -491,6 +528,8 @@ GRANT SELECT ON lv_authorities TO admin,
CREATE VIEW lv_canvassers AS
SELECT canvassers.username,
canvassers.fullname,
canvassers.avatar,
canvassers.bio,
electors.name ||', '|| electors.phone ||', '|| electors.email ||', '|| genders.id AS elector_id_expanded,
canvassers.elector_id,
addresses.address ||', '|| addresses.postcode AS address_id_expanded,
@ -570,6 +609,25 @@ GRANT SELECT ON lv_electors TO admin,
issueexperts,
teamorganisers ;
------------------------------------------------------------------------
-- convenience view lv_events of entity events for lists, et cetera
------------------------------------------------------------------------
CREATE VIEW lv_events AS
SELECT events.name,
events.date,
events.time,
events.decription,
events.cancelled,
events.id
FROM events
;
GRANT SELECT ON lv_events TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
------------------------------------------------------------------------
-- convenience view lv_followupactions of entity followupactions for
-- lists, et cetera
@ -661,7 +719,7 @@ SELECT addresses.address ||', '|| addresses.postcode ||', '|| visits.date AS vis
options.id AS option_id_expanded,
intentions.option_id,
intentions.locality,
intentions.Id
intentions.id
FROM visits, intentions, addresses, genders, electors, options
WHERE intentions.visit_id = visits.id
AND intentions.elector_id = electors.id
@ -860,64 +918,149 @@ ALTER TABLE visits ADD CONSTRAINT ri_visits_canvassers_canvasser_id
------------------------------------------------------------------------
-- link table joining canvassers with roles
------------------------------------------------------------------------
CREATE TABLE ln_canvassers_roles
CREATE TABLE ln_roles_canvassers_roles
(
canvasser_id INTEGER,
role_id INTEGER
);
GRANT SELECT ON ln_canvassers_roles TO admin,
GRANT SELECT ON ln_roles_canvassers_roles TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
GRANT INSERT ON ln_canvassers_roles TO admin,
GRANT INSERT ON ln_roles_canvassers_roles TO admin,
canvassers,
teamorganisers ;
GRANT UPDATE ON ln_canvassers_roles TO admin,
GRANT UPDATE ON ln_roles_canvassers_roles TO admin,
canvassers,
teamorganisers ;
GRANT DELETE ON ln_canvassers_roles TO admin ;
GRANT DELETE ON ln_roles_canvassers_roles TO admin ;
ALTER TABLE ln_canvassers_roles ADD CONSTRAINT ri_ln_canvassers_roles_canvassers_canvasser_id
ALTER TABLE ln_roles_canvassers_roles ADD CONSTRAINT ri_ln_roles_canvassers_roles_canvassers_canvasser_id
FOREIGN KEY( canvasser_id )
REFERENCES canvassers(id)
ON DELETE NO ACTION ;
ALTER TABLE ln_canvassers_roles ADD CONSTRAINT ri_ln_canvassers_roles_roles_role_id
ALTER TABLE ln_roles_canvassers_roles ADD CONSTRAINT ri_ln_roles_canvassers_roles_roles_role_id
FOREIGN KEY( role_id )
REFERENCES roles(id)
ON DELETE NO ACTION ;
------------------------------------------------------------------------
-- link table joining teams with canvassers
-- link table joining events with teams
------------------------------------------------------------------------
CREATE TABLE ln_canvassers_teams
CREATE TABLE ln_teams_events_teams
(
team_id INTEGER,
canvasser_id INTEGER
event_id INTEGER,
team_id INTEGER
);
GRANT SELECT ON ln_canvassers_teams TO admin,
GRANT SELECT ON ln_teams_events_teams TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
GRANT INSERT ON ln_canvassers_teams TO admin,
GRANT INSERT ON ln_teams_events_teams TO admin,
teamorganisers ;
GRANT UPDATE ON ln_canvassers_teams TO admin,
GRANT UPDATE ON ln_teams_events_teams TO admin,
teamorganisers ;
GRANT DELETE ON ln_canvassers_teams TO admin ;
GRANT DELETE ON ln_teams_events_teams TO admin ;
ALTER TABLE ln_canvassers_teams ADD CONSTRAINT ri_ln_canvassers_teams_canvassers_canvasser_id
FOREIGN KEY( canvasser_id )
REFERENCES canvassers(id)
ALTER TABLE ln_teams_events_teams ADD CONSTRAINT ri_ln_teams_events_teams_events_event_id
FOREIGN KEY( event_id )
REFERENCES events(id)
ON DELETE NO ACTION ;
ALTER TABLE ln_canvassers_teams ADD CONSTRAINT ri_ln_canvassers_teams_teams_team_id
ALTER TABLE ln_teams_events_teams ADD CONSTRAINT ri_ln_teams_events_teams_teams_team_id
FOREIGN KEY( team_id )
REFERENCES teams(id)
ON DELETE NO ACTION ;
------------------------------------------------------------------------
-- link table joining roles with canvassers
------------------------------------------------------------------------
CREATE TABLE ln_members_roles_canvassers
(
role_id INTEGER,
canvasser_id INTEGER
);
GRANT SELECT ON ln_members_roles_canvassers TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
GRANT INSERT ON ln_members_roles_canvassers TO admin ;
GRANT UPDATE ON ln_members_roles_canvassers TO admin ;
GRANT DELETE ON ln_members_roles_canvassers TO admin ;
ALTER TABLE ln_members_roles_canvassers ADD CONSTRAINT ri_ln_members_roles_canvassers_canvassers_canvasser_id
FOREIGN KEY( canvasser_id )
REFERENCES canvassers(id)
ON DELETE NO ACTION ;
ALTER TABLE ln_members_roles_canvassers ADD CONSTRAINT ri_ln_members_roles_canvassers_roles_role_id
FOREIGN KEY( role_id )
REFERENCES roles(id)
ON DELETE NO ACTION ;
------------------------------------------------------------------------
-- link table joining teams with canvassers
------------------------------------------------------------------------
CREATE TABLE ln_members_teams_canvassers
(
team_id INTEGER,
canvasser_id INTEGER
);
GRANT SELECT ON ln_members_teams_canvassers TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
GRANT INSERT ON ln_members_teams_canvassers TO admin,
teamorganisers ;
GRANT UPDATE ON ln_members_teams_canvassers TO admin,
teamorganisers ;
GRANT DELETE ON ln_members_teams_canvassers TO admin ;
ALTER TABLE ln_members_teams_canvassers ADD CONSTRAINT ri_ln_members_teams_canvassers_canvassers_canvasser_id
FOREIGN KEY( canvasser_id )
REFERENCES canvassers(id)
ON DELETE NO ACTION ;
ALTER TABLE ln_members_teams_canvassers ADD CONSTRAINT ri_ln_members_teams_canvassers_teams_team_id
FOREIGN KEY( team_id )
REFERENCES teams(id)
ON DELETE NO ACTION ;
------------------------------------------------------------------------
-- link table joining teams with canvassers
------------------------------------------------------------------------
CREATE TABLE ln_organisers_teams_canvassers
(
team_id INTEGER,
canvasser_id INTEGER
);
GRANT SELECT ON ln_organisers_teams_canvassers TO admin,
analysts,
canvassers,
issueeditors,
issueexperts,
teamorganisers ;
GRANT INSERT ON ln_organisers_teams_canvassers TO admin,
teamorganisers ;
GRANT UPDATE ON ln_organisers_teams_canvassers TO admin,
teamorganisers ;
GRANT DELETE ON ln_organisers_teams_canvassers TO admin ;
ALTER TABLE ln_organisers_teams_canvassers ADD CONSTRAINT ri_ln_organisers_teams_canvassers_canvassers_canvasser_id
FOREIGN KEY( canvasser_id )
REFERENCES canvassers(id)
ON DELETE NO ACTION ;
ALTER TABLE ln_organisers_teams_canvassers ADD CONSTRAINT ri_ln_organisers_teams_canvassers_teams_team_id
FOREIGN KEY( team_id )
REFERENCES teams(id)
ON DELETE NO ACTION ;

View file

@ -2,12 +2,6 @@
{% block big-links %}
{% endblock %}
{% block content %}
<h2>
Alpha test code
</h2>
<p>
Although addresses in the database mostly are real, all personal data in the database
is randomly generated and does not represent real people.
</p>
{{motd|safe}}
{% endblock %}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File application-index.html generated 2018-07-05T10:14:18.460Z by adl.to-selmer-templates.
<!-- File application-index.html generated 2018-07-07T08:09:49.942Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -15,7 +15,8 @@ Address
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
Addresses of all buildings which contain dwellings.
Addresses of all buildings which contain
dwellings.
</p>
</dd>
{% endifmemberof %}
@ -29,7 +30,8 @@ Authority
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
Authorities which may authenticate canvassers to the system.
Authorities which may authenticate canvassers to
the system.
</p>
</dd>
{% endifmemberof %}
@ -43,7 +45,8 @@ Canvasser
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
Primary users of the system: those actually interviewing electors.
Primary users of the system: those actually
interviewing electors.
</p>
</dd>
{% endifmemberof %}
@ -57,7 +60,9 @@ District
{% ifmemberof public admin canvassers teamorganisers issueexperts analysts issueeditors %}
<dd>
<p>
Electoral districts: TODO: Shape (polygon) information will need to be added, for use in maps.
Electoral districts: TODO: Shape (polygon)
information will need to be added, for use in
maps.
</p>
</dd>
{% endifmemberof %}
@ -71,12 +76,12 @@ Dwelling
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
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.
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.
</p>
</dd>
{% endifmemberof %}
@ -90,7 +95,26 @@ Elector
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
All electors known to the system; electors are people believed to be entitled to vote in the current campaign.
All electors known to the system; electors are
people believed to be entitled to vote in the current
campaign.
</p>
</dd>
{% endifmemberof %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dt>
<a href='list-events-Events'>
Event
</a>
</dt>
{% endifmemberof %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
An event to which a team or teams are invited. Typically created by the team organiser(s).
May be a training event, a social event or a canvassing session.
</p>
</dd>
{% endifmemberof %}
@ -104,7 +128,8 @@ Followupaction
{% ifmemberof issueexperts canvassers analysts issueeditors admin %}
<dd>
<p>
Actions taken on followup requests.
Actions taken on followup
requests.
</p>
</dd>
{% endifmemberof %}
@ -129,7 +154,8 @@ Followuprequest
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
Requests for a followup with an issue expert
Requests for a followup with an issue
expert
</p>
</dd>
{% endifmemberof %}
@ -143,7 +169,8 @@ Gender
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
All genders which may be assigned to electors.
All genders which may be assigned to
electors.
</p>
</dd>
{% endifmemberof %}
@ -157,7 +184,8 @@ Intention
{% ifmemberof canvassers analysts admin %}
<dd>
<p>
Intentions of electors to vote for options elicited in visits.
Intentions of electors to vote for options
elicited in visits.
</p>
</dd>
{% endifmemberof %}
@ -171,7 +199,8 @@ Issue
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
Issues believed to be of interest to electors, about which they may have questions.
Issues believed to be of interest to electors,
about which they may have questions.
</p>
</dd>
{% endifmemberof %}
@ -185,7 +214,8 @@ Option
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
Options in the election or referendum being canvassed on
Options in the election or referendum being
canvassed on
</p>
</dd>
{% endifmemberof %}
@ -199,7 +229,9 @@ Role
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<dd>
<p>
A role (essentially, the same as a group, but application layer rather than database layer) of which a user may be a member.
A role (essentially, the same as a group, but
application layer rather than database layer) of which a user
may be a member.
</p>
</dd>
{% endifmemberof %}
@ -224,7 +256,8 @@ Visit
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin canvassers teamorganisers %}
<dd>
<p>
All visits made by canvassers to dwellings in which opinions were recorded.
All visits made by canvassers to dwellings in
which opinions were recorded.
</p>
</dd>
{% endifmemberof %}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-addresses-Address.html generated 2018-07-05T10:14:18.448Z by adl.to-selmer-templates.
<!-- File form-addresses-Address.html generated 2018-07-07T08:09:49.931Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of addresses
</p>
<p class='widget'>
<label for='address'>
address
Address
</label>
{% ifmemberof admin %}
<input id='address' name='address' type='string' value='{{record.address}}' maxlength='256' size='60'/>
@ -48,7 +48,7 @@ You are not permitted to view address of addresses
</p>
<p class='widget'>
<label for='postcode'>
postcode
Postcode
</label>
{% ifmemberof admin %}
<input id='postcode' name='postcode' type='string' value='{{record.postcode}}' maxlength='16' size='16'/>
@ -66,7 +66,7 @@ You are not permitted to view postcode of addresses
</p>
<p class='widget'>
<label for='phone'>
phone
Phone
</label>
{% ifmemberof admin %}
<input id='phone' name='phone' type='string' value='{{record.phone}}' maxlength='16' size='16'/>
@ -84,7 +84,7 @@ You are not permitted to view phone of addresses
</p>
<p class='widget'>
<label for='district_id'>
district_id
District_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='districts' found='true'>
@ -108,7 +108,7 @@ You are not permitted to view district_id of addresses
</p>
<p class='widget'>
<label for='latitude'>
latitude
Latitude
</label>
{% ifmemberof admin %}
<input id='latitude' name='latitude' type='number' value='{{record.latitude}}' maxlength='' size='16'/>
@ -126,7 +126,7 @@ You are not permitted to view latitude of addresses
</p>
<p class='widget'>
<label for='longitude'>
longitude
Longitude
</label>
{% ifmemberof admin %}
<input id='longitude' name='longitude' type='number' value='{{record.longitude}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-authorities-Authority.html generated 2018-07-05T10:14:18.468Z by adl.to-selmer-templates.
<!-- File form-authorities-Authority.html generated 2018-07-07T08:09:49.951Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of authorities
</p>
<p class='widget'>
<label for='request_token_uri'>
request-token-uri
Request-token-uri
</label>
{% ifmemberof admin %}
<input id='request_token_uri' name='request_token_uri' type='string' value='{{record.request_token_uri}}' maxlength='256' size='60'/>
@ -48,7 +48,7 @@ You are not permitted to view request_token_uri of authorities
</p>
<p class='widget'>
<label for='access_token_uri'>
access-token-uri
Access-token-uri
</label>
{% ifmemberof admin %}
<input id='access_token_uri' name='access_token_uri' type='string' value='{{record.access_token_uri}}' maxlength='256' size='60'/>
@ -66,7 +66,7 @@ You are not permitted to view access_token_uri of authorities
</p>
<p class='widget'>
<label for='authorize_uri'>
authorize-uri
Authorize-uri
</label>
{% ifmemberof admin %}
<input id='authorize_uri' name='authorize_uri' type='string' value='{{record.authorize_uri}}' maxlength='256' size='60'/>
@ -84,7 +84,7 @@ You are not permitted to view authorize_uri of authorities
</p>
<p class='widget'>
<label for='consumer_key'>
consumer-key
Consumer-key
</label>
{% ifmemberof admin %}
<input id='consumer_key' name='consumer_key' type='string' value='{{record.consumer_key}}' maxlength='32' size='32'/>
@ -102,7 +102,7 @@ You are not permitted to view consumer_key of authorities
</p>
<p class='widget'>
<label for='consumer_secret'>
consumer-secret
Consumer-secret
</label>
{% ifmemberof admin %}
<input id='consumer_secret' name='consumer_secret' type='string' value='{{record.consumer_secret}}' maxlength='256' size='60'/>

View file

@ -1,10 +1,11 @@
{% extends "base.html" %}
<!-- File form-canvassers-Canvasser.html generated 2018-07-05T10:14:18.471Z by adl.to-selmer-templates.
<!-- File form-canvassers-Canvasser.html generated 2018-07-07T08:09:49.958Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% block extra-head %}
{% script "js/lib/node_modules/simplemde/dist/simplemde.min.js" %}
{% style "js/lib/node_modules/simplemde/dist/simplemde.min.css" %}
{% endblock %}
{% block content %}
<div id='content' class='edit'>
@ -12,7 +13,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +31,7 @@ You are not permitted to view id of canvassers
</p>
<p class='widget'>
<label for='username'>
username
Username
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<input id='username' name='username' type='string' value='{{record.username}}' maxlength='32' size='32'/>
@ -48,7 +49,7 @@ You are not permitted to view username of canvassers
</p>
<p class='widget'>
<label for='fullname'>
fullname
Fullname
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<input id='fullname' name='fullname' type='string' value='{{record.fullname}}' maxlength='64' size='60'/>
@ -66,7 +67,7 @@ You are not permitted to view fullname of canvassers
</p>
<p class='widget'>
<label for='elector_id'>
elector_id
Elector_id
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<span class='select-box' farside='electors' found='true'>
@ -90,7 +91,7 @@ You are not permitted to view elector_id of canvassers
</p>
<p class='widget'>
<label for='address_id'>
address_id
Address_id
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<span class='select-box' farside='addresses' found='true'>
@ -114,7 +115,7 @@ You are not permitted to view address_id of canvassers
</p>
<p class='widget'>
<label for='phone'>
phone
Phone
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<input id='phone' name='phone' type='string' value='{{record.phone}}' maxlength='16' size='16'/>
@ -132,7 +133,7 @@ You are not permitted to view phone of canvassers
</p>
<p class='widget'>
<label for='email'>
email
Email
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<input id='email' name='email' type='string' value='{{record.email}}' maxlength='128' size='60'/>
@ -150,7 +151,7 @@ You are not permitted to view email of canvassers
</p>
<p class='widget'>
<label for='authority_id'>
authority_id
Authority_id
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<span class='select-box' farside='authorities' found='true'>
@ -174,7 +175,7 @@ You are not permitted to view authority_id of canvassers
</p>
<p class='widget'>
<label for='authorised'>
authorised
Authorised
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<input id='authorised' name='authorised' type='checkbox' value='{{record.authorised}}' maxlength='' size='16'/>
@ -192,7 +193,7 @@ You are not permitted to view authorised of canvassers
</p>
<p class='widget'>
<label for='roles'>
roles
Roles
</label>
{% ifmemberof canvassers teamorganisers admin canvassers teamorganisers admin %}
<span class='select-box' farside='roles' found='true'>
@ -249,6 +250,24 @@ To delete this canvassers record
});
}
var simplemde = new SimpleMDE({
autosave: {
enabled: true,
uniqueId: "Smeagol-{{page}}",
delay: 1000,
},
indentWithTabs: true,
insertTexts: {
horizontalRule: ["", "\n\n-----\n\n"],
image: ["![](http://", ")"],
link: ["[", "](http://)"],
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
},
showIcons: ["code"], //, "table"], - sadly, markdown-clj does not support tables
spellChecker: true,
status: ["autosave", "lines", "words", "cursor"]
});
</script>
{% endblock %}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-districts-District.html generated 2018-07-05T10:14:18.436Z by adl.to-selmer-templates.
<!-- File form-districts-District.html generated 2018-07-07T08:09:49.922Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of districts
</p>
<p class='widget'>
<label for='name'>
name
Name
</label>
{% ifmemberof admin %}
<input id='name' name='name' type='string' value='{{record.name}}' maxlength='64' size='60'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-dwellings-Dwelling.html generated 2018-07-05T10:14:18.485Z by adl.to-selmer-templates.
<!-- File form-dwellings-Dwelling.html generated 2018-07-07T08:09:49.973Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of dwellings
</p>
<p class='widget'>
<label for='address_id'>
address_id
Address_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='addresses' found='true'>
@ -54,7 +54,7 @@ You are not permitted to view address_id of dwellings
</p>
<p class='widget'>
<label for='sub_address'>
sub-address
Sub-address
</label>
{% ifmemberof admin %}
<input id='sub_address' name='sub_address' type='string' value='{{record.sub_address}}' maxlength='32' size='32'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-electors-Elector.html generated 2018-07-05T10:14:18.465Z by adl.to-selmer-templates.
<!-- File form-electors-Elector.html generated 2018-07-07T08:09:49.947Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of electors
</p>
<p class='widget'>
<label for='name'>
name
Name
</label>
{% ifmemberof admin %}
<input id='name' name='name' type='string' value='{{record.name}}' maxlength='64' size='60'/>
@ -48,7 +48,7 @@ You are not permitted to view name of electors
</p>
<p class='widget'>
<label for='dwelling_id'>
dwelling_id
Dwelling_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='dwellings' found='true'>
@ -72,7 +72,7 @@ You are not permitted to view dwelling_id of electors
</p>
<p class='widget'>
<label for='phone'>
phone
Phone
</label>
{% ifmemberof admin %}
<input id='phone' name='phone' type='string' value='{{record.phone}}' maxlength='16' size='16'/>
@ -90,7 +90,7 @@ You are not permitted to view phone of electors
</p>
<p class='widget'>
<label for='email'>
email
Email
</label>
{% ifmemberof admin %}
<input id='email' name='email' type='string' value='{{record.email}}' maxlength='128' size='60'/>
@ -108,7 +108,7 @@ You are not permitted to view email of electors
</p>
<p class='widget'>
<label for='gender'>
gender
Gender
</label>
{% ifmemberof admin %}
<span class='select-box' farside='genders' found='true'>

View file

@ -0,0 +1,205 @@
{% extends "base.html" %}
<!-- File form-events-Events.html generated 2018-07-07T08:09:49.954Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% block extra-head %}
{% script "js/lib/node_modules/simplemde/dist/simplemde.min.js" %}
{% style "js/lib/node_modules/simplemde/dist/simplemde.min.css" %}
{% endblock %}
{% block content %}
<div id='content' class='edit'>
<form action='{{servlet-context}}/form-events-Events' method='POST'>
{% csrf-field %}
<p class='widget'>
<label for='id'>
Id
</label>
{% ifmemberof teamorganisers admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='id' name='id' class='pseudo-widget disabled'>
{{record.id}}
</span>
{% else %}
<span id='id' name='id' class='pseudo-widget not-authorised'>
You are not permitted to view id of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
<p class='widget'>
<label for='name'>
Name
</label>
{% ifmemberof teamorganisers admin %}
<input id='name' name='name' type='string' value='{{record.name}}' maxlength='64' size='60'/>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='name' name='name' class='pseudo-widget disabled'>
{{record.name}}
</span>
{% else %}
<span id='name' name='name' class='pseudo-widget not-authorised'>
You are not permitted to view name of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
<p class='widget'>
<label for='teams'>
Teams
</label>
{% ifmemberof teamorganisers admin %}
<span class='select-box' farside='teams' found='true'>
<input name='teams_search_box' onchange='$.getJSON("/auto/json/seach-strings-teams?name=" + teams_search_box.text, null, function (data) {updateMenuOptions("teams", "id", ["name"], data);})'/>
<br/>
<select id='teams' name='teams' multiple='multiple'>
{% for r in teams %}<option value='{{r.id}}' {% ifequal record.teams r.id%}selected{% endifequal %}>{{r.name}}</option>{% endfor %}
</select>
</span>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='teams' name='teams' class='pseudo-widget disabled'>
{{record.teams}}
</span>
{% else %}
<span id='teams' name='teams' class='pseudo-widget not-authorised'>
You are not permitted to view teams of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
<p class='widget'>
<label for='date'>
Date
</label>
{% ifmemberof teamorganisers admin %}
<input id='date' name='date' type='date' value='{{record.date}}' maxlength='' size='16'/>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='date' name='date' class='pseudo-widget disabled'>
{{record.date}}
</span>
{% else %}
<span id='date' name='date' class='pseudo-widget not-authorised'>
You are not permitted to view date of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
<p class='widget'>
<label for='time'>
Time
</label>
{% ifmemberof teamorganisers admin %}
<input id='time' name='time' type='time' value='{{record.time}}' maxlength='' size='16'/>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='time' name='time' class='pseudo-widget disabled'>
{{record.time}}
</span>
{% else %}
<span id='time' name='time' class='pseudo-widget not-authorised'>
You are not permitted to view time of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
<p class='widget'>
<label for='decription'>
Decription
</label>
{% ifmemberof teamorganisers admin %}
<textarea rows='8' cols='60' id='decription' name='decription'>
{{record.decription}}
</textarea>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='decription' name='decription' class='pseudo-widget disabled'>
{{record.decription}}
</span>
{% else %}
<span id='decription' name='decription' class='pseudo-widget not-authorised'>
You are not permitted to view decription of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
<p class='widget'>
<label for='cancelled'>
Cancelled
</label>
{% ifmemberof teamorganisers admin %}
<input id='cancelled' name='cancelled' type='checkbox' value='{{record.cancelled}}' maxlength='' size='16'/>
{% else %}
{% ifmemberof canvassers teamorganisers issueexperts analysts issueeditors admin %}
<span id='cancelled' name='cancelled' class='pseudo-widget disabled'>
{{record.cancelled}}
</span>
{% else %}
<span id='cancelled' name='cancelled' class='pseudo-widget not-authorised'>
You are not permitted to view cancelled of events
</span>
{% endifmemberof %}
{% endifmemberof %}
</p>
{% ifmemberof teamorganisers admin %}
<p class='widget action-safe'>
<label for='save-button' class='action-safe'>
To save this events record
</label>
<input id='save-button' name='save-button' class='action-safe' type='submit' value='Save!'/>
</p>
{% endifmemberof %}
{% ifmemberof teamorganisers admin %}
<p class='widget action-dangerous'>
<label for='delete-button' class='action-dangerous'>
To delete this events record
</label>
<input id='delete-button' name='delete-button' class='action-dangerous' type='submit' value='Delete!'/>
</p>
{% endifmemberof %}
</form>
</div>
{% endblock %}
{% block extra-tail %}
<script type='text/javascript'>
/**
* update the select menu with id `wid` from this `data` whose fields include
* this `entity_key` and these `fields`
*/
function updateMenuOptions(wid, entity_key, fields, data){
$('#' + wid).children().filter(function(){
return $(this).attr('selected') === undefined;
}).remove().end();
$.each(data, function(key, entry){
$('#' + wid).append(
$('<option></option>').attr('value', key).text(entry));
});
}
var simplemde = new SimpleMDE({
autosave: {
enabled: true,
uniqueId: "Smeagol-{{page}}",
delay: 1000,
},
indentWithTabs: true,
insertTexts: {
horizontalRule: ["", "\n\n-----\n\n"],
image: ["![](http://", ")"],
link: ["[", "](http://)"],
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
},
showIcons: ["code"], //, "table"], - sadly, markdown-clj does not support tables
spellChecker: true,
status: ["autosave", "lines", "words", "cursor"]
});
</script>
{% endblock %}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-followupactions-Followupaction.html generated 2018-07-05T10:14:18.488Z by adl.to-selmer-templates.
<!-- File form-followupactions-Followupaction.html generated 2018-07-07T08:09:49.976Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -13,7 +13,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -31,7 +31,7 @@ You are not permitted to view id of followupactions
</p>
<p class='widget'>
<label for='request_id'>
request_id
Request_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='followuprequests' found='true'>
@ -55,7 +55,7 @@ You are not permitted to view request_id of followupactions
</p>
<p class='widget'>
<label for='actor'>
actor
Actor
</label>
{% ifmemberof admin %}
<span class='select-box' farside='canvassers' found='true'>
@ -79,7 +79,7 @@ You are not permitted to view actor of followupactions
</p>
<p class='widget'>
<label for='date'>
date
Date
</label>
{% ifmemberof admin %}
<input id='date' name='date' type='string' value='{{record.date}}' maxlength='' size='16'/>
@ -97,7 +97,7 @@ You are not permitted to view date of followupactions
</p>
<p class='widget'>
<label for='notes'>
notes
Notes
</label>
{% ifmemberof admin %}
<textarea rows='8' cols='60' id='notes' name='notes'>
@ -117,7 +117,7 @@ You are not permitted to view notes of followupactions
</p>
<p class='widget'>
<label for='closed'>
closed
Closed
</label>
{% ifmemberof admin %}
<input id='closed' name='closed' type='checkbox' value='{{record.closed}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-followupmethods-Followupmethod.html generated 2018-07-05T10:14:18.491Z by adl.to-selmer-templates.
<!-- File form-followupmethods-Followupmethod.html generated 2018-07-07T08:09:49.979Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-followuprequests-Followuprequest.html generated 2018-07-05T10:14:18.440Z by adl.to-selmer-templates.
<!-- File form-followuprequests-Followuprequest.html generated 2018-07-07T08:09:49.925Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of followuprequests
</p>
<p class='widget'>
<label for='elector_id'>
elector_id
Elector_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='electors' found='true'>
@ -54,7 +54,7 @@ You are not permitted to view elector_id of followuprequests
</p>
<p class='widget'>
<label for='visit_id'>
visit_id
Visit_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='visits' found='true'>
@ -78,7 +78,7 @@ You are not permitted to view visit_id of followuprequests
</p>
<p class='widget'>
<label for='issue_id'>
issue_id
Issue_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='issues' found='true'>
@ -100,7 +100,7 @@ You are not permitted to view issue_id of followuprequests
</p>
<p class='widget'>
<label for='method_id'>
method_id
Method_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='followupmethods' found='true'>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-genders-Gender.html generated 2018-07-05T10:14:18.432Z by adl.to-selmer-templates.
<!-- File form-genders-Gender.html generated 2018-07-07T08:09:49.918Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-intentions-Intention.html generated 2018-07-05T10:14:18.481Z by adl.to-selmer-templates.
<!-- File form-intentions-Intention.html generated 2018-07-07T08:09:49.968Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='visit_id'>
visit_id
Visit_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='visits' found='true'>
@ -36,7 +36,7 @@ You are not permitted to view visit_id of intentions
</p>
<p class='widget'>
<label for='elector_id'>
elector_id
Elector_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='electors' found='true'>
@ -60,7 +60,7 @@ You are not permitted to view elector_id of intentions
</p>
<p class='widget'>
<label for='option_id'>
option_id
Option_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='options' found='true'>
@ -82,7 +82,7 @@ You are not permitted to view option_id of intentions
</p>
<p class='widget'>
<label for='locality'>
locality
Locality
</label>
{% ifmemberof admin %}
<input id='locality' name='locality' type='number' value='{{record.locality}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-issues-Issue.html generated 2018-07-05T10:14:18.452Z by adl.to-selmer-templates.
<!-- File form-issues-Issue.html generated 2018-07-07T08:09:49.935Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -13,7 +13,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof issueeditors admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -31,7 +31,7 @@ You are not permitted to view id of issues
</p>
<p class='widget'>
<label for='url'>
url
Url
</label>
{% ifmemberof issueeditors admin %}
<input id='url' name='url' type='string' value='{{record.url}}' maxlength='256' size='60'/>
@ -49,7 +49,7 @@ You are not permitted to view url of issues
</p>
<p class='widget'>
<label for='current'>
current
Current
</label>
{% ifmemberof issueeditors admin %}
<input id='current' name='current' type='checkbox' value='{{record.current}}' maxlength='' size='16'/>
@ -67,7 +67,7 @@ You are not permitted to view current of issues
</p>
<p class='widget'>
<label for='brief'>
brief
Brief
</label>
{% ifmemberof issueeditors admin %}
<textarea rows='8' cols='60' id='brief' name='brief'>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-options-Option.html generated 2018-07-05T10:14:18.481Z by adl.to-selmer-templates.
<!-- File form-options-Option.html generated 2018-07-07T08:09:49.967Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-roles-Role.html generated 2018-07-05T10:14:18.454Z by adl.to-selmer-templates.
<!-- File form-roles-Role.html generated 2018-07-07T08:09:49.937Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of roles
</p>
<p class='widget'>
<label for='name'>
name
Name
</label>
{% ifmemberof admin %}
<input id='name' name='name' type='string' value='{{record.name}}' maxlength='64' size='60'/>
@ -48,7 +48,7 @@ You are not permitted to view name of roles
</p>
<p class='widget'>
<label for='members'>
members
Members
</label>
{% ifmemberof admin %}
<span class='select-box' farside='canvassers' found='true'>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-teams-Team.html generated 2018-07-05T10:14:18.461Z by adl.to-selmer-templates.
<!-- File form-teams-Team.html generated 2018-07-07T08:09:49.943Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of teams
</p>
<p class='widget'>
<label for='name'>
name
Name
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<input id='name' name='name' type='string' value='{{record.name}}' maxlength='64' size='60'/>
@ -48,7 +48,7 @@ You are not permitted to view name of teams
</p>
<p class='widget'>
<label for='district_id'>
district_id
District_id
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<span class='select-box' farside='districts' found='true'>
@ -72,7 +72,7 @@ You are not permitted to view district_id of teams
</p>
<p class='widget'>
<label for='latitude'>
latitude
Latitude
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<input id='latitude' name='latitude' type='number' value='{{record.latitude}}' maxlength='' size='16'/>
@ -90,7 +90,7 @@ You are not permitted to view latitude of teams
</p>
<p class='widget'>
<label for='members'>
members
Members
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<span class='select-box' farside='canvassers' found='true'>
@ -114,7 +114,7 @@ You are not permitted to view members of teams
</p>
<p class='widget'>
<label for='organisers'>
organisers
Organisers
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<span class='select-box' farside='canvassers' found='true'>
@ -138,7 +138,7 @@ You are not permitted to view organisers of teams
</p>
<p class='widget'>
<label for='longitude'>
longitude
Longitude
</label>
{% ifmemberof teamorganisers admin teamorganisers admin %}
<input id='longitude' name='longitude' type='number' value='{{record.longitude}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File form-visits-Visit.html generated 2018-07-05T10:14:18.457Z by adl.to-selmer-templates.
<!-- File form-visits-Visit.html generated 2018-07-07T08:09:49.940Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -12,7 +12,7 @@ See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% csrf-field %}
<p class='widget'>
<label for='id'>
id
Id
</label>
{% ifmemberof admin %}
<input id='id' name='id' type='string' value='{{record.id}}' maxlength='' size='16'/>
@ -30,7 +30,7 @@ You are not permitted to view id of visits
</p>
<p class='widget'>
<label for='address_id'>
address_id
Address_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='addresses' found='true'>
@ -54,7 +54,7 @@ You are not permitted to view address_id of visits
</p>
<p class='widget'>
<label for='canvasser_id'>
canvasser_id
Canvasser_id
</label>
{% ifmemberof admin %}
<span class='select-box' farside='canvassers' found='true'>
@ -78,7 +78,7 @@ You are not permitted to view canvasser_id of visits
</p>
<p class='widget'>
<label for='date'>
date
Date
</label>
{% ifmemberof admin %}
<input id='date' name='date' type='string' value='{{record.date}}' maxlength='' size='16'/>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-addresses-Addresses.html generated 2018-07-05T10:14:18.471Z by adl.to-selmer-templates.
<!-- File list-addresses-Addresses.html generated 2018-07-07T08:09:49.953Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,25 +45,25 @@ Add a new Address
<thead>
<tr>
<th>
id
Id
</th>
<th>
address
Address
</th>
<th>
postcode
Postcode
</th>
<th>
phone
Phone
</th>
<th>
district_id
District_id
</th>
<th>
latitude
Latitude
</th>
<th>
longitude
Longitude
</th>
<th>
&nbsp;
@ -74,10 +74,10 @@ longitude
<input id='id' type='text' name='id' value='{{ params.id }}'/>
</th>
<th>
<input id='address' type='text' name='address' value='{{ params.address }}'/>
<input id='Address' type='text' name='Address' value='{{ params.Address }}'/>
</th>
<th>
<input id='postcode' type='text' name='postcode' value='{{ params.postcode }}'/>
<input id='Postcode' type='text' name='Postcode' value='{{ params.Postcode }}'/>
</th>
<th>
<input id='phone' type='text' name='phone' value='{{ params.phone }}'/>
@ -103,10 +103,10 @@ longitude
{{ record.id }}
</td>
<td>
{{ record.address }}
{{ record. }}
</td>
<td>
{{ record.postcode }}
{{ record. }}
</td>
<td>
{{ record.phone }}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-authorities-Authorities.html generated 2018-07-05T10:14:18.439Z by adl.to-selmer-templates.
<!-- File list-authorities-Authorities.html generated 2018-07-07T08:09:49.924Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,16 +45,16 @@ Add a new Authority
<thead>
<tr>
<th>
id
Id
</th>
<th>
request-token-uri
Request-token-uri
</th>
<th>
access-token-uri
Access-token-uri
</th>
<th>
authorize-uri
Authorize-uri
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-canvassers-Canvassers.html generated 2018-07-05T10:14:18.485Z by adl.to-selmer-templates.
<!-- File list-canvassers-Canvassers.html generated 2018-07-07T08:09:49.972Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,31 +45,31 @@ Add a new Canvasser
<thead>
<tr>
<th>
id
Id
</th>
<th>
username
Username
</th>
<th>
fullname
Fullname
</th>
<th>
elector_id
Elector_id
</th>
<th>
address_id
Address_id
</th>
<th>
phone
Phone
</th>
<th>
email
Email
</th>
<th>
authority_id
Authority_id
</th>
<th>
authorised
Authorised
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-districts-Districts.html generated 2018-07-05T10:14:18.479Z by adl.to-selmer-templates.
<!-- File list-districts-Districts.html generated 2018-07-07T08:09:49.965Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,10 +45,10 @@ Add a new District
<thead>
<tr>
<th>
id
Id
</th>
<th>
name
Name
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-dwellings-Dwellings.html generated 2018-07-05T10:14:18.468Z by adl.to-selmer-templates.
<!-- File list-dwellings-Dwellings.html generated 2018-07-07T08:09:49.950Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,13 +45,13 @@ Add a new Dwelling
<thead>
<tr>
<th>
id
Id
</th>
<th>
address_id
Address_id
</th>
<th>
sub-address
Sub-address
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-electors-Electors.html generated 2018-07-05T10:14:18.451Z by adl.to-selmer-templates.
<!-- File list-electors-Electors.html generated 2018-07-07T08:09:49.934Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,22 +45,22 @@ Add a new Elector
<thead>
<tr>
<th>
id
Id
</th>
<th>
name
Name
</th>
<th>
dwelling_id
Dwelling_id
</th>
<th>
phone
Phone
</th>
<th>
email
Email
</th>
<th>
gender
Gender
</th>
<th>
&nbsp;

View file

@ -0,0 +1,148 @@
{% extends "base.html" %}
<!-- File list-events-Events.html generated 2018-07-07T08:09:49.965Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
{% block back-links %}
<div>
<div class='back-link-container'>
{% ifequal params.offset "0" %}
<a id='back-link' class='back-link' href='{{servlet-context}}/admin'>
Back
</a>
{% else %}
<a id='prev-selector' class='back-link'>
Previous
</a>
{% endifunequal %}
</div>
</div>
{% endblock %}
{% block big-links %}
<div>
<div class='big-link-container'>
<a id='next-selector' role='button' class='big-link'>
Next
</a>
</div>
{% ifmemberof teamorganisers admin %}
<div class='big-link-container'>
<a href='form-events-Events' class='big-link'>
Add a new Event
</a>
</div>
{% endifmemberof %}
</div>
{% endblock %}
{% block content %}
<form id='list-events-Events' class='list' action='{{servlet-context}}/list-events-Events' method='POST'>
{% csrf-field %}
<input id='offset' type='hidden' value='{{params.offset|default:0}}'/>
<input id='limit' type='hidden' value='{{params.limit|default:50}}'/>
<table caption='events'>
<thead>
<tr>
<th>
Id
</th>
<th>
Name
</th>
<th>
Date
</th>
<th>
Time
</th>
<th>
Decription
</th>
<th>
Cancelled
</th>
<th>
&nbsp;
</th>
</tr>
<tr>
<th>
<input id='id' type='text' name='id' value='{{ params.id }}'/>
</th>
<th>
<input id='name' type='text' name='name' value='{{ params.name }}'/>
</th>
<th>
<input id='date' type='date' name='date' value='{{ params.date }}'/>
</th>
<th>
<input id='time' type='time' name='time' value='{{ params.time }}'/>
</th>
<th>
<input id='decription' type='text' name='decription' value='{{ params.decription }}'/>
</th>
<th>
<input id='cancelled' type='text' name='cancelled' value='{{ params.cancelled }}'/>
</th>
<th>
<input type='submit' id='search-widget' value='Search'/>
</th>
</tr>
</thead>
<tbody>
{% for record in records %}
<tr>
<td>
{{ record.id }}
</td>
<td>
{{ record.name }}
</td>
<td>
{{ record.date }}
</td>
<td>
{{ record.time }}
</td>
<td>
{{ record.decription }}
</td>
<td>
{{ record.cancelled }}
</td>
<td>
<a href='form-events-Events?id={{ record.id }}'>
View
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% endblock %}
{% block extra-script %}
var form = document.getElementById('list-events-Events');
var ow = document.getElementById('offset');
var lw = document.getElementById('limit');
form.addEventListener('submit', function() {
ow.value='0';
});
{% ifunequal params.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 %}

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-followupactions-Followupactions.html generated 2018-07-05T10:14:18.484Z by adl.to-selmer-templates.
<!-- File list-followupactions-Followupactions.html generated 2018-07-07T08:09:49.971Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,22 +45,22 @@ Add a new Followupaction
<thead>
<tr>
<th>
id
Id
</th>
<th>
request_id
Request_id
</th>
<th>
actor
Actor
</th>
<th>
date
Date
</th>
<th>
notes
Notes
</th>
<th>
closed
Closed
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-followupmethods-Followupmethods.html generated 2018-07-05T10:14:18.456Z by adl.to-selmer-templates.
<!-- File list-followupmethods-Followupmethods.html generated 2018-07-07T08:09:49.939Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,7 +45,7 @@ Add a new Followupmethod
<thead>
<tr>
<th>
id
Id
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-followuprequests-Followuprequests.html generated 2018-07-05T10:14:18.434Z by adl.to-selmer-templates.
<!-- File list-followuprequests-Followuprequests.html generated 2018-07-07T08:09:49.920Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,19 +45,19 @@ Add a new Followuprequest
<thead>
<tr>
<th>
id
Id
</th>
<th>
elector_id
Elector_id
</th>
<th>
visit_id
Visit_id
</th>
<th>
issue_id
Issue_id
</th>
<th>
method_id
Method_id
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-genders-Genders.html generated 2018-07-05T10:14:18.428Z by adl.to-selmer-templates.
<!-- File list-genders-Genders.html generated 2018-07-07T08:09:49.914Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,7 +45,7 @@ Add a new Gender
<thead>
<tr>
<th>
id
Id
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-intentions-Intentions.html generated 2018-07-05T10:14:18.487Z by adl.to-selmer-templates.
<!-- File list-intentions-Intentions.html generated 2018-07-07T08:09:49.975Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,16 +45,16 @@ Add a new Intention
<thead>
<tr>
<th>
visit_id
Visit_id
</th>
<th>
elector_id
Elector_id
</th>
<th>
option_id
Option_id
</th>
<th>
locality
Locality
</th>
<th>
&nbsp;
@ -100,7 +100,7 @@ locality
{{ record.locality }}
</td>
<td>
<a href='form-intentions-Intention?Id={{ record.Id }}'>
<a href='form-intentions-Intention?id={{ record.id }}'>
View
</a>
</td>

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-issues-Issues.html generated 2018-07-05T10:14:18.480Z by adl.to-selmer-templates.
<!-- File list-issues-Issues.html generated 2018-07-07T08:09:49.966Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,16 +45,16 @@ Add a new Issue
<thead>
<tr>
<th>
id
Id
</th>
<th>
url
Url
</th>
<th>
current
Current
</th>
<th>
brief
Brief
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-options-Options.html generated 2018-07-05T10:14:18.435Z by adl.to-selmer-templates.
<!-- File list-options-Options.html generated 2018-07-07T08:09:49.921Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,7 +45,7 @@ Add a new Option
<thead>
<tr>
<th>
id
Id
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-roles-Roles.html generated 2018-07-05T10:14:18.456Z by adl.to-selmer-templates.
<!-- File list-roles-Roles.html generated 2018-07-07T08:09:49.939Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,10 +45,10 @@ Add a new Role
<thead>
<tr>
<th>
id
Id
</th>
<th>
name
Name
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-teams-Teams.html generated 2018-07-05T10:14:18.431Z by adl.to-selmer-templates.
<!-- File list-teams-Teams.html generated 2018-07-07T08:09:49.917Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,19 +45,19 @@ Add a new Team
<thead>
<tr>
<th>
id
Id
</th>
<th>
name
Name
</th>
<th>
district_id
District_id
</th>
<th>
latitude
Latitude
</th>
<th>
longitude
Longitude
</th>
<th>
&nbsp;

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
<!-- File list-visits-Visits.html generated 2018-07-05T10:14:18.430Z by adl.to-selmer-templates.
<!-- File list-visits-Visits.html generated 2018-07-07T08:09:49.916Z by adl.to-selmer-templates.
See [Application Description Language](https://github.com/simon-brooke/adl).-->
@ -45,16 +45,16 @@ Add a new Visit
<thead>
<tr>
<th>
id
Id
</th>
<th>
address_id
Address_id
</th>
<th>
canvasser_id
Canvasser_id
</th>
<th>
date
Date
</th>
<th>
&nbsp;

View file

@ -5,11 +5,11 @@
<!-- head: if you want entire custom head content, override this block. -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="css/yyy-common.css" />
<link rel="stylesheet" type="text/css" href="css/yyy-site.css" />
<link rel="stylesheet" type="text/css" href="css/spinner.css" />
{% style "/css/yyy-common.css" %}
{% style "/css/yyy-site.css" %}
{% style "/css/spinner.css" %}
<link href="https://fonts.googleapis.com/css?family=Archivo+Black|Archivo+Narrow" rel="stylesheet"/>
{% script "js/lib/node_modules/jquery/dist/jquery.min.js" %}
{% script "/js/lib/node_modules/jquery/dist/jquery.min.js" %}
<title>{{site-title}}: {{title}}</title>
{% endblock %}
{% block extra-head %}

View file

@ -1,38 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Something bad happened</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% style "/assets/bootstrap/css/bootstrap.min.css" %}
{% style "/assets/bootstrap/css/bootstrap-theme.min.css" %}
<style type="text/css">
html {
height: 100%;
min-height: 100%;
min-width: 100%;
overflow: hidden;
width: 100%;
}
html body {
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
html .container-fluid {
display: table;
height: 100%;
padding: 0;
width: 100%;
}
html .row-fluid {
display: table-cell;
height: 100%;
vertical-align: middle;
}
</style>
</head>
{% extends "base.html" %}
{% block big-links %}
{% endblock %}
{% block content %}
<body>
<div class="container-fluid">
<div class="row-fluid">
@ -52,5 +21,5 @@
</div>
</div>
</div>
</body>
</html>
{% endblock %}

View file

@ -9,39 +9,7 @@
{% endblock %}
{% block content %}
<img id="site-logo" src="img/ProjectHopeLogo4.png" alt="{{site-title}}" style="float: left;" height="345" width="345"/>
<h2>
Alpha test code
</h2>
<p>
This is a voter intention information system intended to be used by the 'Yes' side in the next independence referendum.
Design documentation is <a href="https://github.com/simon-brooke/youyesyet/blob/master/doc/specification/userspec.md">here</a>.</p>
{{motd|safe}}
<p>Although addresses in the database mostly are real, all personal data in the database
is randomly generated and does not represent real people.</p>
<h3>
The Canvasser app
</h3>
<p>Because the canvasser app now loads data from the database and uses your current location, and the database currently only holds
data for the Castle Douglas area, you're unlikely to see any actual data in the app. A dummy of the app in which you can see
data is <a href="http://www.journeyman.cc/~simon/tmp/yyy-dummy-2/">here</a>.
</p>
<p>
The app currently works on the Chrome browser, and on Android phones. I don't yet know whether it works on iPhones. It does not at
present work with Firefox.
</p>
<h3>
The Admin system
</h3>
<p>'Save' and 'Delete' buttons on administrative pages do not work; this is intentional at this stage.
I want you to be able to see what different roles in the project can see, without actually being able
to mess up the database.</p>
<p>If you encounter problems, please submit a report <a href="https://github.com/simon-brooke/youyesyet/issues">here</a>.
General feedback on usability is also appreciated.</p>
</p>
{% endblock %}

View file

@ -11,7 +11,7 @@
{% endblock %}
{% block content %}
<form action="auth" method="post">
<form action="login" method="post">
{% csrf-field %}
<h2>
Or use a test username and password

View file

@ -5,7 +5,7 @@
{% block big-links %}
{% for role in roles %}
<div class="big-link-container">
<a href="{{role.name|lower}}" class="big-link" id="big-link">{{role.name}}</a>
<a href="roles/{{role.link|lower}}" class="big-link" id="big-link">{{role.name}}</a>
</div>
{% endfor %}
{% endblock %}

View file

@ -0,0 +1 @@

View file

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block big-links %}
<div class="big-link-container">
<a href="auth" class="big-link" id="yes-link">Yes</a>
<a href="login" class="big-link" id="yes-link">Yes</a>
</div>
<div class="big-link-container">
<a href="register" class="big-link" id="signup-link">No</a>

View file

@ -11,7 +11,7 @@
clojure.lang.IPersistentMap
clojure.lang.IPersistentVector
[java.sql
BatchUpdateException
;; BatchUpdateException
Date
Timestamp
PreparedStatement]))

View file

@ -14,6 +14,8 @@
[youyesyet.routes.auto-json :refer [auto-rest-routes]]
[youyesyet.routes.auto :refer [auto-selmer-routes]]
[youyesyet.routes.rest :refer [rest-routes]]
[youyesyet.routes.roles :refer [roles-routes]]
[youyesyet.routes.services :refer [service-routes]]
[youyesyet.env :refer [defaults]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -61,11 +63,15 @@
(shutdown-agents)
(log/info "youyesyet has shut down!"))
(def app-routes
(routes
(-> #'home-routes
(wrap-routes middleware/wrap-csrf)
(wrap-routes middleware/wrap-formats))
(-> #'roles-routes
(wrap-routes middleware/wrap-csrf)
(wrap-routes middleware/wrap-formats))
(-> #'auto-rest-routes
(wrap-routes middleware/wrap-csrf)
(wrap-routes middleware/wrap-formats))
@ -76,12 +82,15 @@
(wrap-routes middleware/wrap-formats))
(-> #'rest-routes
(wrap-routes middleware/wrap-formats))
(-> #'service-routes
(wrap-routes middleware/wrap-formats)) ;; TODO: and authentication, but let's not sweat the small stuff.
'oauth-routes
(route/resources "/")
(route/not-found
(:body
(error-page {:status 404
:title "page not found"})))))
:title "Page not found"
:message "The page you requested has not yet been implemented"})))))
(def app (middleware/wrap-base #'app-routes))

View file

@ -90,4 +90,4 @@
[error-details]
{:status (:status error-details)
:headers {"Content-Type" "text/html; charset=utf-8"}
:body (parser/render-file "error.html" error-details)})
:body (render "error.html" {} error-details)})

View file

@ -1,6 +1,6 @@
(ns
youyesyet.routes.auto
"User interface routes for Youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180705T101418.070Z"
"User interface routes for Youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180707T080949.557Z"
(:require
[adl-support.core :as support]
[clojure.java.io :as io]
@ -63,8 +63,8 @@
(do (db/create-address! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -114,8 +114,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -165,8 +165,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -220,8 +220,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -271,8 +271,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -320,8 +320,8 @@
(do (db/create-elector! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -331,6 +331,53 @@
{:dwellings (db/list-dwellings db/*db*)}
{:genders (db/list-genders db/*db*)}))))))
(defn
form-events-Events
[r]
(let
[p (support/massage-params (:params r) (:form-params r) #{"id"})]
(l/render
(support/resolve-template "form-events-Events.html")
(:session r)
(merge
{:title "Events", :params p}
(reduce
merge
(merge
(cond
(:save-button p)
(try
(if
(some #{"id"} (map name (keys p)))
(do (db/update-event! db/*db* p) {:message "Updated record"})
(do (db/create-event! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
[]
(db/get-event db/*db* p))})
(list {:teams (db/list-teams db/*db*)}))))))
(defn
list-events-Events
[r]
(let
[p (support/massage-params (:params r) (:form-params r) #{"id"})]
(l/render
(support/resolve-template "list-events-Events.html")
(:session r)
(merge
{:title "Events", :params p}
{:records
(if
(not (empty? (remove nil? (vals p))))
(db/search-strings-events db/*db* p)
(db/list-events db/*db* {}))}))))
(defn
list-followupactions-Followupactions
[r]
@ -375,8 +422,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -430,8 +477,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -483,8 +530,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -534,8 +581,8 @@
(do (db/create-gender! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -547,7 +594,7 @@
list-intentions-Intentions
[r]
(let
[p (support/massage-params (:params r) (:form-params r) #{"Id"})]
[p (support/massage-params (:params r) (:form-params r) #{"id"})]
(l/render
(support/resolve-template "list-intentions-Intentions.html")
(:session r)
@ -563,7 +610,7 @@
form-intentions-Intention
[r]
(let
[p (support/massage-params (:params r) (:form-params r) #{"Id"})]
[p (support/massage-params (:params r) (:form-params r) #{"id"})]
(l/render
(support/resolve-template "form-intentions-Intention.html")
(:session r)
@ -576,7 +623,7 @@
(:save-button p)
(try
(if
(some #{"Id"} (map name (keys p)))
(some #{"id"} (map name (keys p)))
(do
(db/update-intention! db/*db* p)
{:message "Updated record"})
@ -585,8 +632,8 @@
{:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -635,8 +682,8 @@
(do (db/create-issue! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -682,8 +729,8 @@
(do (db/create-option! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -729,8 +776,8 @@
(do (db/create-role! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -776,8 +823,8 @@
(do (db/create-team! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -826,8 +873,8 @@
(do (db/create-visit! db/*db* p) {:message "Saved record"}))
(catch
java.lang.Exception
any__2078__auto__
{:error (.getMessage any__2078__auto__)})))
any__2085__auto__
{:error (.getMessage any__2085__auto__)})))
{:record
(if
(empty? (remove nil? (vals p)))
@ -924,6 +971,16 @@
request
(route/restricted
(apply (resolve-handler "form-electors-Elector") (list request))))
(GET
"/form-events-Events"
request
(route/restricted
(apply (resolve-handler "form-events-Events") (list request))))
(POST
"/form-events-Events"
request
(route/restricted
(apply (resolve-handler "form-events-Events") (list request))))
(GET
"/form-followupactions-Followupaction"
request
@ -1120,6 +1177,16 @@
request
(route/restricted
(apply (resolve-handler "list-electors-Electors") (list request))))
(GET
"/list-events-Events"
request
(route/restricted
(apply (resolve-handler "list-events-Events") (list request))))
(POST
"/list-events-Events"
request
(route/restricted
(apply (resolve-handler "list-events-Events") (list request))))
(GET
"/list-followupactions-Followupactions"
request

View file

@ -1,6 +1,6 @@
(ns
youyesyet.routes.auto-json
"JSON routes for youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180705T101417.082Z"
"JSON routes for youyesyet auto-generated by [Application Description Language framework](https://github.com/simon-brooke/adl) at 20180707T080948.404Z"
(:require
[adl-support.core :as support]
[clojure.core.memoize :as memo]
@ -37,7 +37,7 @@
(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."
"Auto-generated method to insert one record to the `canvassers` table. Expects the following key(s) to be present in `params`: `(:username :fullname :avatar :bio :elector_id :address_id :phone :email :authority_id :authorised)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params form-params]}]
(let
[result
@ -79,6 +79,17 @@
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
(defn
create-event!
"Auto-generated method to insert one record to the `events` table. Expects the following key(s) to be present in `params`: `(:name :date :time :decription :cancelled)`. Returns a map containing the keys `#{\"id\"}` identifying the record created."
[{:keys [params form-params]}]
(let
[result
(db/create-event!
db/*db*
(support/massage-params params form-params #{"id"}))]
(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."
@ -125,13 +136,13 @@
(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."
"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 form-params]}]
(let
[result
(db/create-intention!
db/*db*
(support/massage-params params form-params #{"Id"}))]
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
(defn
@ -193,176 +204,153 @@
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 form-params]}]
(let
[result
(db/delete-address!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-address!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-authority!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-authority!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-canvasser!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-canvasser!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-district!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-district!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-dwelling!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-dwelling!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-elector!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-elector!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(defn
delete-event!
"Auto-generated method to delete one record from the `events` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params form-params]}]
((db/delete-event!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-followupaction!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-followupaction!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-followupmethod!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-followupmethod!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-followuprequest!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-followuprequest!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-gender!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-gender!
db/*db*
(support/massage-params params form-params #{"id"}))
(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\"}`."
"Auto-generated method to delete one record from the `intentions` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`."
[{:keys [params form-params]}]
(let
[result
(db/delete-intention!
db/*db*
(support/massage-params params form-params #{"Id"}))]
((db/delete-intention!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-issue!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-issue!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-option!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-option!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-role!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-role!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-team!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-team!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/delete-visit!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/delete-visit!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(def
@ -463,6 +451,17 @@
:ttl/threshold
100000000))
(defn
get-event
"Auto-generated method to select one record from the `events` table. Expects the following key(s) to be present in `params`: `#{\"id\"}`. Returns a map containing the following keys: `clojure.lang.LazySeq@3ac90901`."
[{:keys [params form-params]}]
(let
[result
(db/get-event
db/*db*
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
(defn
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`."
@ -525,7 +524,7 @@
[result
(db/get-intention
db/*db*
(support/massage-params params form-params #{"Id"}))]
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
:ttl/threshold
100000))
@ -738,6 +737,22 @@
[{:keys [params]}]
(do (db/list-electors-by-gender params)))
(defn
list-events
"Auto-generated method to select all records from the `events` 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: `(:name :teams :date :time :decription :cancelled :id)`."
[{:keys [params form-params]}]
(let
[result
(db/list-events
db/*db*
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
(defn
list-events-by-team
[{:keys [params]}]
(do (db/list-events-by-team params)))
(defn
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)`."
@ -830,7 +845,7 @@
[result
(db/list-intentions
db/*db*
(support/massage-params params form-params #{"Id"}))]
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
:ttl/threshold
100000))
@ -1029,6 +1044,17 @@
:ttl/threshold
100000000))
(defn
search-strings-events
"Auto-generated method to select all records from the `events` 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: `(:name :teams :date :time :decription :cancelled :id)`."
[{:keys [params form-params]}]
(let
[result
(db/search-strings-events
db/*db*
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
(defn
search-strings-followupactions
"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)`."
@ -1091,7 +1117,7 @@
[result
(db/search-strings-intentions
db/*db*
(support/massage-params params form-params #{"Id"}))]
(support/massage-params params form-params #{"id"}))]
(response/ok result)))
:ttl/threshold
100000))
@ -1170,176 +1196,153 @@
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 form-params]}]
(let
[result
(db/update-address!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-address!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-authority!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-authority!
db/*db*
(support/massage-params params form-params #{"id"}))
(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)`."
"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 :avatar :bio :elector_id :email :fullname :id :phone :username)`."
[{:keys [params form-params]}]
(let
[result
(db/update-canvasser!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-canvasser!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-district!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-district!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-dwelling!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-dwelling!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-elector!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-elector!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(defn
update-event!
"Auto-generated method to update one record in the `events` table. Expects the following key(s) to be present in `params`: `(:cancelled :date :decription :id :name :time)`."
[{:keys [params form-params]}]
((db/update-event!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-followupaction!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-followupaction!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(defn
update-followupmethod!
"Auto-generated method to update one record in the `followupmethods` table. Expects the following key(s) to be present in `params`: `(:id)`."
[{:keys [params form-params]}]
(let
[result
(db/update-followupmethod!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-followupmethod!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-followuprequest!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-followuprequest!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(defn
update-gender!
"Auto-generated method to update one record in the `genders` table. Expects the following key(s) to be present in `params`: `(:id)`."
[{:keys [params form-params]}]
(let
[result
(db/update-gender!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-gender!
db/*db*
(support/massage-params params form-params #{"id"}))
(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)`."
"Auto-generated method to update one record in the `intentions` table. Expects the following key(s) to be present in `params`: `(:elector_id :id :locality :option_id :visit_id)`."
[{:keys [params form-params]}]
(let
[result
(db/update-intention!
db/*db*
(support/massage-params params form-params #{"Id"}))]
((db/update-intention!
db/*db*
(support/massage-params params form-params #{"id"}))
(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`: `(:brief :current :id :url)`."
[{:keys [params form-params]}]
(let
[result
(db/update-issue!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-issue!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(defn
update-option!
"Auto-generated method to update one record in the `options` table. Expects the following key(s) to be present in `params`: `(:id)`."
[{:keys [params form-params]}]
(let
[result
(db/update-option!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-option!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-role!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-role!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-team!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-team!
db/*db*
(support/massage-params params form-params #{"id"}))
(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 form-params]}]
(let
[result
(db/update-visit!
db/*db*
(support/massage-params params form-params #{"id"}))]
((db/update-visit!
db/*db*
(support/massage-params params form-params #{"id"}))
(response/found "/")))
(defroutes
@ -1368,6 +1371,10 @@
"/json/auto/create-elector"
request
(route/restricted (create-elector! request)))
(POST
"/json/auto/create-event"
request
(route/restricted (create-event! request)))
(POST
"/json/auto/create-followupaction"
request
@ -1432,6 +1439,10 @@
"/json/auto/delete-elector"
request
(route/restricted (delete-elector! request)))
(POST
"/json/auto/delete-event"
request
(route/restricted (delete-event! request)))
(POST
"/json/auto/delete-followupaction"
request
@ -1500,6 +1511,10 @@
"/json/auto/get-elector"
request
(route/restricted (get-elector request)))
(GET
"/json/auto/get-event"
request
(route/restricted (get-event request)))
(GET
"/json/auto/get-followupaction"
request
@ -1600,6 +1615,14 @@
"/json/auto/list-electors-by-gender"
request
(route/restricted (list-electors-by-gender request)))
(GET
"/json/auto/list-events"
request
(route/restricted (list-events request)))
(GET
"/json/auto/list-events-by-team"
request
(route/restricted (list-events-by-team request)))
(GET
"/json/auto/list-followupactions"
request
@ -1720,6 +1743,10 @@
"/json/auto/search-strings-electors"
request
(route/restricted (search-strings-electors request)))
(GET
"/json/auto/search-strings-events"
request
(route/restricted (search-strings-events request)))
(GET
"/json/auto/search-strings-followupactions"
request
@ -1784,6 +1811,10 @@
"/json/auto/update-elector"
request
(route/restricted (update-elector! request)))
(POST
"/json/auto/update-event"
request
(route/restricted (update-event! request)))
(POST
"/json/auto/update-followupaction"
request

View file

@ -1,9 +1,11 @@
(ns ^{:doc "Routes/pages available to unauthenticated users."
:author "Simon Brooke"} youyesyet.routes.home
(:require [clojure.java.io :as io]
(:require [adl-support.utils :refer [safe-name]]
[clojure.java.io :as io]
[clojure.string :as s]
[clojure.tools.logging :as log]
[clojure.walk :refer [keywordize-keys]]
[markdown.core :refer [md-to-html-string]]
[noir.util.route :as route]
[ring.util.http-response :as response]
[youyesyet.config :refer [env]]
@ -36,6 +38,16 @@
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn motd
[]
"Message of the day data is currently being loaded from a file in resources.
That probably isn't the final solution, but I don't currently have a final
solution"
(let [motd (io/as-file (io/resource (env :motd)))]
(if (.exists motd) (slurp motd) "")))
(defn app-page [request]
(layout/render "app.html" {:title "Canvasser app"
:user (:user (:session request))}))
@ -43,7 +55,9 @@
(defn about-page []
(layout/render "about.html" {} {:title
(str "About " (:site-title env))}))
(str "About " (:site-title env))
:motd (md-to-html-string (motd))}))
(defn call-me-page [request]
@ -58,23 +72,9 @@
:concerns (db-core/list-issues db-core/*db* {})})))
(defn roles-page [request]
(let
[session (:session request)
user (:user session)
roles (if user (db-core/list-roles-by-canvasser db-core/*db* {:id (:id user)}))]
(cond
roles (layout/render "roles.html"
(:session request)
{:title (str "Welcome " (:fullname user) ", what do you want to do?")
:user user
:roles roles})
(empty? roles)(response/found "/app")
true (assoc (response/found "/login") :session (dissoc session :user)))))
(defn home-page []
(layout/render "home.html" {} {:title "You yes yet?"}))
(layout/render "home.html" {} {:title "You yes yet?"
:motd (md-to-html-string (motd))}))
(defn login-page
@ -126,17 +126,23 @@
:authorities (db-core/list-authorities db-core/*db*)}))))
(defn handle-logout
[request]
(dissoc (response/found "home") :user :roles))
(defroutes home-routes
(GET "/" [] (home-page))
(GET "/home" [] (home-page))
(GET "/about" [] (about-page))
(GET "/roles" request (route/restricted (roles-page request)))
(GET "/canvassers" [request] (route/restricted (app-page request)))
(GET "/call-me" [] (call-me-page nil))
(POST "/call-me" request (call-me-page request))
(GET "/auth" request (login-page request))
(POST "/auth" request (login-page request))
(GET "/login" request (login-page request))
(POST "/login" request (login-page request))
(GET "/logout" request (handle-logout request))
(GET "/notyet" [] (layout/render "notyet.html" {}
{:title "Can we persuade you?"}))
(GET "/supporter" [] (layout/render "supporter.html" {}
{:title "Have you signed up as a canvasser yet?"})))
{:title "Have you signed up as a canvasser yet?"}))
;; TODO: this should move somewhere else but I'm not sure where yet
(GET "/app" [request] (route/restricted (app-page request))))

View file

@ -0,0 +1,71 @@
(ns ^{:doc "Routes/pages available to authenticated users in specific roles."
:author "Simon Brooke"} youyesyet.routes.roles
(:require [adl-support.utils :refer [safe-name]]
[clojure.tools.logging :as log]
[clojure.walk :refer [keywordize-keys]]
[compojure.core :refer [defroutes GET POST]]
[noir.util.route :as route]
[ring.util.http-response :as response]
[youyesyet.config :refer [env]]
[youyesyet.db.core :as db-core]
[youyesyet.layout :as layout]
[youyesyet.oauth :as oauth]
[youyesyet.routes.auto :as auto]))
(defn roles-page [request]
"Render the routing page for the roles the currently logged in user is member of."
(let
[session (:session request)
user (:user session)
roles (if
user
(db-core/list-roles-by-canvasser db-core/*db* {:id (:id user)}))]
(log/info (str "Roles routing page; user is " user "; roles are " roles))
(cond
roles (layout/render "roles.html"
(:session request)
{:title (str "Welcome " (:fullname user) ", what do you want to do?")
:user user
:roles (map #(assoc % :link (safe-name (:name %) :sql)) roles)})
(empty? roles)(response/found "/app")
true (assoc (response/found "/login") :session (dissoc session :user)))))
(defn admins-page
[request]
(response/found "/admin"))
(defn analysts-page
"My expectation is that analysts will do a lot of their work through QGIS or
some other geographical information system; so there isn't a need to put
anything sophisticated here."
[request]
(response/found "/admin"))
(defn canvassers-page
[request]
(layout/render "roles/canvasser.html" request {}))
(defn issue-experts-page
[request]
(layout/render "roles/issue-experts.html" request {}))
(defn team-organisers-page
[request]
(layout/render "roles/team-orgenisers.html" request {}))
(defroutes roles-routes
(GET "/roles/admins" [request] (route/restricted (admins-page request)))
(GET "/roles/analysts" [request] (route/restricted (analysts-page request)))
(GET "/roles/canvassers" [request] (route/restricted (canvassers-page request)))
(GET "/roles/issue_editors" [request] (route/restricted (auto/list-issues-Issues request)))
(GET "/roles/issue_experts" [request] (route/restricted (issue-experts-page request)))
(GET "/roles/team_organisers" [request] (route/restricted (auto/list-teams-Teams request)))
(GET "/roles" request (route/restricted (roles-page request))))

View file

@ -3,21 +3,26 @@
(ns ^{:doc "REST API."
:author "Simon Brooke"} youyesyet.routes.services
(:require [clj-http.client :as client]
[ring.util.http-response :refer :all]
[compojure.api.sweet :refer :all]
[schema.core :as s]))
[ring.util.http-response :refer :all]
[schema.core :as s]
[youyesyet.db.core :as db]))
(defapi service-routes
{:swagger {:ui "/swagger-ui"
:spec "/swagger.json"
:coercion :schema
:data {:info {:version "1.0.0"
:title "Sample API"
:description "Sample Services"}}}}
(context "/api" []
:tags ["thingie"]
(GET "/electors/:address-id" []
;; (GET "/electors-by-dwelling/:dwelling-id" []
;; :return map
;; :query-params [dwelling-id :- s/Int]
;; :summary ""
;; (db/list-electors-by-dwelling db/*db* {:id dwelling-id}))
(GET "/plus" []
:return Long
@ -47,4 +52,4 @@
:return Long
:header-params [x :- Long, y :- Long]
:summary "x^y with header-parameters"
(ok (long (Math/pow x y)))))))
(ok (long (Math/pow x y))))))

View file

@ -1,20 +0,0 @@
(ns^{:doc "Custom Selmer tags."
:author "Simon Brooke"}
youyesyet.tags
(:require [selmer.parser :as parser]
[selmer.filters :as filters]
[selmer.util :refer :all]))
(defn if-writable-handler [params tag-content render rdr]
"If the current element is writable by the current user, emit the content of
the if clause; else emit the content of the else clause."
(let [{if-tags :ifwritable else-tags :else} (tag-content rdr :ifwritable :else :endifwritable)]
params))
(defn if-readable-handler [params tag-content render rdr]
"If the current element is readable by the current user, emit the content of
the if clause; else emit the content of the else clause."
(let [{if-tags :ifreadable else-tags :else} (tag-content rdr :ifwritable :else :endifwritable)]
params))

View file

@ -39,7 +39,7 @@
[:div
[:h1 "You Yes Yet?"]
[:div.container {:id "main-container"}
[:h2 "Pre-alpha/proof of concept"]
[:h2 "Alpha test code"]
[:p.motd {:dangerouslySetInnerHTML
{:__html (md->html motd)}}]
[:p

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff