From 7797530015b01159ab882d5db714f00b62df152a Mon Sep 17 00:00:00 2001
From: KacperPolczynski <polczynskikf@cardiff.ac.uk>
Date: Wed, 8 Jan 2025 23:19:16 +0000
Subject: [PATCH] references

---
 init.py                       | 16 ++++++++++++----
 static/javascript/add_proj.js |  8 ++++++--
 templates/projects.html       |  3 +++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/init.py b/init.py
index 401b512..0a22a82 100644
--- a/init.py
+++ b/init.py
@@ -18,7 +18,10 @@ db = SQLAlchemy(app)
 
 login_manager = LoginManager()
 login_manager.init_app(app)
-
+#End of models definition
+#Code snippets from:https://www.geeksforgeeks.org/how-to-add-authentication-to-your-app-with-flask-login/
+#accessed on 22nd decemeber
+#Used base login and register feature to add authentication to the app to allow other features
 @login_manager.user_loader
 def loader_user(user_id):
     return Users.query.get(user_id)
@@ -52,8 +55,7 @@ class Comments(db.Model):
     
 with app.app_context():
     db.create_all()
-#End of models definition
-#https://www.geeksforgeeks.org/how-to-add-authentication-to-your-app-with-flask-login/
+
 
 UPLOAD_FOLDER = os.path.join(basedir, 'static/uploads')
 ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
@@ -105,6 +107,9 @@ def projects():
     return render_template('projects.html' , projects=projects,comments=comments_dict)
 
 #Section for uploading photo
+#Code adapted from: https://openjavascript.info/2022/06/08/how-to-upload-a-file-using-the-fetch-api/ 
+# Accessed on 12/12/2024
+# This code allowed me to upload a photo file to the server which has been adapted to link to other projects
 @app.route('/upload', methods=['POST']) #Photo upload
 def upload_photo():
     if request.method =='POST':
@@ -188,7 +193,10 @@ def register():
         flash('User registered successfully!', 'success')
         return redirect(url_for('login'))
     return render_template('register.html')
-    
+#End of models definition
+#Code snippets from:https://www.geeksforgeeks.org/how-to-add-authentication-to-your-app-with-flask-login/
+#accessed on 22nd decemeber
+#Used base login and register feature to add authentication to the app to allow other features 
 @app.route('/login', methods=["GET", "POST"])
 def login():
     if request.method == "POST":
diff --git a/static/javascript/add_proj.js b/static/javascript/add_proj.js
index f61dc0a..d35377b 100644
--- a/static/javascript/add_proj.js
+++ b/static/javascript/add_proj.js
@@ -1,4 +1,6 @@
-
+/*code adapted from: https://www.w3schools.com/howto/howto_css_modals.asp*/
+/*Accessed on 12/12/2024*/
+/*modal pop up allowed me to implement a form to add a project*/
     var modal = document.getElementById("myModal");
     var btn = document.getElementById("add-proj-btn");
     var span = document.getElementsByClassName("close")[0];
@@ -37,7 +39,9 @@ form.addEventListener('submit', async (e) => {
     const payload = new FormData();
     payload.append("photo_url", file);
 
-    /*https://openjavascript.info/2022/06/08/how-to-upload-a-file-using-the-fetch-api/*/
+    /* Code adapted from: https://openjavascript.info/2022/06/08/how-to-upload-a-file-using-the-fetch-api/ */
+    /*Accessed on 12/12/2024*/
+    /*This code allowed me to upload a file to the server*/
     try {
         const photoupload = await fetch('/upload', {
             method : 'POST', 
diff --git a/templates/projects.html b/templates/projects.html
index f9a9fe1..a40b482 100644
--- a/templates/projects.html
+++ b/templates/projects.html
@@ -32,6 +32,9 @@
     </div>
     {% endif %}
     <!-- Pop Up to Add Projects-->
+    <!--code adapted from: https://www.w3schools.com/howto/howto_css_modals.asp*/
+    Accessed on 12/12/2024*/
+    modal pop up allowed me to implement a form to add a project-->
     <div id ="myModal" class="modal">
         <div class = "modal-content">
             <span class="close">&times;</span>
-- 
GitLab