Browse Source

Resource request fixes

Sebastian Lohff 2 years ago
parent
commit
648be3ef83
2 changed files with 9 additions and 2 deletions
  1. 4
    2
      rrequests/views.py
  2. 5
    0
      templates/rrequests/request_detail.html

+ 4
- 2
rrequests/views.py View File

@@ -14,7 +14,7 @@ from .forms import RequestForm, ResponseForm, ProviderResponseForm
14 14
 @login_required
15 15
 def listRequests(request):
16 16
 	mnts = request.user.maintainer_set.all()
17
-	requestedFromMe = Request.objects.filter(applicant=mnts)
17
+	requestedFromMe = Request.objects.filter(applicant__in=mnts)
18 18
 	requestedToMe = Request.objects.filter(provider__in=mnts)
19 19
 	requests = (requestedFromMe | requestedToMe).order_by("-lastAction")
20 20
 
@@ -60,9 +60,11 @@ def rrequestDetail(request, pk):
60 60
 	mnts = request.user.maintainer_set.all()
61 61
 	formClass = None
62 62
 	provider = None
63
+	initialFormData = {}
63 64
 	if reqObj.provider in mnts:
64 65
 		provider = True
65 66
 		formClass = ProviderResponseForm
67
+		initialFormData["createdResources"] = reqObj.grantedResources
66 68
 	else:
67 69
 		provider = False
68 70
 		formClass = ResponseForm
@@ -92,7 +94,7 @@ def rrequestDetail(request, pk):
92 94
 
93 95
 			return HttpResponseRedirect(reverse("rrequests:show", args=(pk,)))
94 96
 	else:
95
-		form = formClass(request=reqObj, user=request.user)
97
+		form = formClass(request=reqObj, user=request.user, initial=initialFormData)
96 98
 
97 99
 	return render(request, "rrequests/request_detail.html", {"request": reqObj, "form": form})
98 100
 

+ 5
- 0
templates/rrequests/request_detail.html View File

@@ -24,6 +24,11 @@
24 24
 						</div>
25 25
 					{% endif %}
26 26
 				{% endfor %}
27
+				{% if request.grantedResources %}
28
+					<div role="alert" class="alert alert-info">
29
+					<span class="glyphicon glyphicon-ok"></span> Created resources: {{ request.grantedResources }}.
30
+					</div>
31
+				{% endif %}
27 32
 				</p>
28 33
 				<h4>Add / change</h4>
29 34
 				<form method="post" action="#">

Loading…
Cancel
Save