Skip to content
Snippets Groups Projects
Commit 6d81831c authored by Cédric Willekens's avatar Cédric Willekens
Browse files

Allow requests to be updated by the TA

parent 64bf18a5
No related merge requests found
...@@ -326,6 +326,17 @@ public class RequestController { ...@@ -326,6 +326,17 @@ public class RequestController {
return "redirect:/requests"; return "redirect:/requests";
} }
@RequestMapping(value = "/request/{id}/room", method = RequestMethod.POST)
@PreAuthorize("@permissionService.canNextRequest(principal, #id)")
public String updateRoom(@PathVariable("id") Long id,
@RequestParam("room") Room room) {
Request request = requestRepository.findById(id);
request.setRoom(room);
requestRepository.save(request);
return "redirect:/request/" + id;
}
@RequestMapping(value = "/course/{id}/requests/export", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/course/{id}/requests/export", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@permissionService.canEditCourse(principal, #id)") @PreAuthorize("@permissionService.canEditCourse(principal, #id)")
@JsonView(View.Summary.class) @JsonView(View.Summary.class)
......
...@@ -597,9 +597,8 @@ public class Request implements RecordsEvents<Request>, Serializable, Comparable ...@@ -597,9 +597,8 @@ public class Request implements RecordsEvents<Request>, Serializable, Comparable
requests.put("labId", this.getLab().getId().toString()); requests.put("labId", this.getLab().getId().toString());
requests.put("lab",this.getLab().getTitle()); requests.put("lab",this.getLab().getTitle());
requests.put("assignment", this.getAssignment().getName()); requests.put("assignment", this.getAssignment().getName());
requests.put("room", this.getRoom().getName()); requests.put("room", (this.getRoom() == null) ? "TBA" : this.getRoom().getName());
requests.put("course", this.getLab().getCourse().toString()); requests.put("course", this.getLab().getCourse().toString());
requests.put("room", this.getRoom().toString());
if (this.getAssistant() != null) if (this.getAssistant() != null)
requests.put("assigned", this.getAssistant().toString()); requests.put("assigned", this.getAssistant().toString());
if (this.getHandledAt() != null) if (this.getHandledAt() != null)
......
...@@ -21,4 +21,5 @@ public interface RequestRepository extends CrudRepository<Request, Long>, JpaSpe ...@@ -21,4 +21,5 @@ public interface RequestRepository extends CrudRepository<Request, Long>, JpaSpe
List<Request> findByAssistant(User assistant); List<Request> findByAssistant(User assistant);
Request findById(Long id);
} }
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<small th:text="${#temporals.format(request.handledAt, 'dd-MM HH:mm')}">22 May 2016</small> <small th:text="${#temporals.format(request.handledAt, 'dd-MM HH:mm')}">22 May 2016</small>
</th:block> </th:block>
</td> </td>
<td th:text="${request.getRoom().toString()}">Room</td> <td th:text="${(request.getRoom() == null)? 'TBA' : request.getRoom().toString()}">Room</td>
</tr> </tr>
</th:block> </th:block>
</tbody> </tbody>
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="course/view"> <html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="course/view">
<head> <head>
<title>Request #[[${request.id}]] · [[${request.lab.course}]]</title> <title>Request #[[${request.id}]] · [[${request.lab.course}]]</title>
...@@ -12,7 +13,8 @@ ...@@ -12,7 +13,8 @@
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li> <li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/courses">Courses</a></li> <li class="breadcrumb-item"><a href="/courses">Courses</a></li>
<li class="breadcrumb-item"><a href="#" th:href="@{/course/{id}(id=${course.id})}" th:text="${course.code}">TI1234</a></li> <li class="breadcrumb-item"><a href="#" th:href="@{/course/{id}(id=${course.id})}" th:text="${course.code}">TI1234</a>
</li>
<li class="breadcrumb-item active">Request #[[${request.id}]]</li> <li class="breadcrumb-item active">Request #[[${request.id}]]</li>
</ol> </ol>
</nav> </nav>
...@@ -28,21 +30,25 @@ ...@@ -28,21 +30,25 @@
</div> </div>
</div> </div>
<h3 th:unless="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]]</h3> <h3 th:unless="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]]</h3>
<h3 th:if="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]] at [[${request.getSlot()}]]</h3> <h3 th:if="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]] at
[[${request.getSlot()}]]</h3>
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-12" th:if="${request.isHandled() and !request.getLeftFeedback() and request.getRequestEntity().getId().equals(#authenticated.getId())}"> <div class="col-sm-12"
th:if="${request.isHandled() and !request.getLeftFeedback() and request.getRequestEntity().getId().equals(#authenticated.getId())}">
<div class="page-header"> <div class="page-header">
<h4>Feedback</h4> <h4>Feedback</h4>
</div> </div>
<form action="#" th:action="@{/request/{id}/feedback(id=${request.id})}" method="post" class="form-horizontal"> <form action="#" th:action="@{/request/{id}/feedback(id=${request.id})}" method="post"
class="form-horizontal">
<div class="form-group"> <div class="form-group">
<label for="inputFeedback" class="col-sm-2 control-label">Feedback</label> <label for="inputFeedback" class="col-sm-2 control-label">Feedback</label>
<div class="col-sm-8"> <div class="col-sm-8">
<textarea maxlength="250" class="form-control" id="inputFeedback" name="feedback" placeholder="Leave feedback about the TA (only teachers can see this feedback)."></textarea> <textarea maxlength="250" class="form-control" id="inputFeedback" name="feedback"
placeholder="Leave feedback about the TA (only teachers can see this feedback)."></textarea>
</div> </div>
</div> </div>
...@@ -100,7 +106,26 @@ ...@@ -100,7 +106,26 @@
<dd th:text="${request.assignment}"></dd> <dd th:text="${request.assignment}"></dd>
<dt>Room</dt> <dt>Room</dt>
<dd th:text="${request.room}"></dd> <dd th:text="${request.room}" th:if="${request.getLab().studentCanChooseRoom()}"></dd>
<dd th:if="${not request.getLab().studentCanChooseRoom()}">
<form action="#" th:action="@{/request/{id}/room(id=${request.id})}" method="post" class="form-horizontal">
<label for="inputRoom" class="col-sm-4 control-label">What room are you in?</label>
<div class="col-sm-8 form-group" >
<select class="form-control" id="inputRoom" th:field="${request.room}">
<div>
<option value="" th:selected="selected">Choose a room</option>
<option th:each="room : ${request.getLab().rooms}" th:value="${room.id}"
th:text="${room}" th:selected="${room.equals(request.getRoom())? 'selected' : ''}">DW 1.01
</option>
</div>
</select>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Update room</button>
</div>
</form>
</dd>
<dt>Type</dt> <dt>Type</dt>
<dd th:text="${request.requestType.name}"></dd> <dd th:text="${request.requestType.name}"></dd>
...@@ -118,7 +143,8 @@ ...@@ -118,7 +143,8 @@
<dt>Status</dt> <dt>Status</dt>
<dd th:include="request/status :: status(${request.status})"></dd> <dd th:include="request/status :: status(${request.status})"></dd>
<th:block th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)}"> <th:block
th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)}">
<th:block th:unless="${#strings.isEmpty(request.reason)}"> <th:block th:unless="${#strings.isEmpty(request.reason)}">
<dt>Reason (TA only)</dt> <dt>Reason (TA only)</dt>
<dd th:text="${request.reason}"></dd> <dd th:text="${request.reason}"></dd>
...@@ -131,11 +157,15 @@ ...@@ -131,11 +157,15 @@
</th:block> </th:block>
</dl> </dl>
</div> </div>
<div class="card-footer" th:if="${@permissionService.canFinishRequest(#authentication.principal, request.id)}"> <div class="card-footer"
th:if="${@permissionService.canFinishRequest(#authentication.principal, request.id)}">
<div class="btn-group d-flex" role="group"> <div class="btn-group d-flex" role="group">
<a href="#" th:href="@{/request/{id}/approve(id=${request.id})}" class="w-100 btn btn-success btn-sm">Approve</a> <a href="#" th:href="@{/request/{id}/approve(id=${request.id})}"
<a href="#" th:href="@{/request/{id}/reject(id=${request.id})}" class="w-100 btn btn-danger btn-sm">Reject</a> class="w-100 btn btn-success btn-sm">Approve</a>
<a href="#" th:href="@{/request/{id}/forward(id=${request.id})}" class="w-100 btn btn-warning btn-sm">Forward</a> <a href="#" th:href="@{/request/{id}/reject(id=${request.id})}"
class="w-100 btn btn-danger btn-sm">Reject</a>
<a href="#" th:href="@{/request/{id}/forward(id=${request.id})}"
class="w-100 btn btn-warning btn-sm">Forward</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -145,25 +175,32 @@ ...@@ -145,25 +175,32 @@
</div> </div>
<p th:if="${#lists.isEmpty(request.previous)}"> <p th:if="${#lists.isEmpty(request.previous)}">
There are no previous requests by <strong th:text="${request.requestEntity}">student</strong> for <strong th:text="${request.assignment}">Assembly programming</strong>. There are no previous requests by <strong th:text="${request.requestEntity}">student</strong> for
<strong th:text="${request.assignment}">Assembly programming</strong>.
</p> </p>
<div class="list-group mb-3" th:unless="${#lists.isEmpty(request.previous)}"> <div class="list-group mb-3" th:unless="${#lists.isEmpty(request.previous)}">
<a href="#" class="list-group-item list-group-item-action" th:each="request : ${request.previous}" th:href="@{/request/{id}(id=${request.id})}"> <a href="#" class="list-group-item list-group-item-action" th:each="request : ${request.previous}"
th:href="@{/request/{id}(id=${request.id})}">
<th:block th:if="${request.revoked}"> <th:block th:if="${request.revoked}">
Request <strong>#[[${request.id}]]</strong> was <strong>revoked</strong>. Request <strong>#[[${request.id}]]</strong> was <strong>revoked</strong>.
</th:block> </th:block>
<th:block th:unless="${request.revoked}"> <th:block th:unless="${request.revoked}">
<th:block th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}"> <th:block
Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by <strong>[[${request.assistant}]]</strong> because &ldquo;[[${request.reason}]]&rdquo; th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}">
Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by
<strong>[[${request.assistant}]]</strong> because &ldquo;[[${request.reason}]]&rdquo;
</th:block> </th:block>
<th:block th:unless="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}"> <th:block
Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by <strong>[[${request.assistant}]]</strong>. th:unless="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}">
Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by
<strong>[[${request.assistant}]]</strong>.
</th:block> </th:block>
</th:block> </th:block>
<p class="time" th:text="${#prettyTime.diffForHumans(request.handledAt)}" th:if="request.handledAt">5 minutes ago</p> <p class="time" th:text="${#prettyTime.diffForHumans(request.handledAt)}" th:if="request.handledAt">
5 minutes ago</p>
</a> </a>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment