From 40c903df927165ef169532b4adaa00fb45a6d483 Mon Sep 17 00:00:00 2001
From: Danae Natalie Savvidi <d.n.savvidi@student.tudelft.nl>
Date: Wed, 12 Feb 2025 14:21:36 +0100
Subject: [PATCH 1/3] view response button for applicants

---
 src/main/resources/messages.properties        |  1 +
 .../templates/application/view_many.html      | 22 ++++++---
 ...ring_message.html => message_overlay.html} |  8 ++--
 .../templates/job_offer/view_many.html        |  4 +-
 .../job_offer/view_reject_message.html        | 47 -------------------
 5 files changed, 23 insertions(+), 59 deletions(-)
 rename src/main/resources/templates/job_offer/{view_hiring_message.html => message_overlay.html} (82%)
 delete mode 100644 src/main/resources/templates/job_offer/view_reject_message.html

diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties
index 40647b75c..4bcee607d 100644
--- a/src/main/resources/messages.properties
+++ b/src/main/resources/messages.properties
@@ -185,6 +185,7 @@ jobOffer.hiringMessage.enter = An optional message that a student will see after
 jobOffer.hiringMessage.edit = Edit Hiring Message
 jobOffer.hiringMessage.add = Add Hiring Message
 jobOffer.hiringMessage.view = View hiring message
+jobOffer.responseMessage = Your Response
 jobOffer.rejectMessage = Rejection Message
 jobOffer.rejectMessage.enter = An optional message that a rejected student will see...
 jobOffer.rejectMessage.view = View rejection message
diff --git a/src/main/resources/templates/application/view_many.html b/src/main/resources/templates/application/view_many.html
index 969519a5b..828313561 100644
--- a/src/main/resources/templates/application/view_many.html
+++ b/src/main/resources/templates/application/view_many.html
@@ -100,18 +100,25 @@
                     </td>
                     <td>
                         <div class="flex justify-end gap-3">
+                            <button
+                                th:if="${!(app.content == null || app.content.isEmpty())}"
+                                class="button p-min"
+                                data-style="outlined"
+                                th:data-dialog="|view-response-message-overlay-${offer.id}|"
+                                th:aria-label="#{application.viewContent}"
+                                th:text="#{application.viewContent}"></button>
                             <button
                                 th:if="${(status == 'ACCEPTED' || status == 'OFFERED') && !(offer.hiringMessage == null || offer.hiringMessage.isEmpty())}"
                                 class="button p-min"
                                 data-style="outlined"
-                                th:data-dialog="|view-hiring-message-overlay-${app.jobOfferId}|"
+                                th:data-dialog="|view-hiring-message-overlay-${offer.id}|"
                                 th:aria-label="#{jobOffer.hiringMessage.view}"
                                 th:text="#{jobOffer.hiringMessage.view}"></button>
                             <button
                                 th:if="${status == 'REJECTED_BY_TEACHER' && !(offer.rejectMessage == null || offer.rejectMessage.isEmpty())}"
                                 class="button p-min"
                                 data-style="outlined"
-                                th:data-dialog="|view-reject-message-overlay-${app.jobOfferId}|"
+                                th:data-dialog="|view-reject-message-overlay-${offer.id}|"
                                 th:aria-label="#{jobOffer.rejectMessage.view}"
                                 th:text="#{jobOffer.rejectMessage.view}"></button>
                             <form
@@ -145,12 +152,15 @@
                             </div>
                         </div>
                     </td>
-                    <div
+                    <th:block
                         th:if="${(status == 'ACCEPTED' || status == 'OFFERED') && !(offer.hiringMessage == null || offer.hiringMessage.isEmpty())}"
-                        th:replace="~{job_offer/view_hiring_message :: overlay}"></div>
-                    <div
+                        th:replace="~{job_offer/message_overlay :: overlay('hiring', ${offer.id}, ${offer.hiringMessage})}"></th:block>
+                    <th:block
                         th:if="${status == 'REJECTED_BY_TEACHER' && !(offer.rejectMessage == null || offer.rejectMessage.isEmpty())}"
-                        th:replace="~{job_offer/view_reject_message :: overlay}"></div>
+                        th:replace="~{job_offer/message_overlay :: overlay('reject', ${offer.id}, ${offer.rejectMessage})}"></th:block>
+                    <th:block
+                        th:if="${!(app.content == null || app.content.isEmpty())}"
+                        th:replace="~{job_offer/message_overlay :: overlay('response', ${offer.id}, ${app.content})}"></th:block>
                 </tr>
                 <tr th:if="${applications.isEmpty()}">
                     <td data-empty="true" colspan="6" th:text="#{application.empty}"></td>
diff --git a/src/main/resources/templates/job_offer/view_hiring_message.html b/src/main/resources/templates/job_offer/message_overlay.html
similarity index 82%
rename from src/main/resources/templates/job_offer/view_hiring_message.html
rename to src/main/resources/templates/job_offer/message_overlay.html
index 0809eece6..ec2a629c7 100644
--- a/src/main/resources/templates/job_offer/view_hiring_message.html
+++ b/src/main/resources/templates/job_offer/message_overlay.html
@@ -24,14 +24,14 @@
     xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
     <body>
         <dialog
-            th:fragment="overlay"
-            th:id="|view-hiring-message-overlay-${offer.id}|"
+            th:fragment="overlay(type, jobOfferId, messageHtml)"
+            th:id="|view-${type}-message-overlay-${jobOfferId}|"
             data-closable
             class="dialog">
             <div class="flex vertical p-7">
-                <h1 class="font-500 underlined" th:text="#{jobOffer.hiringMessage}"></h1>
+                <h1 class="font-500 underlined" th:text="#{|jobOffer.${type}Message|}"></h1>
 
-                <div class="article" th:utext="${offer.hiringMessageHtml}"></div>
+                <div class="article" th:utext="${messageHtml}"></div>
 
                 <div>
                     <button
diff --git a/src/main/resources/templates/job_offer/view_many.html b/src/main/resources/templates/job_offer/view_many.html
index b72c1f2ec..b36fe3a2c 100644
--- a/src/main/resources/templates/job_offer/view_many.html
+++ b/src/main/resources/templates/job_offer/view_many.html
@@ -228,10 +228,10 @@
 
                             <th:block
                                 th:if="${app.exists() && (status == 'ACCEPTED' || status == 'OFFERED') && !(offer.hiringMessage == null || offer.hiringMessage.isEmpty())}"
-                                th:replace="~{job_offer/view_hiring_message :: overlay}"></th:block>
+                                th:replace="~{job_offer/message_overlay :: overlay('hiring', ${offer.id}, ${offer.hiringMessageHtml})}"></th:block>
                             <th:block
                                 th:if="${app.exists() && status == 'REJECTED_BY_TEACHER' && !(offer.rejectMessage == null || offer.rejectMessage.isEmpty())}"
-                                th:replace="~{job_offer/view_reject_message :: overlay}"></th:block>
+                                th:replace="~{job_offer/message_overlay :: overlay('reject', ${offer.id}, ${offer.rejectMessageHtml})}"></th:block>
                         </tr>
                     </tbody>
                 </th:block>
