diff --git a/main.hy b/main.hy index e73d1c0..6d0b93c 100644 --- a/main.hy +++ b/main.hy @@ -2,7 +2,9 @@ (import [flask [Flask]]) (def app (Flask __name__)) -(def hello ((.route app "/") (fn [] "Hello World"))) + +(with-decorator (.route app "/") (defn hello [] "Hello World")) + (if (= __name__ "__main__") (.run app)) diff --git a/main.py b/main.py index f22dd59..59dba86 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,7 @@ -# from http://flask.pocoo.org/ tutorial from flask import Flask - + app = Flask(__name__) - + @app.route("/") # take note of this decorator syntax, it's a common pattern def hello(): return "Hello World!" diff --git a/notes/bs.md b/notes/bs.md index 5e5a5a6..85c6bf6 100644 --- a/notes/bs.md +++ b/notes/bs.md @@ -15,6 +15,14 @@ Note: "BS" stands for BrainStorming. slot is booked, other clients should not be able to book that slot with the same coach. +## Alternatives + + Google Calendar offers an "office hours" appointment mechanism. It + doesn't quite do what the problem requires; it's only available to + other members of the same school or corporate group account. + + + ## Solution requirements: * Data Store @@ -175,7 +183,12 @@ TODO Postgres range example TODO Deliver home page TODO Deliver retreivals - +--- + +Quick thoughts: + +Craft views or + diff --git a/notes/progress.md b/notes/progress.md index eb53a7f..85e6112 100644 --- a/notes/progress.md +++ b/notes/progress.md @@ -1,4 +1,5 @@ -Re-learning how to install Postgres (*Sigh) +# Re-learning how to install Postgres (*Sigh) +## WITH Postgres 9.4 CREATE DATABASE officehours; CREATE USER officehours; @@ -16,17 +17,15 @@ CREATE EXTENSION citext; CREATE EXTENSION btree_gist; CREATE EXTENSION plv8; -# -What can I do? - 1) Add users and make them clients. - 2) Add users and make them staff. - 3) Allocate a block of time as "office hours" - 4) Allocate a block of time as an "appointment." -NEXT: Psycopg2 +# What can I do? -** Progress: Everything works in psycopg2 EXCEPT add_appointment, which -is very distressing. Really, _really_ don't want to take that -functionality and put it into the middle tier. It's rock-solid business -logic; it belongs in the database as a constraint. +1) Add users and make them clients. +2) Add users and make them staff. +3) Allocate a block of time as "office hours" +4) Allocate a block of time as an "appointment." + +## Progress: + +Everything works in psycopg2. diff --git a/play.hy b/play.hy index e068f44..d4f913f 100644 --- a/play.hy +++ b/play.hy @@ -7,7 +7,6 @@ (defn connect [] (psycopg2.connect "host='localhost' dbname='officehours' user='officehours' password='eatabug'")) - (def users [ (, "Alice" "alice@example.com") (, "Bob" "bob@example.com") @@ -58,16 +57,22 @@ (.execute curs "INSERT INTO officehours (staff_id, during) VALUES (2, '[2015-02-07 12:00, 2015-02-07 15:00)');") (.commit conn)) + + +; [ops ["SELECT add_appointment(3, '[2015-02-07 10:00, 2015-02-07 10:30)');" +; "SELECT add_appointment(4, '[2015-02-07 10:30, 2015-02-07 11:00)');" +; "SELECT add_appointment(5, '[2015-02-07 13:00, 2015-02-07 13:30)');" +; "SELECT add_appointment(6, '[2015-02-07 13:30, 2015-02-07 14:00)');"]]] + + (let [[conn (connect)] [curs (.cursor conn)] - [ops ["SELECT add_appointment(3, '[2015-02-07 10:00, 2015-02-07 10:30)');" - "SELECT add_appointment(4, '[2015-02-07 10:30, 2015-02-07 11:00)');" - "SELECT add_appointment(5, '[2015-02-07 13:00, 2015-02-07 13:30)');" - "SELECT add_appointment(6, '[2015-02-07 13:30, 2015-02-07 14:00)');"]]] - + [ops [(, 3 "[2015-02-07 10:00, 2015-02-07 10:30)") + (, 4 "[2015-02-07 10:30, 2015-02-07 11:00)") + (, 5 "[2015-02-07 13:00, 2015-02-07 13:30)") + (, 6 "[2015-02-07 13:30, 2015-02-07 14:00)")]]] (for [op ops] - (print op) - (.execute curs op) + (.callproc curs "add_appointment" op) (.commit conn))) (let [[conn (connect)]