diff --git a/README.md b/README.md index 756f5a1..36a67f0 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,25 @@ webpy framework: http://webpy.org/ ### prerequisites: docker https://www.docker.com/ -### Run -docker-compose up +### Build & Run +$ docker-compose up --build + +### Prune/Recreate +If you need a fresh rebuild in case of startup issues use this command (WARNING this will remove all your docker images) +$ docker system prune -a +$ docker-compose up --build + +### Deploy locally + +Install: +mysql +src/app/requirements.txt + +Run: +Launch mysql at port 3306 +Execute mysql queries +"CREATE database db;" +"USE db;" +Populate mysql by posting mysql/sql/init.sql into mysql +Edit src/app/models/database.py to point at local server +python3 src/app/main.py diff --git a/src/app/models/database.py b/src/app/models/database.py index 11bbd81..f1de688 100644 --- a/src/app/models/database.py +++ b/src/app/models/database.py @@ -3,6 +3,7 @@ import mysql.connector db = mysql.connector.connect( user='root', password='root', - host='10.5.0.5', + #host='10.5.0.5', # Docker address + host='0.0.0.0', # Local address database='db' ) diff --git a/src/app/models/guestbook.py b/src/app/models/guestbook.py index 076cf98..d987615 100644 --- a/src/app/models/guestbook.py +++ b/src/app/models/guestbook.py @@ -12,6 +12,7 @@ def set_guestbook_entry(entry): cursor = db.cursor() query = ("INSERT INTO guestbook VALUES (NULL, \"" + entry + "\")") cursor.execute(query) + db.commit() cursor.close() diff --git a/src/app/models/project.py b/src/app/models/project.py index f75a217..50a67bc 100644 --- a/src/app/models/project.py +++ b/src/app/models/project.py @@ -10,14 +10,19 @@ def get_categories(): def set_project(categoryid, userid, title, project_description, project_status): cursor = db.cursor() - query = ("INSERT INTO projects values (NULL, \"1\", \"1\", \"sad\", \"desdf\", \"open\")") - #("INSERT INTO projects values (NULL, \"" + - #categoryid + "\", \"" + userid + "\", \"" + title + "\", \"" + - #project_description + "\", \"" + project_status + "\")") - print(query) + query = ("INSERT INTO projects VALUES (NULL, \"" + + categoryid + "\", \"" + userid + "\", \"" + title + "\", \"" + + project_description + "\", \"" + project_status + "\")") cursor.execute(query) + db.commit() cursor.close() categories = get_categories() - print(categories) return categories - + +def get_projects_by_status_and_category(categoryid, project_status): + cursor = db.cursor() + query = ("SELECT * FROM projects WHERE project_status = \"" + + project_status + "\" AND categoryid = \"" + categoryid + "\"") + cursor.execute(query) + projects = cursor.fetchall() + return projects diff --git a/src/app/models/register.py b/src/app/models/register.py index af5172e..8ffeefd 100644 --- a/src/app/models/register.py +++ b/src/app/models/register.py @@ -8,4 +8,5 @@ def set_user(username, password, full_name, company, phone_number, phone_number + "\", \"" + street_address + "\", \"" + city + "\", \"" + state + "\", \"" + postal_code + "\", \"" + country + "\")") cursor.execute(query) + db.commit() cursor.close() diff --git a/src/app/static/stylesheet.css b/src/app/static/stylesheet.css index 692858e..4bff02b 100644 --- a/src/app/static/stylesheet.css +++ b/src/app/static/stylesheet.css @@ -5,6 +5,28 @@ body { margin: 0; } +.title { + margin: auto; +} + +.categories { + display: flex; /* or inline-flex */ + flex-direction: row; +} + +.category { + margin: auto; +} + +.projects { + display: flex; /* or inline-flex */ + flex-direction: row; +} + +.projects * { + margin: auto; +} + h1 { margin: auto; } diff --git a/src/app/templates/guestbook.html b/src/app/templates/guestbook.html index 09747d0..1914e43 100644 --- a/src/app/templates/guestbook.html +++ b/src/app/templates/guestbook.html @@ -4,6 +4,7 @@ $def with (nav, entries, guestbook_form)
$project[4]
diff --git a/src/app/templates/login.html b/src/app/templates/login.html
index 8f369e5..595edc2 100644
--- a/src/app/templates/login.html
+++ b/src/app/templates/login.html
@@ -4,6 +4,7 @@ $def with (nav, login_form, friends)