From fd0d8e7842def08e1dd0ce777eee9abca41f4ff1 Mon Sep 17 00:00:00 2001
From: Robert Metcalf <metcalfr@cardiff.ac.uk>
Date: Fri, 19 Nov 2021 11:17:17 +0000
Subject: [PATCH] show workspaces on home page

---
 main.py             |  4 +++-
 templates/home.html | 18 +++++++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/main.py b/main.py
index e4e1c86..dc32f70 100644
--- a/main.py
+++ b/main.py
@@ -1,11 +1,13 @@
 from flask import Flask, request, render_template
+import database
 
 app = Flask(__name__)
 
 @app.route("/", methods = ["GET"])
 def home():
 	if request.method == "GET":
-		return render_template("home.html")
+		workspaces = database.get_workspaces()
+		return render_template("home.html", workspaces = workspaces)
 
 if __name__ == "__main__":
 	app.run(debug = True)
diff --git a/templates/home.html b/templates/home.html
index 214431d..9556192 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -1,2 +1,18 @@
 {% extends "main.html" %}
-{% block title %}Home{% endblock %}
\ No newline at end of file
+{% block title %}Home{% endblock %}
+{% block mainBlock %}
+<ul>
+	{% for workspace in workspaces %}
+	<li><a href="{{ workspace.website }}">{{ workspace.name }}</a></li>
+	<img src="{{ workspace.main_photo }}">
+	<ul>
+		<li>{{ workspace.address }}</li>
+		<li>{{ workspace.description }}</li>
+		<li>{{ workspace.email }}</li>
+		<li>{{ workspace.phone_number }}</li>
+		<li>{{ workspace.opening_hours }}</li>
+		<li>{{ workspace.checkin_instructions }}</li>
+	</ul>
+	{% endfor %}
+</ul>
+{% endblock %}
\ No newline at end of file
-- 
GitLab