diff --git a/src/main/resources/templates/job_offer/view_reject_message.html b/src/main/resources/templates/job_offer/view_reject_message.html
deleted file mode 100644
index fb28aa245..000000000
--- a/src/main/resources/templates/job_offer/view_reject_message.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
-
-    TAM
-    Copyright (C) 2021 - Delft University of Technology
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU Affero General Public License as
-    published by the Free Software Foundation, either version 3 of the
-    License, or (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU Affero General Public License for more details.
-
-    You should have received a copy of the GNU Affero General Public License
-    along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
--->
-<!DOCTYPE html>
-<html
-    lang="en"
-    xmlns:th="http://www.thymeleaf.org"
-    xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
-    <body>
-        <dialog
-            th:fragment="overlay"
-            th:id="|view-reject-message-overlay-${offer.id}|"
-            data-closable
-            class="dialog">
-            <div class="flex vertical p-7">
-                <h1 class="underlined font-500" th:text="#{jobOffer.rejectMessage}"></h1>
-
-                <div class="article" th:utext="${offer.rejectMessageHtml}"></div>
-
-                <div>
-                    <button
-                        type="button"
-                        class="button p-less"
-                        th:aria-label="#{general.close}"
-                        th:text="#{general.close}"
-                        data-cancel></button>
-                </div>
-            </div>
-        </dialog>
-    </body>
-</html>
-- 
GitLab


From 1cad0f1a67c978319b7972bb9d7976fb06a5a21d Mon Sep 17 00:00:00 2001
From: Danae Natalie Savvidi <d.n.savvidi@student.tudelft.nl>
Date: Wed, 12 Feb 2025 15:29:11 +0100
Subject: [PATCH 2/3] fix authorization in apply button

---
 src/main/java/nl/tudelft/tam/security/AuthorisationService.java | 1 +
 src/main/resources/templates/job_offer/apply.html               | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/nl/tudelft/tam/security/AuthorisationService.java b/src/main/java/nl/tudelft/tam/security/AuthorisationService.java
index 00a07c14e..8bc84a2cb 100644
--- a/src/main/java/nl/tudelft/tam/security/AuthorisationService.java
+++ b/src/main/java/nl/tudelft/tam/security/AuthorisationService.java
@@ -242,6 +242,7 @@ public class AuthorisationService {
 		JobOffer jobOffer = jobOfferService.findByIdOrThrow(offerId);
 		return !applicationService.appExistsFor(getAuthPerson().getId(), offerId) &&
 				!jobOffer.getHidden() &&
+				!canManageEdition(jobOffer.getEditionId()) &&
 				(jobOffer.getDeadline() == null || !LocalDate.now().isAfter(jobOffer.getDeadline()));
 	}
 
diff --git a/src/main/resources/templates/job_offer/apply.html b/src/main/resources/templates/job_offer/apply.html
index 6f52595b0..a5d76d06e 100644
--- a/src/main/resources/templates/job_offer/apply.html
+++ b/src/main/resources/templates/job_offer/apply.html
@@ -78,7 +78,7 @@
                         th:text="#{general.close}"
                         data-cancel></button>
                     <button
-                        th:unless="${app.exists()}"
+                        th:unless="${app.exists() || !@authorisationService.canSubmitApplication(offer.id)}"
                         type="submit"
                         class="button p-less"
                         th:aria-label="#{jobOffer.apply}"
-- 
GitLab


From 400067a0c43dc8efdba691781664a57f54bda2d3 Mon Sep 17 00:00:00 2001
From: Danae Natalie Savvidi <d.n.savvidi@student.tudelft.nl>
Date: Wed, 12 Feb 2025 15:29:35 +0100
Subject: [PATCH 3/3] Revert "fix authorization in apply button"

This reverts commit 1cad0f1a67c978319b7972bb9d7976fb06a5a21d.
---
 src/main/java/nl/tudelft/tam/security/AuthorisationService.java | 1 -
 src/main/resources/templates/job_offer/apply.html               | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/nl/tudelft/tam/security/AuthorisationService.java b/src/main/java/nl/tudelft/tam/security/AuthorisationService.java
index 8bc84a2cb..00a07c14e 100644
--- a/src/main/java/nl/tudelft/tam/security/AuthorisationService.java
+++ b/src/main/java/nl/tudelft/tam/security/AuthorisationService.java
@@ -242,7 +242,6 @@ public class AuthorisationService {
 		JobOffer jobOffer = jobOfferService.findByIdOrThrow(offerId);
 		return !applicationService.appExistsFor(getAuthPerson().getId(), offerId) &&
 				!jobOffer.getHidden() &&
-				!canManageEdition(jobOffer.getEditionId()) &&
 				(jobOffer.getDeadline() == null || !LocalDate.now().isAfter(jobOffer.getDeadline()));
 	}
 
diff --git a/src/main/resources/templates/job_offer/apply.html b/src/main/resources/templates/job_offer/apply.html
index a5d76d06e..6f52595b0 100644
--- a/src/main/resources/templates/job_offer/apply.html
+++ b/src/main/resources/templates/job_offer/apply.html
@@ -78,7 +78,7 @@
                         th:text="#{general.close}"
                         data-cancel></button>
                     <button
-                        th:unless="${app.exists() || !@authorisationService.canSubmitApplication(offer.id)}"
+                        th:unless="${app.exists()}"
                         type="submit"
                         class="button p-less"
                         th:aria-label="#{jobOffer.apply}"
-- 
GitLab