From 706e42f4833574e5554fc7af0261920cfaa71f1f Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 11 Jun 2018 21:49:16 +0100 Subject: [PATCH] More work, some progress made. --- .../20180611204244-bootstrap.down.sql | 0 .../20180611204244-bootstrap.up.sql | 15 +++++ resources/sql/queries.auto.sql | 14 ++-- .../templates/auto/application-index.html | 64 +++++++++---------- .../auto/form-addresses-Address.html | 64 +++++++++---------- .../auto/form-canvassers-Canvasser.html | 64 +++++++++---------- .../auto/form-districts-District.html | 64 +++++++++---------- .../auto/form-dwellings-Dwelling.html | 64 +++++++++---------- .../templates/auto/form-electors-Elector.html | 64 +++++++++---------- .../form-followupactions-Followupaction.html | 64 +++++++++---------- .../templates/auto/form-issues-Issue.html | 64 +++++++++---------- resources/templates/auto/form-roles-Role.html | 64 +++++++++---------- resources/templates/auto/form-teams-Team.html | 64 +++++++++---------- .../templates/auto/form-visits-Visit.html | 64 +++++++++---------- .../auto/list-addresses-Addresses.html | 64 +++++++++---------- .../auto/list-canvassers-Canvassers.html | 64 +++++++++---------- .../auto/list-districts-Districts.html | 64 +++++++++---------- .../auto/list-dwellings-Dwellings.html | 64 +++++++++---------- .../auto/list-electors-Electors.html | 64 +++++++++---------- .../list-followupactions-Followupactions.html | 64 +++++++++---------- .../templates/auto/list-issues-Issues.html | 64 +++++++++---------- .../templates/auto/list-roles-Roles.html | 64 +++++++++---------- .../templates/auto/list-teams-Teams.html | 64 +++++++++---------- .../templates/auto/list-visits-Visits.html | 64 +++++++++---------- ...ed copy.html => base-unauthenticated.html} | 40 +++--------- resources/templates/base.html | 41 +++++++++--- resources/templates/login.html | 3 +- src/clj/youyesyet/handler.clj | 3 + src/clj/youyesyet/routes/home.clj | 8 ++- youyesyet.adl.xml | 42 ++++++------ youyesyet.canonical.adl.xml | 42 ++++++------ 31 files changed, 789 insertions(+), 763 deletions(-) create mode 100644 resources/migrations/20180611204244-bootstrap.down.sql create mode 100644 resources/migrations/20180611204244-bootstrap.up.sql rename resources/templates/{base-authenticated copy.html => base-unauthenticated.html} (66%) diff --git a/resources/migrations/20180611204244-bootstrap.down.sql b/resources/migrations/20180611204244-bootstrap.down.sql new file mode 100644 index 0000000..e69de29 diff --git a/resources/migrations/20180611204244-bootstrap.up.sql b/resources/migrations/20180611204244-bootstrap.up.sql new file mode 100644 index 0000000..c63cfe3 --- /dev/null +++ b/resources/migrations/20180611204244-bootstrap.up.sql @@ -0,0 +1,15 @@ +-- enough data to get the system working and real logins + +insert into addresses (id, address, postcode, latitude, longitude) +values (5, 'West Croft, Standingstone, Auchencairn', 'DG7 1RF', 54.822389, -3.920265); + +insert into dwellings (id, address_id, sub_address) +values (5, 5, ''); + +insert into electors (id, name, dwelling_id, gender) +values (11, 'Simon Brooke', 5, 'Male'); + +insert into authorities (id) values ('GitHub'); + +insert into canvassers (username, fullname, elector_id, address_id, authority_id, authorised) +values ('simon_brooke', 'Simon Brooke', 11, 5, 'GitHub', true); diff --git a/resources/sql/queries.auto.sql b/resources/sql/queries.auto.sql index 16e3b9f..63625ad 100644 --- a/resources/sql/queries.auto.sql +++ b/resources/sql/queries.auto.sql @@ -1,6 +1,6 @@ -- File queries.sql -- autogenerated by adl.to-hugsql-queries at --- 2018-06-11T15:50:04.238Z +-- 2018-06-11T20:39:10.396Z -- See [Application Description Language](https://github.com/simon-brooke/adl). @@ -494,8 +494,8 @@ ORDER BY canvassers.username, -- :name list-canvassers-by-role :? :* -- :doc links all existing canvasser records related to a given role SELECT * -FROM canvassers -WHERE canvassers.roles = link_canvassers_.canvasser_id +FROM canvassers, link_canvassers_ +WHERE canvassers.id = link_canvassers_.canvasser_id AND link_canvassers_.role_id = :id ORDER BY canvassers.username, canvassers.fullname, @@ -701,8 +701,8 @@ ORDER BY roles.name, -- :name list-roles-by-canvasser :? :* -- :doc links all existing role records related to a given canvasser SELECT * -FROM roles -WHERE roles.members = link_roles_canvassers.role_id +FROM roles, link_roles_canvassers +WHERE roles.id = link_roles_canvassers.role_id AND link_roles_canvassers.canvasser_id = :id ORDER BY roles.name, roles.id @@ -754,8 +754,8 @@ ORDER BY teams.name, -- :name list-teams-by-canvasser :? :* -- :doc links all existing team records related to a given canvasser SELECT * -FROM teams -WHERE teams.members = link_teams_canvassers.team_id +FROM teams, link_teams_canvassers +WHERE teams.id = link_teams_canvassers.team_id AND link_teams_canvassers.canvasser_id = :id ORDER BY teams.name, teams.id diff --git a/resources/templates/auto/application-index.html b/resources/templates/auto/application-index.html index 6311cdf..3ebe8f0 100644 --- a/resources/templates/auto/application-index.html +++ b/resources/templates/auto/application-index.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -220,49 +220,49 @@ Followupmethod {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-addresses-Address.html b/resources/templates/auto/form-addresses-Address.html index 3fbf3ab..30af8fe 100644 --- a/resources/templates/auto/form-addresses-Address.html +++ b/resources/templates/auto/form-addresses-Address.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -248,49 +248,49 @@ To delete this addresses record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-canvassers-Canvasser.html b/resources/templates/auto/form-canvassers-Canvasser.html index 8a975b9..2df601e 100644 --- a/resources/templates/auto/form-canvassers-Canvasser.html +++ b/resources/templates/auto/form-canvassers-Canvasser.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -343,49 +343,49 @@ To delete this canvassers record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-districts-District.html b/resources/templates/auto/form-districts-District.html index 6755daa..108288b 100644 --- a/resources/templates/auto/form-districts-District.html +++ b/resources/templates/auto/form-districts-District.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -98,49 +98,49 @@ To delete this districts record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-dwellings-Dwelling.html b/resources/templates/auto/form-dwellings-Dwelling.html index ab82225..15462c1 100644 --- a/resources/templates/auto/form-dwellings-Dwelling.html +++ b/resources/templates/auto/form-dwellings-Dwelling.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -136,49 +136,49 @@ To delete this dwellings record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-electors-Elector.html b/resources/templates/auto/form-electors-Elector.html index 099cd53..c696650 100644 --- a/resources/templates/auto/form-electors-Elector.html +++ b/resources/templates/auto/form-electors-Elector.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -228,49 +228,49 @@ To delete this electors record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-followupactions-Followupaction.html b/resources/templates/auto/form-followupactions-Followupaction.html index a82cce8..b7b3e1d 100644 --- a/resources/templates/auto/form-followupactions-Followupaction.html +++ b/resources/templates/auto/form-followupactions-Followupaction.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -230,49 +230,49 @@ To delete this followupactions record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-issues-Issue.html b/resources/templates/auto/form-issues-Issue.html index 1a33953..c496dcd 100644 --- a/resources/templates/auto/form-issues-Issue.html +++ b/resources/templates/auto/form-issues-Issue.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -139,49 +139,49 @@ To delete this issues record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-roles-Role.html b/resources/templates/auto/form-roles-Role.html index 1d20938..2215d29 100644 --- a/resources/templates/auto/form-roles-Role.html +++ b/resources/templates/auto/form-roles-Role.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -117,49 +117,49 @@ To delete this roles record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-teams-Team.html b/resources/templates/auto/form-teams-Team.html index e08105f..17a7abf 100644 --- a/resources/templates/auto/form-teams-Team.html +++ b/resources/templates/auto/form-teams-Team.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -211,49 +211,49 @@ To delete this teams record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/form-visits-Visit.html b/resources/templates/auto/form-visits-Visit.html index 2c1ea30..eea048a 100644 --- a/resources/templates/auto/form-visits-Visit.html +++ b/resources/templates/auto/form-visits-Visit.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -174,49 +174,49 @@ To delete this visits record {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-addresses-Addresses.html b/resources/templates/auto/list-addresses-Addresses.html index 70aa63e..67f54be 100644 --- a/resources/templates/auto/list-addresses-Addresses.html +++ b/resources/templates/auto/list-addresses-Addresses.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -124,49 +124,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-canvassers-Canvassers.html b/resources/templates/auto/list-canvassers-Canvassers.html index 98c8b4a..3208f2c 100644 --- a/resources/templates/auto/list-canvassers-Canvassers.html +++ b/resources/templates/auto/list-canvassers-Canvassers.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -142,49 +142,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-districts-Districts.html b/resources/templates/auto/list-districts-Districts.html index 3349092..f7ba9a6 100644 --- a/resources/templates/auto/list-districts-Districts.html +++ b/resources/templates/auto/list-districts-Districts.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -79,49 +79,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-dwellings-Dwellings.html b/resources/templates/auto/list-dwellings-Dwellings.html index 7f39626..308fa23 100644 --- a/resources/templates/auto/list-dwellings-Dwellings.html +++ b/resources/templates/auto/list-dwellings-Dwellings.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -88,49 +88,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-electors-Electors.html b/resources/templates/auto/list-electors-Electors.html index da7d082..0a512bf 100644 --- a/resources/templates/auto/list-electors-Electors.html +++ b/resources/templates/auto/list-electors-Electors.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -115,49 +115,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-followupactions-Followupactions.html b/resources/templates/auto/list-followupactions-Followupactions.html index 6c587e6..bd336e9 100644 --- a/resources/templates/auto/list-followupactions-Followupactions.html +++ b/resources/templates/auto/list-followupactions-Followupactions.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -115,49 +115,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-issues-Issues.html b/resources/templates/auto/list-issues-Issues.html index d1c9e43..3eb2726 100644 --- a/resources/templates/auto/list-issues-Issues.html +++ b/resources/templates/auto/list-issues-Issues.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -88,49 +88,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-roles-Roles.html b/resources/templates/auto/list-roles-Roles.html index 720443f..6fe67e3 100644 --- a/resources/templates/auto/list-roles-Roles.html +++ b/resources/templates/auto/list-roles-Roles.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -79,49 +79,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-teams-Teams.html b/resources/templates/auto/list-teams-Teams.html index d3b6c19..c456013 100644 --- a/resources/templates/auto/list-teams-Teams.html +++ b/resources/templates/auto/list-teams-Teams.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -106,49 +106,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/auto/list-visits-Visits.html b/resources/templates/auto/list-visits-Visits.html index fd26cb1..0eed2f0 100644 --- a/resources/templates/auto/list-visits-Visits.html +++ b/resources/templates/auto/list-visits-Visits.html @@ -1,22 +1,22 @@ {% extends "base.html" %} - {% block head %} - + - + - + - + - + - + - + {{site-title}}: {{title}} -</html:title> + {% endblock %} @@ -97,49 +97,49 @@ View {% endblock %} {% block foot %} - - - - + {% endblock %} \ No newline at end of file diff --git a/resources/templates/base-authenticated copy.html b/resources/templates/base-unauthenticated.html similarity index 66% rename from resources/templates/base-authenticated copy.html rename to resources/templates/base-unauthenticated.html index 22af08a..cfb278f 100644 --- a/resources/templates/base-authenticated copy.html +++ b/resources/templates/base-unauthenticated.html @@ -1,30 +1,22 @@ - + - - + + - - {{title}} + {% block title %}{% endblock %}{{title}} - {% block whole-page %} - {% block top %}
@@ -32,21 +24,17 @@ {{title}}
- {% endblock %} +
+
{% block content %} {% endblock %}
- - {% block foot %}
@@ -63,17 +51,9 @@
- {% endblock %} - {% endblock %} - {% block extra-script %} - {% endblock %} - - - - diff --git a/resources/templates/base.html b/resources/templates/base.html index cfb278f..b490cd1 100644 --- a/resources/templates/base.html +++ b/resources/templates/base.html @@ -1,22 +1,30 @@ - + - - + + + - {% block title %}{% endblock %}{{title}} + {{title}} + {% block whole-page %} + {% block top %}
@@ -24,17 +32,22 @@ {{title}}
- + {% endblock %}
+
{% block content %} {% endblock %}
+
+ + {% block foot %}
@@ -51,9 +64,17 @@
+ {% endblock %} + {% endblock %} + + + + diff --git a/resources/templates/login.html b/resources/templates/login.html index 5ee3706..eebe793 100644 --- a/resources/templates/login.html +++ b/resources/templates/login.html @@ -1,7 +1,8 @@ {% extends "base-unauthenticated.html" %} {% block content %}

- We're not going to do login in the long term; we're going to use oauth. + We're not going to do login in the long term; we're going to use + oauth. This is a temporary login form.

diff --git a/src/clj/youyesyet/handler.clj b/src/clj/youyesyet/handler.clj index 40f95cf..5c3d962 100644 --- a/src/clj/youyesyet/handler.clj +++ b/src/clj/youyesyet/handler.clj @@ -13,6 +13,7 @@ [mount.core :as mount] [youyesyet.middleware :as middleware] [clojure.tools.logging :as log] + [youyesyet.db.core :as db] [youyesyet.config :refer [env]])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -42,6 +43,8 @@ :start ((or (:init defaults) identity)) :stop ((or (:stop defaults) identity))) +;;(mount/start db/*db*) + (defn init "init will be called once when app is deployed as a servlet on diff --git a/src/clj/youyesyet/routes/home.clj b/src/clj/youyesyet/routes/home.clj index eeb3722..af151ba 100644 --- a/src/clj/youyesyet/routes/home.clj +++ b/src/clj/youyesyet/routes/home.clj @@ -1,8 +1,10 @@ (ns ^{:doc "Routes/pages available to unauthenticated users." :author "Simon Brooke"} youyesyet.routes.home (:require [clojure.walk :refer [keywordize-keys]] + [clojure.java.io :refer [input-stream]] [noir.response :as nresponse] [noir.util.route :as route] + [ring.util.http-response :refer [content-type ok]] [youyesyet.layout :as layout] [youyesyet.db.core :as db-core] [compojure.core :refer [defroutes GET POST]] @@ -95,6 +97,10 @@ (defroutes home-routes (GET "/" [] (home-page)) + (GET "/js/:file" [file] + (-> (input-stream (str "resources/public/js/" file)) + ok + (content-type "text/javascript;charset=UTF-8"))) (GET "/home" [] (home-page)) (GET "/about" [] (about-page)) (GET "/roles" request (route/restricted (roles-page request))) @@ -104,6 +110,6 @@ (GET "/auth" request (login-page request)) (POST "/auth" request (login-page request)) (GET "/notyet" [] (layout/render "notyet.html" - {:title "Can we persuade you?"})) + {:title "Can we persuade you?"})) (GET "/supporter" [] (layout/render "supporter.html" {:title "Have you signed up as a canvasser yet?"}))) diff --git a/youyesyet.adl.xml b/youyesyet.adl.xml index 52a6aef..4c9ae8c 100644 --- a/youyesyet.adl.xml +++ b/youyesyet.adl.xml @@ -14,32 +14,32 @@ - - - - - - - {{site-title}}: {{title}} + + + + + + + {{site-title}}: {{title}} - - - - + - - - - - - - {{site-title}}: {{title}} + + + + + + + {{site-title}}: {{title}} - - - - +