mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-29 14:06:32 +02:00
Linter, reordered logic
This commit is contained in:
parent
a2572d0c73
commit
376aa30e1e
4 changed files with 24 additions and 21 deletions
|
@ -191,7 +191,8 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
)
|
)
|
||||||
|
|
||||||
def has_change_permission(self, request, obj=None):
|
def has_change_permission(self, request, obj=None):
|
||||||
# Fixes a bug wherein users which are only is_staff can access 'change' when GET,
|
# Fixes a bug wherein users which are only is_staff
|
||||||
|
# can access 'change' when GET,
|
||||||
# but cannot access this page when it is a request of type POST.
|
# but cannot access this page when it is a request of type POST.
|
||||||
if request.user.is_staff:
|
if request.user.is_staff:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
{% if not is_analyst_or_superuser or not analyst_action %}
|
{% if not is_analyst_or_superuser or not analyst_action or analyst_action_location != domain.pk %}
|
||||||
<p class="font-body-md margin-top-0 margin-bottom-2
|
<p class="font-body-md margin-top-0 margin-bottom-2
|
||||||
text-primary-darker text-semibold"
|
text-primary-darker text-semibold"
|
||||||
>
|
>
|
||||||
|
@ -21,18 +21,8 @@
|
||||||
|
|
||||||
<div class="tablet:grid-col-9">
|
<div class="tablet:grid-col-9">
|
||||||
<main id="main-content" class="grid-container">
|
<main id="main-content" class="grid-container">
|
||||||
{% if not is_analyst_or_superuser or not analyst_action %}
|
|
||||||
<a href="{% url 'home' %}" class="breadcrumb__back">
|
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
|
||||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
{% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %}
|
||||||
Back to manage your domains
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</a>
|
|
||||||
{% elif is_analyst_or_superuser and analyst_action == 'edit' %}
|
|
||||||
<div class="usa-alert usa-alert--warning">
|
<div class="usa-alert usa-alert--warning">
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
<h4 class="usa-alert__heading larger-font-sizing ">Attention!</h4>
|
<h4 class="usa-alert__heading larger-font-sizing ">Attention!</h4>
|
||||||
|
@ -41,6 +31,16 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'home' %}" class="breadcrumb__back">
|
||||||
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||||
|
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
||||||
|
Back to manage your domains
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{# messages block is under the back breadcrumb link #}
|
{# messages block is under the back breadcrumb link #}
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
|
|
|
@ -58,10 +58,10 @@ class DomainPermission(PermissionsLoginMixin):
|
||||||
|
|
||||||
except DomainInformation.DoesNotExist:
|
except DomainInformation.DoesNotExist:
|
||||||
# Q: While testing, I saw that, application-wide, if you go to a domain
|
# Q: While testing, I saw that, application-wide, if you go to a domain
|
||||||
# that does not exist (i.e: https://getgov-staging.app.cloud.gov/domain/73333),
|
# that does not exist, for example,
|
||||||
# the page throws a 403 error,
|
# https://getgov-staging.app.cloud.gov/domain/73333,
|
||||||
# instead of a 404. This fixes that behaviour,
|
# the page throws a 403 error, instead of a 404.
|
||||||
# but do we want it to throw a 403 instead?
|
# This fixes that behaviour, but do we want it to throw a 403 instead?
|
||||||
# Basically, should this be logger.debug()?
|
# Basically, should this be logger.debug()?
|
||||||
raise Http404()
|
raise Http404()
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import abc # abstract base class
|
||||||
from django.views.generic import DetailView, DeleteView
|
from django.views.generic import DetailView, DeleteView
|
||||||
|
|
||||||
from registrar.models import Domain, DomainApplication, DomainInvitation
|
from registrar.models import Domain, DomainApplication, DomainInvitation
|
||||||
from registrar.models.domain_information import DomainInformation
|
|
||||||
|
|
||||||
from .mixins import (
|
from .mixins import (
|
||||||
DomainPermission,
|
DomainPermission,
|
||||||
|
@ -35,11 +35,13 @@ class DomainPermissionView(DomainPermission, DetailView, abc.ABC):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
|
|
||||||
context["is_analyst_or_superuser"] = user.is_superuser or user.is_staff
|
context["is_analyst_or_superuser"] = user.is_staff or user.is_superuser
|
||||||
# Flag to see if an analyst is attempting to make edits
|
# Flag to see if an analyst is attempting to make edits
|
||||||
if "analyst_action" in self.request.session:
|
if "analyst_action" in self.request.session:
|
||||||
context["analyst_action"] = self.request.session["analyst_action"]
|
# Stored in a variable for the linter
|
||||||
context["analyst_action_location"] = self.request.session["analyst_action_location"]
|
action = "analyst_action"
|
||||||
|
context[action] = self.request.session[action]
|
||||||
|
context[f"{action}_location"] = self.request.session[f"{action}_location"]
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue