diff --git a/env/dev/clj/youyesyet/core.clj b/env/dev/clj/youyesyet/core.clj index c64c2e7..c9f3446 100644 --- a/env/dev/clj/youyesyet/core.clj +++ b/env/dev/clj/youyesyet/core.clj @@ -1,4 +1,5 @@ -(ns youyesyet.core +(ns ^{:doc "Devalopment launcher, entirely boilerplate from Luminus."} + youyesyet.core (:require [youyesyet.handler :as handler] [luminus.repl-server :as repl] [luminus.http-server :as http] @@ -60,8 +61,8 @@ :else (start-app args))) -(mount/stop) - -(mount/start) +;; (mount/start) +;; (mount/stop) + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..17b97dd --- /dev/null +++ b/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "bower": { + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/bower/-/bower-1.8.4.tgz", + "integrity": "sha1-54dqB23rgTf30GUl3F6MZtuC8oo=" + } + } +} diff --git a/project.clj b/project.clj index 303e26e..2e6879b 100644 --- a/project.clj +++ b/project.clj @@ -51,15 +51,16 @@ :main ^:skip-aot youyesyet.core :migratus {:store :database :db ~(get (System/getenv) "DATABASE_URL")} - :plugins [[lein-cprop "1.0.1"] - [migratus-lein "0.4.2"] - [org.clojars.punkisdead/lein-cucumber "1.0.5"] + :plugins [[lein-bower "0.5.1"] [lein-cljsbuild "1.1.4"] [lein-codox "0.10.3"] - [lein-uberwar "0.2.0"] - [lein-bower "0.5.1"] + [lein-cprop "1.0.1"] [lein-less "1.7.5"] - [lein-codox "0.10.3"]] + [lein-npm "0.6.2"] + [lein-uberwar "0.2.0"] + [migratus-lein "0.4.2"] + [org.clojars.punkisdead/lein-cucumber "1.0.5"] + ] :bower-dependencies [[leaflet "0.7.3"] [jquery "3.3.1"] @@ -73,6 +74,13 @@ :languages [:clojure :clojurescript] :source-paths ["src/clj" "src/cljc" "src/cljs"]} + :npm {:dependencies [[datatables.net "1.10.19"] + [datatables.net-dt "1.10.19"] + [jquery "3.3.1"] + [leaflet "1.3.1"] + [signature_pad "2.3.2"]] + :root "resources/public/js/lib"} + :uberwar {:handler youyesyet.handler/app :init youyesyet.handler/init @@ -80,7 +88,8 @@ :name "youyesyet.war"} :clean-targets ^{:protect false} - [:target-path [:cljsbuild :builds :app :compiler :output-dir] [:cljsbuild :builds :app :compiler :output-to]] + [:target-path [:cljsbuild :builds :app :compiler :output-dir] + [:cljsbuild :builds :app :compiler :output-to]] :figwheel {:http-server-root "public" @@ -93,7 +102,8 @@ {:uberjar {:omit-source true :prep-tasks ["compile" ["cljsbuild" "once" "min"]] :cljsbuild - {:builds + {:prep-tasks [["npm" "install"]] + :builds {:min {:source-paths ["src/cljc" "src/cljs" "env/prod/cljs"] :compiler @@ -129,7 +139,8 @@ [lein-figwheel "0.5.9"] [org.clojure/clojurescript "1.9.495"]] :cljsbuild - {:builds + {:prep-tasks [["npm" "install"]] + :builds {:app {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"] :compiler @@ -140,9 +151,6 @@ :source-map true :optimizations :none :pretty-print true}}}} - - - :doo {:build "test"} :source-paths ["env/dev/clj"] :resource-paths ["env/dev/resources"] @@ -151,7 +159,8 @@ (pjstadig.humane-test-output/activate!)]} :project/test {:resource-paths ["env/test/resources"] :cljsbuild - {:builds + {:prep-tasks [["npm" "install"]] + :builds {:test {:source-paths ["src/cljc" "src/cljs" "test/cljs"] :compiler diff --git a/resources/migrations/20161014170335-basic-setup.down.sql b/resources/migrations/20161014170335-basic-setup.down.sql deleted file mode 100644 index 1005cee..0000000 --- a/resources/migrations/20161014170335-basic-setup.down.sql +++ /dev/null @@ -1,50 +0,0 @@ --------------------------------------------------------------------------------- ----- ----- 20161014170335-basic-setup.down.sql: database schema for youyesyet. ----- ----- This program is free software; you can redistribute it and/or ----- modify it under the terms of the GNU General Public License ----- as published by the Free Software Foundation; either version 2 ----- of the License, or (at your option) any later version. ----- ----- This program is distributed in the hope that it will be useful, ----- but WITHOUT ANY WARRANTY; without even the implied warranty of ----- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ----- GNU General Public License for more details. ----- ----- You should have received a copy of the GNU General Public License ----- along with this program; if not, write to the Free Software ----- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ----- USA. ----- ----- Copyright (C) 2016 Simon Brooke for Radical Independence Campaign ----- --------------------------------------------------------------------------------- - --- intended to reverse out the database changes made in --- 20161014170335-basic-setup.up.sql - -drop table addresses cascade; ---;; -drop table authorities cascade; ---;; -drop table canvassers cascade; ---;; -drop table districts cascade; ---;; -drop table electors cascade; ---;; -drop table followupactions cascade; ---;; -drop table followupmethods cascade; ---;; -drop table followuprequests cascade; ---;; -drop table issueexpertise cascade; ---;; -drop table issues cascade; ---;; -drop table options cascade; ---;; -drop table visits cascade; ---;; diff --git a/resources/migrations/20161014170335-basic-setup.up.sql b/resources/migrations/20161014170335-basic-setup.up.sql deleted file mode 100644 index 4d74c06..0000000 --- a/resources/migrations/20161014170335-basic-setup.up.sql +++ /dev/null @@ -1,669 +0,0 @@ --------------------------------------------------------------------------------- ----- ----- 20161014170335-basic-setup.up.sql: database schema for youyesyet. ----- ----- This program is free software; you can redistribute it and/or ----- modify it under the terms of the GNU General Public License ----- as published by the Free Software Foundation; either version 2 ----- of the License, or (at your option) any later version. ----- ----- This program is distributed in the hope that it will be useful, ----- but WITHOUT ANY WARRANTY; without even the implied warranty of ----- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ----- GNU General Public License for more details. ----- ----- You should have received a copy of the GNU General Public License ----- along with this program; if not, write to the Free Software ----- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ----- USA. ----- ----- Copyright (C) 2016 Simon Brooke for Radical Independence Campaign ----- --------------------------------------------------------------------------------- ----- ----- NOTE ----- This file is essentially a Postgres schema dump of a database schema which was ----- created with the function initdb! in the file src/clj/youyesyet/db/schema.clj. ----- This file has then been mildly massaged to work with Migratus. ----- Either this file or src/clj/youyesyet/db/schema.clj is redundant; schema.clj ----- represents the older, Korma, way of doing things but does not readily allow ----- for migrations; this file represents the newer Migratus/HugSQL way. I'm not ----- certain which of these paths I'm going to go down. ----- --------------------------------------------------------------------------------- - -SET statement_timeout = 0; ---;; -SET lock_timeout = 0; ---;; -SET client_encoding = 'UTF8'; ---;; -SET standard_conforming_strings = on; ---;; -SET check_function_bodies = false; ---;; -SET client_min_messages = warning; ---;; --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: --- - --- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; ---;; - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: --- - --- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; ---;; - -SET search_path = public, pg_catalog; ---;; -SET default_tablespace = ''; ---;; -SET default_with_oids = false; ---;; --- --- Name: addresses; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS addresses ( - id integer NOT NULL, - address character varying(256) NOT NULL, - postcode character varying(16), - phone character varying(16), - district_id integer, - latitude real, - longitude real -); ---;; - -ALTER TABLE public.addresses OWNER TO youyesyet; ---;; --- --- Name: addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: youyesyet --- - -CREATE SEQUENCE addresses_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; ---;; - -ALTER TABLE public.addresses_id_seq OWNER TO youyesyet; ---;; --- --- Name: addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: youyesyet --- - -ALTER SEQUENCE addresses_id_seq OWNED BY addresses.id; ---;; - --- --- Name: authorities; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS authorities ( - id character varying(32) NOT NULL -); ---;; - -ALTER TABLE public.authorities OWNER TO youyesyet; ---;; --- --- Name: canvassers; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS canvassers ( - id serial, - username character varying(32) NOT NULL, - fullname character varying(64) NOT NULL, - elector_id integer, - address_id integer NOT NULL, - phone character varying(16), - email character varying(128), - authority_id character varying(32) NOT NULL, - introduced_by int references canvassers(id), - authorised boolean -); ---;; - -ALTER TABLE public.canvassers OWNER TO youyesyet; ---;; --- --- Name: districts; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS districts ( - id integer NOT NULL, - name character varying(64) NOT NULL -); ---;; - -ALTER TABLE public.districts OWNER TO youyesyet; ---;; --- --- Name: electors; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS electors ( - id integer NOT NULL, - name character varying(64) NOT NULL, - address_id integer NOT NULL, - phone character varying(16), - email character varying(128) -); ---;; - -ALTER TABLE public.electors OWNER TO youyesyet; ---;; --- --- Name: followupactions; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS followupactions ( - id integer NOT NULL, - request_id integer NOT NULL, - actor integer NOT NULL, - date timestamp with time zone DEFAULT now() NOT NULL, - notes text, - closed boolean -); ---;; - -ALTER TABLE public.followupactions OWNER TO youyesyet; - --- --- Name: followupactions_id_seq; Type: SEQUENCE; Schema: public; Owner: youyesyet --- - -CREATE SEQUENCE followupactions_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; ---;; - -ALTER TABLE public.followupactions_id_seq OWNER TO youyesyet; ---;; --- --- Name: followupactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: youyesyet --- - -ALTER SEQUENCE followupactions_id_seq OWNED BY followupactions.id; ---;; - --- --- Name: followupmethods; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS followupmethods ( - id character varying(32) NOT NULL -); ---;; - -ALTER TABLE public.followupmethods OWNER TO youyesyet; ---;; --- --- Name: followuprequests; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -insert into followupmethods values ('Telephone'); ---;; -insert into followupmethods values ('eMail'); ---;; -insert into followupmethods values ('Post'); ---;; - - -CREATE TABLE IF NOT EXISTS followuprequests ( - id integer NOT NULL, - elector_id integer NOT NULL, - visit_id integer NOT NULL, - issue_id character varying(32) NOT NULL, - method_id character varying(32) NOT NULL -); ---;; - -ALTER TABLE public.followuprequests OWNER TO youyesyet; ---;; - --- --- Name: followuprequests_id_seq; Type: SEQUENCE; Schema: public; Owner: youyesyet --- - -CREATE SEQUENCE followuprequests_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; ---;; - - -ALTER TABLE public.followuprequests_id_seq OWNER TO youyesyet; ---;; - --- --- Name: followuprequests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: youyesyet --- - -ALTER SEQUENCE followuprequests_id_seq OWNED BY followuprequests.id; ---;; - - --- --- Name: issueexpertise; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS issueexpertise ( - canvasser_id integer NOT NULL, - issue_id character varying(32) NOT NULL, - method_id character varying(32) NOT NULL -); ---;; - - -ALTER TABLE public.issueexpertise OWNER TO youyesyet; ---;; - --- --- Name: issues; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS issues ( - id character varying(32) NOT NULL, - url character varying(256) -); ---;; - - -ALTER TABLE public.issues OWNER TO youyesyet; ---;; - --- --- Name: options; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS options ( - id character varying(32) NOT NULL -); ---;; - - -ALTER TABLE public.options OWNER TO youyesyet; ---;; - --- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS schema_migrations ( - id bigint NOT NULL -); ---;; - - -ALTER TABLE public.schema_migrations OWNER TO youyesyet; ---;; - --- --- Name: visits; Type: TABLE; Schema: public; Owner: youyesyet; Tablespace: --- - -CREATE TABLE IF NOT EXISTS visits ( - id integer NOT NULL, - address_id integer NOT NULL, - canvasser_id integer NOT NULL, - date timestamp with time zone DEFAULT now() NOT NULL -); ---;; - - -ALTER TABLE public.visits OWNER TO youyesyet; ---;; - --- --- Name: visits_id_seq; Type: SEQUENCE; Schema: public; Owner: youyesyet --- - -CREATE SEQUENCE visits_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; ---;; - - -ALTER TABLE public.visits_id_seq OWNER TO youyesyet; ---;; - --- --- Name: visits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: youyesyet --- - -ALTER SEQUENCE visits_id_seq OWNED BY visits.id; ---;; - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY addresses ALTER COLUMN id SET DEFAULT nextval('addresses_id_seq'::regclass); ---;; - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followupactions ALTER COLUMN id SET DEFAULT nextval('followupactions_id_seq'::regclass); ---;; - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followuprequests ALTER COLUMN id SET DEFAULT nextval('followuprequests_id_seq'::regclass); ---;; - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY visits ALTER COLUMN id SET DEFAULT nextval('visits_id_seq'::regclass); ---;; - - --- --- Name: addresses_address_key; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY addresses - ADD CONSTRAINT addresses_address_key UNIQUE (address); ---;; - - --- --- Name: addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY addresses - ADD CONSTRAINT addresses_pkey PRIMARY KEY (id); ---;; - - --- --- Name: authorities_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY authorities - ADD CONSTRAINT authorities_pkey PRIMARY KEY (id); ---;; - - --- --- Name: canvassers_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY canvassers - ADD CONSTRAINT canvassers_pkey PRIMARY KEY (id); ---;; - - --- --- Name: districts_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY districts - ADD CONSTRAINT districts_pkey PRIMARY KEY (id); ---;; - - --- --- Name: electors_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY electors - ADD CONSTRAINT electors_pkey PRIMARY KEY (id); ---;; - - --- --- Name: followupactions_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY followupactions - ADD CONSTRAINT followupactions_pkey PRIMARY KEY (id); ---;; - - --- --- Name: followupmethods_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY followupmethods - ADD CONSTRAINT followupmethods_pkey PRIMARY KEY (id); ---;; - - --- --- Name: followuprequests_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY followuprequests - ADD CONSTRAINT followuprequests_pkey PRIMARY KEY (id); ---;; - - --- --- Name: issues_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY issues - ADD CONSTRAINT issues_pkey PRIMARY KEY (id); ---;; - - --- --- Name: options_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY options - ADD CONSTRAINT options_pkey PRIMARY KEY (id); ---;; - - --- --- Name: schema_migrations_id_key; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - ---ALTER TABLE ONLY schema_migrations --- ADD CONSTRAINT schema_migrations_id_key UNIQUE (id); ---;; - - --- --- Name: visits_pkey; Type: CONSTRAINT; Schema: public; Owner: youyesyet; Tablespace: --- - -ALTER TABLE ONLY visits - ADD CONSTRAINT visits_pkey PRIMARY KEY (id); ---;; - - --- --- Name: addresses_district_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY addresses - ADD CONSTRAINT addresses_district_id_fkey FOREIGN KEY (district_id) REFERENCES districts(id); ---;; - - --- --- Name: canvassers_address_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY canvassers - ADD CONSTRAINT canvassers_address_id_fkey FOREIGN KEY (address_id) REFERENCES addresses(id); ---;; - - --- --- Name: canvassers_authority_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY canvassers - ADD CONSTRAINT canvassers_authority_id_fkey FOREIGN KEY (authority_id) REFERENCES authorities(id); ---;; - - --- --- Name: canvassers_elector_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY canvassers - ADD CONSTRAINT canvassers_elector_id_fkey FOREIGN KEY (elector_id) REFERENCES electors(id); ---;; - -create unique index canvassers_username_ix on canvassers (username); -create unique index canvassers_email_ix on canvassers(email); - --- --- Name: electors_address_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY electors - ADD CONSTRAINT electors_address_id_fkey FOREIGN KEY (address_id) REFERENCES addresses(id); ---;; - - --- --- Name: followupactions_actor_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followupactions - ADD CONSTRAINT followupactions_actor_fkey FOREIGN KEY (actor) REFERENCES canvassers(id); ---;; - - --- --- Name: followupactions_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followupactions - ADD CONSTRAINT followupactions_request_id_fkey FOREIGN KEY (request_id) REFERENCES followuprequests(id); ---;; - - --- --- Name: followuprequests_elector_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followuprequests - ADD CONSTRAINT followuprequests_elector_id_fkey FOREIGN KEY (elector_id) REFERENCES electors(id); ---;; - - --- --- Name: followuprequests_issue_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followuprequests - ADD CONSTRAINT followuprequests_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id); ---;; - - --- --- Name: followuprequests_method_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followuprequests - ADD CONSTRAINT followuprequests_method_id_fkey FOREIGN KEY (method_id) REFERENCES followupmethods(id); ---;; - - --- --- Name: followuprequests_visit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY followuprequests - ADD CONSTRAINT followuprequests_visit_id_fkey FOREIGN KEY (visit_id) REFERENCES visits(id); ---;; - - --- --- Name: issueexpertise_canvasser_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY issueexpertise - ADD CONSTRAINT issueexpertise_canvasser_id_fkey FOREIGN KEY (canvasser_id) REFERENCES canvassers(id); ---;; - - --- --- Name: issueexpertise_issue_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY issueexpertise - ADD CONSTRAINT issueexpertise_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id); ---;; - - --- --- Name: issueexpertise_method_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY issueexpertise - ADD CONSTRAINT issueexpertise_method_id_fkey FOREIGN KEY (method_id) REFERENCES followupmethods(id); ---;; - - --- --- Name: visits_address_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY visits - ADD CONSTRAINT visits_address_id_fkey FOREIGN KEY (address_id) REFERENCES addresses(id); ---;; - - --- --- Name: visits_canvasser_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: youyesyet --- - -ALTER TABLE ONLY visits - ADD CONSTRAINT visits_canvasser_id_fkey FOREIGN KEY (canvasser_id) REFERENCES canvassers(id); ---;; - - --- --- Name: public; Type: ACL; Schema: -; Owner: postgres --- - -REVOKE ALL ON SCHEMA public FROM PUBLIC; ---;; - -REVOKE ALL ON SCHEMA public FROM postgres; ---;; - -GRANT ALL ON SCHEMA public TO postgres; ---;; - -GRANT ALL ON SCHEMA public TO PUBLIC; ---;; - - --- --- PostgreSQL database dump complete --- - diff --git a/resources/migrations/20170315190500-roles-and-teams.down.sql b/resources/migrations/20170315190500-roles-and-teams.down.sql deleted file mode 100644 index a8bdb6a..0000000 --- a/resources/migrations/20170315190500-roles-and-teams.down.sql +++ /dev/null @@ -1,13 +0,0 @@ -drop table teammemberships; - -drop table teamorganiserships; - -drop index ix_teams_name; - -drop table teams; - -drop table rolememberships; - -drop index ix_roles_name; - -drop table roles; diff --git a/resources/migrations/20170315190500-roles-and-teams.up.sql b/resources/migrations/20170315190500-roles-and-teams.up.sql deleted file mode 100644 index 7ff7ffc..0000000 --- a/resources/migrations/20170315190500-roles-and-teams.up.sql +++ /dev/null @@ -1,39 +0,0 @@ -create table if not exists roles ( - id serial primary key, - name varchar(64) not null -); - -create unique index ix_roles_name on roles(name); - -create table if not exists rolememberships ( - role_id integer not null references roles(id), - canvasser_id integer not null references canvassers(id) -); - -create table if not exists teams ( - id serial primary key, - name varchar(64) not null, - district_id integer not null references districts(id), - latitude real, - longitude real -); - -create unique index ix_teams_name on teams(name); - -create table if not exists teammemberships ( - team_id integer not null references teams(id), - canvasser_id integer not null references canvassers(id) -); - -create table if not exists teamorganiserships ( - team_id integer not null references teams(id), - canvasser_id integer not null references canvassers(id) -); - -alter table roles owner to youyesyet; - -alter table rolememberships owner to youyesyet; - -alter table teams owner to youyesyet; - -alter table teammemberships owner to youyesyet; diff --git a/resources/migrations/20170401115900-basic-reference-data.down.sql b/resources/migrations/20170401115900-basic-reference-data.down.sql deleted file mode 100644 index a0b3aa1..0000000 --- a/resources/migrations/20170401115900-basic-reference-data.down.sql +++ /dev/null @@ -1,17 +0,0 @@ --- this is just a teardown of everything set up in the corresponding .up.sql file - -delete from roles where name = 'Expert'; -delete from roles where name = 'Administrator'; -delete from roles where name = 'Recruiter'; -delete from roles where name = 'Organiser'; -delete from roles where name = 'Editor'; - -alter table issues drop column content; -alter table issues drop column current; - -delete from issues where id = 'Currency'; -delete from issues where id = 'Monarchy'; -delete from issues where id = 'Defence'; - -delete from options where id = 'Yes'; -delete from options where id = 'No'; diff --git a/resources/migrations/20170401115900-basic-reference-data.up.sql b/resources/migrations/20170401115900-basic-reference-data.up.sql deleted file mode 100644 index 26d3bf1..0000000 --- a/resources/migrations/20170401115900-basic-reference-data.up.sql +++ /dev/null @@ -1,58 +0,0 @@ - --- We don't explicitly instantiate the 'Canvasser' role since every user is --- deemed to be a canvasser. - - --- an 'Expert' is someone with expertise in one or more issues, who is --- trusted to discuss those issues in detail with electors. -insert into roles (name) values ('Expert'); - - --- an 'Administrator' is someone entitled to broadly alter reference data --- throughout the system. -insert into roles (name) values ('Administrator'); - - --- a 'Recruiter' is someone entitled to invite other people to become users --- ('Canvassers'). A Recruiter is entitled to lock the account of anyone they --- have recruited, recursively. -insert into roles (name) values ('Recruiter'); - - --- an 'Organiser' is someone who organises one or more local teams. An Organiser --- is entitled to exclude any Canvasser from any team they organise. -insert into roles (name) values ('Organiser'); - - --- an 'Editor' is someone entitled to add and edit issues. -insert into roles (name) values ('Editor'); - --- issue text is local; there may still in addition be a further link to more --- information, but the basic issue text should be part of the issue record. --- The text should fit on a phone screen without scrolling, so is reasonably --- short. -alter table issues add column content varchar(1024); - --- an issue may be current or not current; when not current it is not deleted --- from the system but kept because it may become current again later. Only --- current issues are shown in the app. Typically not fewer than three and not --- more than about seven issues should be current at any time. -alter table issues add column current boolean default false; - -insert into issues (id, content, current) values ('Currency', - 'Scotland could keep the Pound, or use the Euro. But we could also set up a new currency of our own.', - true); - -insert into issues (id, content, current) values ('Monarchy', - 'Scotland could keep the Queen. This is an issue to be decided after independence.', - true); - -insert into issues (id, content, current) values ('Defence', - 'Scotland will not have nuclear weapons, and will probably not choose to engage in far-off wars. But we could remain members of NATO.', - true); - - -insert into options (id) values ('Yes'); - -insert into options (id) values ('No'); - diff --git a/resources/migrations/20170415102900-core-views.down.sql b/resources/migrations/20170415102900-core-views.down.sql deleted file mode 100644 index c576947..0000000 --- a/resources/migrations/20170415102900-core-views.down.sql +++ /dev/null @@ -1,11 +0,0 @@ -drop view if exists roles_by_canvasser; - -drop view if exists teams_by_canvasser; - -drop view if exists canvassers_by_team; - -drop view if exists canvassers_by_introducer; - -drop view if exists teams_by_organiser; - -drop view if exists organisers_by_team; diff --git a/resources/migrations/20170415102900-core-views.up.sql b/resources/migrations/20170415102900-core-views.up.sql deleted file mode 100644 index 53346a6..0000000 --- a/resources/migrations/20170415102900-core-views.up.sql +++ /dev/null @@ -1,59 +0,0 @@ - -create view roles_by_canvasser as - select canvassers.id as canvasser, roles.name - from roles, rolememberships, canvassers - where roles.id = rolememberships.role_id - and canvassers.id = rolememberships.canvasser_id - and canvassers.authorised = true; - -create view teams_by_canvasser as - select canvassers.id as canvasser, teams.id, teams.name, teams.latitude, teams.longitude - from teams, teammemberships, canvassers - where teams.id = teammemberships.team_id - and canvassers.id = teammemberships.canvasser_id; - -create view canvassers_by_team as - select teams.id as team, - canvassers.id, - canvassers.username, - canvassers.fullname, - canvassers.email, - canvassers.phone - from teams, teammemberships, canvassers - where teams.id = teammemberships.team_id - and canvassers.id = teammemberships.canvasser_id - and canvassers.authorised = true; - -create view canvassers_by_introducer as - select introducers.id as introducer, - canvassers.id as canvasser, - canvassers.username, - canvassers.fullname, - canvassers.email, - canvassers.phone, - canvassers.authorised - from canvassers, canvassers as introducers - where introducers.id = canvassers.introduced_by; - -create view teams_by_organiser as - select canvassers.id as organiser, - teams.id, - teams.name, - teams.latitude, - teams.longitude - from teams, teamorganiserships, canvassers - where teams.id = teamorganiserships.team_id - and canvassers.id = teamorganiserships.canvasser_id - and canvassers.authorised = true; - -create view organisers_by_team as - select teams.id as team, - canvassers.id, - canvassers.username, - canvassers.fullname, - canvassers.email, - canvassers.phone - from teams, teamorganiserships, canvassers - where teams.id = teamorganiserships.team_id - and canvassers.id = teamorganiserships.canvasser_id - and canvassers.authorised = true; diff --git a/resources/migrations/20170721084900-dwellings.down.sql b/resources/migrations/20170721084900-dwellings.down.sql deleted file mode 100644 index 674fb1b..0000000 --- a/resources/migrations/20170721084900-dwellings.down.sql +++ /dev/null @@ -1,69 +0,0 @@ --------------------------------------------------------------------------------- ----- ----- 20170721084900.up.sql: add dwellings table, to deal with flatted addresses. ----- ----- This program is free software; you can redistribute it and/or ----- modify it under the terms of the GNU General Public License ----- as published by the Free Software Foundation; either version 2 ----- of the License, or (at your option) any later version. ----- ----- This program is distributed in the hope that it will be useful, ----- but WITHOUT ANY WARRANTY; without even the implied warranty of ----- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ----- GNU General Public License for more details. ----- ----- You should have received a copy of the GNU General Public License ----- along with this program; if not, write to the Free Software ----- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ----- USA. ----- ----- Copyright (C) 2017 Simon Brooke for Radical Independence Campaign ----- --------------------------------------------------------------------------------- ----- ----- NOTE ----- This file is essentially a Postgres schema dump of a database schema which was ----- created with the function initdb! in the file src/clj/youyesyet/db/schema.clj. ----- This file has then been mildly massaged to work with Migratus. ----- Either this file or src/clj/youyesyet/db/schema.clj is redundant; schema.clj ----- represents the older, Korma, way of doing things but does not readily allow ----- for migrations; this file represents the newer Migratus/HugSQL way. I'm not ----- certain which of these paths I'm going to go down. ----- --------------------------------------------------------------------------------- - -alter table canvassers add column address_id integer references addresses(id); ---;; -alter table electors add column address_id integer references addresses(id); ---;; -alter table visits add column address_id integer references addresses(id); ---;; - -update canvassers set address_id = - (select address_id from dwellings where id = canvassers.dwelling_id); ---;; - -update electors set address_id = - (select address_id from dwellings where id = electors.dwelling_id); ---;; - -update visits set address_id = - (select address_id from dwellings where id = visits.dwelling_id); ---;; - -alter table canvassers alter column address_id set not null; ---;; -alter table electors alter column address_id set not null; ---;; -alter table visits alter column address_id set not null; ---;; - -alter table canvassers drop column dwelling_id; ---;; -alter table electors drop column dwelling_id; ---;; -alter table visits drop column dwelling_id; ---;; - -drop table if exists dwellings; ---;; diff --git a/resources/migrations/20170721084900-dwellings.up.sql b/resources/migrations/20170721084900-dwellings.up.sql deleted file mode 100644 index 74e6a27..0000000 --- a/resources/migrations/20170721084900-dwellings.up.sql +++ /dev/null @@ -1,87 +0,0 @@ --------------------------------------------------------------------------------- ----- ----- 20170721084900.up.sql: add dwellings table, to deal with flatted addresses. ----- ----- This program is free software; you can redistribute it and/or ----- modify it under the terms of the GNU General Public License ----- as published by the Free Software Foundation; either version 2 ----- of the License, or (at your option) any later version. ----- ----- This program is distributed in the hope that it will be useful, ----- but WITHOUT ANY WARRANTY; without even the implied warranty of ----- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ----- GNU General Public License for more details. ----- ----- You should have received a copy of the GNU General Public License ----- along with this program; if not, write to the Free Software ----- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ----- USA. ----- ----- Copyright (C) 2017 Simon Brooke for Radical Independence Campaign ----- --------------------------------------------------------------------------------- ----- ----- NOTE ----- This file is essentially a Postgres schema dump of a database schema which was ----- created with the function initdb! in the file src/clj/youyesyet/db/schema.clj. ----- This file has then been mildly massaged to work with Migratus. ----- Either this file or src/clj/youyesyet/db/schema.clj is redundant; schema.clj ----- represents the older, Korma, way of doing things but does not readily allow ----- for migrations; this file represents the newer Migratus/HugSQL way. I'm not ----- certain which of these paths I'm going to go down. ----- --------------------------------------------------------------------------------- - -CREATE TABLE IF NOT EXISTS dwellings ( - id serial NOT NULL primary key, - address_id integer NOT NULL references addresses(id), - sub_address varchar(16) -); ---;; - -ALTER TABLE public.dwellings OWNER TO youyesyet; ---;; - -INSERT INTO dwellings (address_id, sub_address) - SELECT DISTINCT id, '' FROM addresses; ---;; - -alter table canvassers add column dwelling_id integer references dwellings(id); ---;; -alter table electors add column dwelling_id integer references dwellings(id); ---;; -alter table visits add column dwelling_id integer references dwellings(id); ---;; - -update canvassers set dwelling_id = - (select id from dwellings where address_id = canvassers.address_id); ---;; - -update electors set dwelling_id = - (select id from dwellings where address_id = electors.address_id); ---;; - -update visits set dwelling_id = - (select id from dwellings where address_id = visits.address_id); ---;; - -alter table canvassers alter column dwelling_id set not null; ---;; -alter table electors alter column dwelling_id set not null; ---;; -alter table visits alter column dwelling_id set not null; ---;; - -alter table canvassers drop constraint canvassers_address_id_fkey; ---;; -alter table electors drop constraint electors_address_id_fkey; ---;; -alter table visits drop constraint visits_address_id_fkey; ---;; - -alter table canvassers drop column address_id; ---;; -alter table electors drop column address_id; ---;; -alter table visits drop column address_id; ---;; diff --git a/resources/migrations/20180316110100-intentions-and-options.down.sql b/resources/migrations/20180316110100-intentions-and-options.down.sql deleted file mode 100644 index 84c98b8..0000000 --- a/resources/migrations/20180316110100-intentions-and-options.down.sql +++ /dev/null @@ -1,24 +0,0 @@ --------------------------------------------------------------------------------- ----- ----- 20180316110100intentions-and-options.down.sql: remove intentions and options ----- ----- This program is free software; you can redistribute it and/or ----- modify it under the terms of the GNU General Public License ----- as published by the Free Software Foundation; either version 2 ----- of the License, or (at your option) any later version. ----- ----- This program is distributed in the hope that it will be useful, ----- but WITHOUT ANY WARRANTY; without even the implied warranty of ----- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ----- GNU General Public License for more details. ----- ----- You should have received a copy of the GNU General Public License ----- along with this program; if not, write to the Free Software ----- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ----- USA. ----- ----- Copyright (C) 2016 Simon Brooke for Radical Independence Campaign ----- --------------------------------------------------------------------------------- - -drop table intentions; diff --git a/resources/migrations/20180316110100-intentions-and-options.up.sql b/resources/migrations/20180316110100-intentions-and-options.up.sql deleted file mode 100644 index 0736740..0000000 --- a/resources/migrations/20180316110100-intentions-and-options.up.sql +++ /dev/null @@ -1,30 +0,0 @@ --------------------------------------------------------------------------------- ----- ----- 20180316110100intentions-and-options.up.sql: add intentions and options ----- ----- This program is free software; you can redistribute it and/or ----- modify it under the terms of the GNU General Public License ----- as published by the Free Software Foundation; either version 2 ----- of the License, or (at your option) any later version. ----- ----- This program is distributed in the hope that it will be useful, ----- but WITHOUT ANY WARRANTY; without even the implied warranty of ----- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ----- GNU General Public License for more details. ----- ----- You should have received a copy of the GNU General Public License ----- along with this program; if not, write to the Free Software ----- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ----- USA. ----- ----- Copyright (C) 2016 Simon Brooke for Radical Independence Campaign ----- --------------------------------------------------------------------------------- - -CREATE TABLE IF NOT EXISTS intentions ( - visit_id int not null references visits(id) on delete no action, - elector_id int not null references electors(id) on delete no action, - option_id varchar(32) not null references options(id) on delete no action - ); - -ALTER TABLE intentions owner to youyesyet; diff --git a/resources/migrations/20180317170000-gender.down.sql b/resources/migrations/20180317170000-gender.down.sql deleted file mode 100644 index 5eac53a..0000000 --- a/resources/migrations/20180317170000-gender.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table electors drop column gender; - -drop table genders; diff --git a/resources/migrations/20180317170000-gender.up.sql b/resources/migrations/20180317170000-gender.up.sql deleted file mode 100644 index 9512ea2..0000000 --- a/resources/migrations/20180317170000-gender.up.sql +++ /dev/null @@ -1,11 +0,0 @@ -create table genders ( - id varchar(32) not null primary key -); - --- genders is reference data -insert into genders values ('Female'); -insert into genders values ('Male'); -insert into genders values ('Non-binary'); -insert into genders values ('Unknown'); - -alter table electors add column gender varchar(32) references genders(id) default 'Unknown'; diff --git a/resources/migrations/20180317170907-reference-data.down.sql b/resources/migrations/20180317170907-reference-data.down.sql deleted file mode 100644 index ed67940..0000000 --- a/resources/migrations/20180317170907-reference-data.down.sql +++ /dev/null @@ -1,10 +0,0 @@ -delete from options where id = 'Yes'; - -delete from options where id = 'No'; - -delete from issues where id = 'Currency'; - -delete from issues where id = 'Monarchy'; - -delete from issues where id = 'Defence'; - diff --git a/resources/migrations/20180317170907-reference-data.up.sql b/resources/migrations/20180317170907-reference-data.up.sql deleted file mode 100644 index ed1dfa4..0000000 --- a/resources/migrations/20180317170907-reference-data.up.sql +++ /dev/null @@ -1,18 +0,0 @@ -insert into options values ('Yes'); - -insert into options values ('No'); - - -insert into issues (id, url) values ('Currency', 'https://www.yyy.scot/wiki/issues/Currency'); - -insert into issues (id, url) values ('Monarchy', 'https://www.yyy.scot/wiki/issues/Monarchy'); - -insert into issues (id, url) values ('Defence', 'https://www.yyy.scot/wiki/issues/Defence'); - -insert into genders (id ) values ('Female'); - -insert into genders (id ) values ('Male'); - -insert into genders (id ) values ('Non-binary'); - -insert into genders (id ) values ('Unknown'); diff --git a/resources/migrations/20180317175047-test-data.down.sql b/resources/migrations/20180317175047-test-data.down.sql deleted file mode 100644 index 4a5583c..0000000 --- a/resources/migrations/20180317175047-test-data.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -delete from addresses where id < = 4; - -delete from electors where id <= 10; diff --git a/resources/migrations/20180317175047-test-data.up.sql b/resources/migrations/20180317175047-test-data.up.sql deleted file mode 100644 index 0cc4b20..0000000 --- a/resources/migrations/20180317175047-test-data.up.sql +++ /dev/null @@ -1,41 +0,0 @@ -insert into addresses (id, address, postcode, latitude, longitude) -values (1, '13 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.8253043, -4.2569057); - -insert into addresses (id, address, postcode, latitude, longitude) -values (2, '15 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.8252354, -4.2572778); - -insert into addresses (id, address, postcode, latitude, longitude) -values (3, '17 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.825166, -4.257026); - -insert into addresses (id, address, postcode, latitude, longitude) -values (4, '19 Imaginary Terrace, IM1 3TE', 'IM1 3TE', 55.8250695, -4.2570239); - -insert into electors (id, name, address_id, gender) -values (1, 'Alan Anderson', 1, 'Male'); - -insert into electors (id, name, address_id, gender) -values (2, 'Ann Anderson', 1, 'Female'); - -insert into electors (id, name, address_id, gender) -values (3, 'Alex Anderson', 1, 'Non-binary'); - -insert into electors (id, name, address_id) -values (4, 'Andy Anderson', 1); - -insert into electors (id, name, address_id, gender) -values (5, 'Beryl Brown', 2, 'Female'); - -insert into electors (id, name, address_id, gender) -values (6, 'Betty Black', 2, 'Female'); - -insert into electors (id, name, address_id, gender) -values (7, 'Catriona Crathie', 3, 'Female'); - -insert into electors (id, name, address_id, gender) -values (8, 'Colin Caruthers', 3, 'Male'); - -insert into electors (id, name, address_id, gender) -values (9, 'Calum Crathie', 3, 'Unknown'); - -insert into electors (id, name, address_id, gender) -values (10, 'David Dewar', 4, 'Male'); diff --git a/resources/migrations/20180408124500-reference-data.down.sql b/resources/migrations/20180408124500-reference-data.down.sql deleted file mode 100644 index 68bada9..0000000 --- a/resources/migrations/20180408124500-reference-data.down.sql +++ /dev/null @@ -1 +0,0 @@ -alter table issues drop column current; diff --git a/resources/migrations/20180408124500-reference-data.up.sql b/resources/migrations/20180408124500-reference-data.up.sql deleted file mode 100644 index aaae234..0000000 --- a/resources/migrations/20180408124500-reference-data.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table issues add column current boolean default true; - diff --git a/resources/migrations/20180526162051-dwellings.down.sql b/resources/migrations/20180526162051-dwellings.down.sql deleted file mode 100644 index ab91769..0000000 --- a/resources/migrations/20180526162051-dwellings.down.sql +++ /dev/null @@ -1,8 +0,0 @@ -alter table electors - add column address_id references addresses on delete no action; - -update electors - set address_id = - (select address_id - from dwellings - where dwellings.id electors.dwelling_id); diff --git a/resources/migrations/20180526162051-dwellings.up.sql b/resources/migrations/20180526162051-dwellings.up.sql deleted file mode 100644 index 41e1a6e..0000000 --- a/resources/migrations/20180526162051-dwellings.up.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE dwellings -( - id INT NOT NULL PRIMARY KEY, - address_id INT NOT NULL references addresses on delete no action, - sub_address VARCHAR( 32) -); - -alter table electors - add column dwelling_id int references dwellings on delete no action; - -alter table electors drop column address_id; diff --git a/resources/migrations/20180611204244-bootstrap.down.sql b/resources/migrations/20180611204244-bootstrap.down.sql deleted file mode 100644 index e69de29..0000000 diff --git a/resources/migrations/20180611204244-bootstrap.up.sql b/resources/migrations/20180611204244-bootstrap.up.sql deleted file mode 100644 index d0377ad..0000000 --- a/resources/migrations/20180611204244-bootstrap.up.sql +++ /dev/null @@ -1,15 +0,0 @@ --- enough data to get the system working and real logins - -insert into addresses (address, postcode, latitude, longitude) -values ('West Croft, Standingstone, Auchencairn', 'DG7 1RF', 54.822389, -3.920265); - -insert into dwellings (id, address_id, sub_address) -values (5, 5, ''); - -insert into electors (name, dwelling_id, gender) -values ('Simon Brooke', 1, 'Male'); - -insert into authorities (id) values ('GitHub'); - -insert into canvassers (username, fullname, elector_id, address_id, authority_id, authorised) -values ('simon_brooke', 'Simon Brooke', 2, 2, 'GitHub', true); diff --git a/resources/templates/app.html b/resources/templates/app.html index 7b181ca..4b14abe 100644 --- a/resources/templates/app.html +++ b/resources/templates/app.html @@ -23,13 +23,22 @@
{% endblock %} +{% block extra-script %} + var user = { + "username": "{{user.username}}", + "fullname": "{{user.fullname}}", + "id": {{user.id|default:-1}}, + "authorised": {{user.authorised|default:false}} + }; +{% endblock %} {% block extra-tail %} -{% script "js/lib/leaflet/dist/leaflet.js" %} +{% script "js/lib/node_modules/signature_pad/dist/signature_pad.min.js" %} +{% script "js/lib/node_modules/leaflet/dist/leaflet.js" %} {% script "/js/app.js" %} {% endblock %} diff --git a/resources/templates/base.html b/resources/templates/base.html index 93c779c..317fc4f 100644 --- a/resources/templates/base.html +++ b/resources/templates/base.html @@ -10,7 +10,6 @@