mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-20 09:46:06 +02:00
Changes
This commit is contained in:
parent
fc101e8676
commit
00d475f3a6
8 changed files with 54 additions and 47 deletions
|
@ -6,6 +6,7 @@ from django.http.response import HttpResponseRedirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,8 +142,10 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
readonly_fields = ["state"]
|
readonly_fields = ["state"]
|
||||||
|
|
||||||
def response_change(self, request, obj):
|
def response_change(self, request, obj):
|
||||||
ACTION_BUTTON = "_place_client_hold"
|
PLACE_HOLD = "_place_client_hold"
|
||||||
if ACTION_BUTTON in request.POST:
|
EDIT_DOMAIN = "_edit_domain"
|
||||||
|
if PLACE_HOLD in request.POST:
|
||||||
|
logger.debug("Hit!")
|
||||||
try:
|
try:
|
||||||
obj.place_client_hold()
|
obj.place_client_hold()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -157,11 +160,17 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
% obj.name,
|
% obj.name,
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
|
elif EDIT_DOMAIN in request.POST:
|
||||||
|
# We want to know, globally, when an edit action occurs
|
||||||
|
request.session['analyst_action'] = 'edit'
|
||||||
|
return HttpResponseRedirect(reverse('domain', args=(obj.id,)))
|
||||||
return super().response_change(request, obj)
|
return super().response_change(request, obj)
|
||||||
|
|
||||||
# Sets domain_id as a context var
|
# Sets domain_id as a context var
|
||||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||||
|
if 'analyst_action' in request.session:
|
||||||
|
# If an analyst performed an edit action,
|
||||||
|
# delete the session variable
|
||||||
|
del request.session['analyst_action']
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
extra_context["domain_id"] = object_id
|
extra_context["domain_id"] = object_id
|
||||||
return super().change_view(
|
return super().change_view(
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
{% block field_sets %}
|
{% block field_sets %}
|
||||||
<div class="submit-row">
|
<div class="submit-row">
|
||||||
<a href="{% url 'domain' domain_id %}" class="button" >Edit domain</a>
|
|
||||||
|
<input type="hidden" value="edit" name="analyst_action">
|
||||||
|
<input type="submit" value="Edit Domain" name="_edit_domain">
|
||||||
<input type="submit" value="Place hold" name="_place_client_hold">
|
<input type="submit" value="Place hold" name="_place_client_hold">
|
||||||
</div>
|
</div>
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<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 is_original_creator %}
|
{% if not is_analyst_or_superuser or not analyst_action%}
|
||||||
<a href="{% url 'home' %}" class="breadcrumb__back">
|
<a href="{% url 'home' %}" class="breadcrumb__back">
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||||
|
@ -30,14 +30,14 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
{% elif is_analyst_or_superuser%}
|
{% elif is_analyst_or_superuser and analyst_action == 'edit' %}
|
||||||
<a href="{% url 'admin:registrar_domain_change' domain.id%}" class="breadcrumb__back">
|
<a href="{% url 'admin:registrar_domain_change' domain.id%}" class="breadcrumb__back">
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||||
</svg>
|
</svg>
|
||||||
{# Q: should this be 'Back to .gov admin' or 'Back to manage your domains'? #}
|
{# Q: For analysts, should this be 'Back to .gov admin' or 'Back to change domain'? #}
|
||||||
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
||||||
Back to change domain
|
Back to manage your domains
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -6,36 +6,20 @@
|
||||||
<div class="margin-top-4 tablet:grid-col-10">
|
<div class="margin-top-4 tablet:grid-col-10">
|
||||||
{% url 'domain-nameservers' pk=domain.id as url %}
|
{% url 'domain-nameservers' pk=domain.id as url %}
|
||||||
{% if domain.nameservers %}
|
{% if domain.nameservers %}
|
||||||
{% if is_original_creator %}
|
{% include "includes/summary_item.html" with title='DNS name servers' value=domain.nameservers list='true' edit_link=url %}
|
||||||
{% include "includes/summary_item.html" with title='DNS name servers' value=domain.nameservers list='true' edit_link=url %}
|
|
||||||
{% else %}
|
|
||||||
{% include "includes/summary_item.html" with title='DNS name servers' value=domain.nameservers list='true' %}
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<h2 class="margin-top-neg-1"> DNS name servers </h2>
|
<h2 class="margin-top-neg-1"> DNS name servers </h2>
|
||||||
{% if is_original_creator %}
|
|
||||||
<p> No DNS name servers have been added yet. Before your domain can be used we’ll need information about your domain name servers.</p>
|
<p> No DNS name servers have been added yet. Before your domain can be used we’ll need information about your domain name servers.</p>
|
||||||
<a class="usa-button margin-bottom-1" href="{{url}}"> Add DNS name servers </a>
|
<a class="usa-button margin-bottom-1" href="{{url}}"> Add DNS name servers </a>
|
||||||
{% else %}
|
|
||||||
<p>No DNS name servers have been added yet.</p>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% url 'domain-org-name-address' pk=domain.id as url %}
|
{% url 'domain-org-name-address' pk=domain.id as url %}
|
||||||
{% include "includes/summary_item.html" with title='Organization name and mailing address' value=domain.domain_info address='true' edit_link=url %}
|
{% include "includes/summary_item.html" with title='Organization name and mailing address' value=domain.domain_info address='true' edit_link=url %}
|
||||||
|
|
||||||
{% url 'domain-authorizing-official' pk=domain.id as url %}
|
{% url 'domain-authorizing-official' pk=domain.id as url %}
|
||||||
{% if is_original_creator %}
|
{% include "includes/summary_item.html" with title='Authorizing official' value=domain.domain_info.authorizing_official contact='true' edit_link=url %}
|
||||||
{% include "includes/summary_item.html" with title='Authorizing official' value=domain.domain_info.authorizing_official contact='true' edit_link=url %}
|
|
||||||
{% else %}
|
|
||||||
{% include "includes/summary_item.html" with title='Authorizing official' value=domain.domain_info.authorizing_official contact='true'%}
|
|
||||||
{% endif %}
|
|
||||||
{% url 'domain-your-contact-information' pk=domain.id as url %}
|
{% url 'domain-your-contact-information' pk=domain.id as url %}
|
||||||
{% if is_original_creator %}
|
{% include "includes/summary_item.html" with title='Your contact information' value=request.user.contact contact='true' edit_link=url %}
|
||||||
{% include "includes/summary_item.html" with title='Your contact information' value=request.user.contact contact='true' edit_link=url %}
|
|
||||||
{% else %}
|
|
||||||
{% include "includes/summary_item.html" with title='Contact information' value=request.user.contact contact='true' edit_link=url %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% url 'domain-security-email' pk=domain.id as url %}
|
{% url 'domain-security-email' pk=domain.id as url %}
|
||||||
{% include "includes/summary_item.html" with title='Security email' value=domain.security_email edit_link=url %}
|
{% include "includes/summary_item.html" with title='Security email' value=domain.security_email edit_link=url %}
|
||||||
|
|
|
@ -8,11 +8,8 @@
|
||||||
{% include "includes/form_errors.html" with form=form %}
|
{% include "includes/form_errors.html" with form=form %}
|
||||||
|
|
||||||
<h1>Organization name and mailing address </h1>
|
<h1>Organization name and mailing address </h1>
|
||||||
{% if is_original_creator %}
|
|
||||||
<p>The name of your organization will be publicly listed as the domain registrant.</p>
|
<p>The name of your organization will be publicly listed as the domain registrant.</p>
|
||||||
{% else %}
|
|
||||||
<p>The name of the organization will be publicly listed as the domain registrant.</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% include "includes/required_fields.html" %}
|
{% include "includes/required_fields.html" %}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
Domain overview
|
Domain overview
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if is_original_creator %}
|
|
||||||
<li class="usa-sidenav__item">
|
<li class="usa-sidenav__item">
|
||||||
{% url 'domain-nameservers' pk=domain.id as url %}
|
{% url 'domain-nameservers' pk=domain.id as url %}
|
||||||
<a href="{{ url }}"
|
<a href="{{ url }}"
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
DNS name servers
|
DNS name servers
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
|
||||||
<li class="usa-sidenav__item">
|
<li class="usa-sidenav__item">
|
||||||
{% url 'domain-org-name-address' pk=domain.id as url %}
|
{% url 'domain-org-name-address' pk=domain.id as url %}
|
||||||
<a href="{{ url }}"
|
<a href="{{ url }}"
|
||||||
|
@ -29,7 +27,6 @@
|
||||||
Organization name and mailing address
|
Organization name and mailing address
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if is_original_creator %}
|
|
||||||
<li class="usa-sidenav__item">
|
<li class="usa-sidenav__item">
|
||||||
{% url 'domain-authorizing-official' pk=domain.id as url %}
|
{% url 'domain-authorizing-official' pk=domain.id as url %}
|
||||||
<a href="{{ url }}"
|
<a href="{{ url }}"
|
||||||
|
@ -38,17 +35,12 @@
|
||||||
Authorizing official
|
Authorizing official
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
|
||||||
<li class="usa-sidenav__item">
|
<li class="usa-sidenav__item">
|
||||||
{% url 'domain-your-contact-information' pk=domain.id as url %}
|
{% url 'domain-your-contact-information' pk=domain.id as url %}
|
||||||
<a href="{{ url }}"
|
<a href="{{ url }}"
|
||||||
{% if request.path == url %}class="usa-current"{% endif %}
|
{% if request.path == url %}class="usa-current"{% endif %}
|
||||||
>
|
>
|
||||||
{% if is_original_creator %}
|
Your contact information
|
||||||
Your contact information
|
|
||||||
{% else %}
|
|
||||||
Contact information
|
|
||||||
{% endif %}
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,28 @@ class DomainOrgNameAddressView(DomainPermissionView, FormMixin):
|
||||||
messages.success(
|
messages.success(
|
||||||
self.request, "The organization name and mailing address has been updated."
|
self.request, "The organization name and mailing address has been updated."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If the user is not privileged, don't do any special checks
|
||||||
|
if not self.request.user.is_staff and not self.request.user.is_superuser:
|
||||||
|
# superclass has the redirect
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
# Otherwise, if they are editing from an '/admin' redirect, log their actions
|
||||||
|
# Q: do we want to be logging on every changed field?
|
||||||
|
# I could see that becoming spammy log-wise, but it may also be important.
|
||||||
|
# To do so, I'd likely have to override some of the save() functionality of ModelForm.
|
||||||
|
if 'analyst_action' in self.request.session:
|
||||||
|
action = self.request.session['analyst_action']
|
||||||
|
|
||||||
|
# Template for future expansion,
|
||||||
|
# in the event we want more logging granularity.
|
||||||
|
# Could include things such as 'view'
|
||||||
|
# or 'copy', for instance.
|
||||||
|
match action:
|
||||||
|
case 'edit':
|
||||||
|
if(self.request.user.is_staff):
|
||||||
|
logger.info("Analyst {} edited {} for {}".format(self.request.user, type(form_class).__name__, self.get_object().domain_info))
|
||||||
|
|
||||||
# superclass has the redirect
|
# superclass has the redirect
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
|
@ -37,13 +37,14 @@ class DomainPermissionView(DomainPermission, DetailView, abc.ABC):
|
||||||
is_original_creator = DomainInformation.objects.filter(
|
is_original_creator = DomainInformation.objects.filter(
|
||||||
creator_id=self.request.user.id, id=self.kwargs["pk"]
|
creator_id=self.request.user.id, id=self.kwargs["pk"]
|
||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
context['primary_key'] = self.kwargs["pk"]
|
|
||||||
context['is_analyst_or_superuser'] = user.is_superuser or user.is_staff
|
|
||||||
context['is_original_creator'] = is_original_creator
|
context['is_original_creator'] = is_original_creator
|
||||||
context['is_active_user'] = DomainInformation.objects.filter(
|
context['is_analyst_or_superuser'] = user.is_superuser or user.is_staff
|
||||||
id=self.kwargs["pk"]
|
|
||||||
)
|
# Flag to see if an analyst is attempting to make edits
|
||||||
|
if 'analyst_action' in self.request.session:
|
||||||
|
context['analyst_action'] = self.request.session['analyst_action']
|
||||||
|
# Clear the session variable after use
|
||||||
|
# del self.request.session['analyst_action']
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue