From d7c3297f190ddce12c6ca6c2994365f298428f91 Mon Sep 17 00:00:00 2001
From: Ivan Procaccini <ivanprocaccini905@gmail.com>
Date: Tue, 23 Aug 2022 14:43:33 +0100
Subject: [PATCH] Feat: Separate own project proposals from rest

---
 app/templates/pages/student/projects.html | 36 +++++++++++++----------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/app/templates/pages/student/projects.html b/app/templates/pages/student/projects.html
index 661844f..29e64e4 100644
--- a/app/templates/pages/student/projects.html
+++ b/app/templates/pages/student/projects.html
@@ -1,24 +1,30 @@
 {% extends "components/layout.html" %}
 
+{% macro project_list(title, projects) %}
+    <section class="w3-section">
+        <h1 class="w3-center w3-text-blue">{{ title }}</h1>
+        <ul class="w3-ul">
+            {% for project in projects %}
+                <li class="w3-display-container">
+                    {{ project.title }}
+                    <div class="w3-display-right">
+                        <a href="{{ url_for("student.view_project", project_id=project.id) }}"
+                           class="w3-button w3-hover-blue">View</a>
+                        <a href=""
+                           class="w3-button w3-hover-blue">Shortlist</a>
+                    </div>
+                </li>
+            {% endfor %}
+        </ul>
+    </section>
+{% endmacro %}
+
 {% block content %}
 
     <div class="w3-content">
         <div class="w3-container">
-            <h1 class="w3-center w3-text-blue">All project proposals</h1>
-            <section class="w3-section">
-                <ul class="w3-ul">
-                    {% for project in projects %}
-                        <li class="w3-display-container">
-                            {{ project.title }}
-                            <div class="w3-display-right">
-                                <a href="{{ url_for("student.view_project", project_id=project.id) }}" class="w3-button w3-hover-blue">View</a>
-                                <a href=""
-                                   class="w3-button w3-hover-blue">Shortlist</a>
-                            </div>
-                        </li>
-                    {% endfor %}
-                </ul>
-            </section>
+            {{ project_list("All project proposals", projects | selectattr("on_behalf", "ne", current_user.username)) }}
+            {{ project_list("Your own project proposals", projects | selectattr("on_behalf", "eq", current_user.username)) }}
         </div>
     </div>
 
-- 
GitLab