Resource request fixes

This commit is contained in:
Sebastian Lohff 2017-04-15 16:57:19 +02:00
parent 68e5c31426
commit 648be3ef83
2 changed files with 9 additions and 2 deletions

View File

@ -14,7 +14,7 @@ from .forms import RequestForm, ResponseForm, ProviderResponseForm
@login_required
def listRequests(request):
mnts = request.user.maintainer_set.all()
requestedFromMe = Request.objects.filter(applicant=mnts)
requestedFromMe = Request.objects.filter(applicant__in=mnts)
requestedToMe = Request.objects.filter(provider__in=mnts)
requests = (requestedFromMe | requestedToMe).order_by("-lastAction")
@ -60,9 +60,11 @@ def rrequestDetail(request, pk):
mnts = request.user.maintainer_set.all()
formClass = None
provider = None
initialFormData = {}
if reqObj.provider in mnts:
provider = True
formClass = ProviderResponseForm
initialFormData["createdResources"] = reqObj.grantedResources
else:
provider = False
formClass = ResponseForm
@ -92,7 +94,7 @@ def rrequestDetail(request, pk):
return HttpResponseRedirect(reverse("rrequests:show", args=(pk,)))
else:
form = formClass(request=reqObj, user=request.user)
form = formClass(request=reqObj, user=request.user, initial=initialFormData)
return render(request, "rrequests/request_detail.html", {"request": reqObj, "form": form})

View File

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