Fix minor bug

This commit is contained in:
zandercymatics 2024-04-11 16:05:42 -06:00
parent 1d6c06208d
commit 61b71c298e
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 12 additions and 10 deletions

View file

@ -801,7 +801,7 @@ class WebsiteAdmin(ListHeaderAdmin):
def response_change(self, request, obj):
"""
Override to redirect users back to the same page after saving.
Override to redirect users back to the previous page after saving.
"""
superuser_perm = request.user.has_perm("registrar.full_access_permission")
analyst_perm = request.user.has_perm("registrar.analyst_access_permission")
@ -1956,19 +1956,17 @@ class DraftDomainAdmin(ListHeaderAdmin):
def response_change(self, request, obj):
"""
Override to redirect users back to the same page after saving.
Override to redirect users back to the previous page after saving.
"""
superuser_perm = request.user.has_perm("registrar.full_access_permission")
analyst_perm = request.user.has_perm("registrar.analyst_access_permission")
return_path = request.GET.get('return_path')
# Don't redirect to the website page on save if the user is an analyst.
# Rather, just redirect back to the same change page.
if analyst_perm and not superuser_perm:
opts = obj._meta
pk_value = obj._get_pk_val()
return HttpResponseRedirect(
reverse("admin:%s_%s_change" % (opts.app_label, opts.model_name), args=(pk_value,))
)
# Rather, just redirect back to the originating page.
if (analyst_perm and not superuser_perm) and return_path:
# Redirect to the return path if it exists
return HttpResponseRedirect(return_path)
return super().response_change(request, obj)

View file

@ -27,6 +27,10 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
</dl>
</div>
{% endif %}
{% elif field.field.name == "requested_domain" %}
{% with current_path=request.get_full_path %}
<a class="margin-top-05 padding-top-05" href="{% url 'admin:registrar_draftdomain_change' original.requested_domain.id %}?{{ 'return_path='|add:current_path }}">{{ original.requested_domain }}</a>
{% endwith%}
{% elif field.field.name == "current_websites" %}
{% comment %}
The "website" model is essentially just a text field.