Skip to content

Commit

Permalink
Allow role_apply to redirect somewhere else.
Browse files Browse the repository at this point in the history
  • Loading branch information
amanning9 committed Feb 29, 2024
1 parent 4bacf09 commit 54e138f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions jasmin_services/templates/jasmin_services/role_apply.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<form method="POST" action="" class="form-horizontal" onsubmit="submitted.disabled = true; return true;">
{% csrf_token %}

{% block service_identity %}
<div class="form-group">
<div class="row">
<label class="col-4 text-right control-label" for="id_service"><b>Service</b></label>
Expand All @@ -33,6 +34,7 @@
</div>
</div>
</div>
{% endblock service_identity %}
{% if req or grant %}
<div class="row">
<div class="col-md-9 col-md-offset-3">
Expand Down
11 changes: 10 additions & 1 deletion jasmin_services/views/role_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import django.contrib.auth.mixins
import django.core.exceptions
import django.http
import django.urls
import django.views.generic
import django.views.generic.edit
from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -177,4 +179,11 @@ def form_valid(self, form):
form.save(req)

messages.success(self.request, "Request submitted successfully")
return common.redirect_to_service(self.service)
return django.http.HttpResponseRedirect(self.get_success_url())

def get_success_url(self):
"""Set default success url to service details page."""
return django.urls.reverse(
"jasmin_services:service_details",
kwargs={"category": self.service.category.name, "service": self.service.name},
)

0 comments on commit 54e138f

Please sign in to comment.