mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 01:57:03 +02:00
Redirect and basic changes
This commit is contained in:
parent
87bb71a214
commit
bd0edf7203
9 changed files with 124 additions and 44 deletions
|
@ -160,6 +160,17 @@ class DomainAdmin(ListHeaderAdmin):
|
|||
|
||||
return super().response_change(request, obj)
|
||||
|
||||
# Sets domain_id as a context var
|
||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||
extra_context = extra_context or {}
|
||||
extra_context["domain_id"] = object_id
|
||||
return super().change_view(
|
||||
request,
|
||||
object_id,
|
||||
form_url,
|
||||
extra_context=extra_context,
|
||||
)
|
||||
|
||||
|
||||
class ContactAdmin(ListHeaderAdmin):
|
||||
|
||||
|
|
|
@ -170,3 +170,24 @@ table > caption > a {
|
|||
.min-width-81 {
|
||||
min-width: 81px;
|
||||
}
|
||||
|
||||
.buttonAdminPadding {
|
||||
background: var(--button-bg);
|
||||
padding: 10px 15px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
color: var(--button-fg);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
}
|
||||
|
||||
.submit-row input {
|
||||
height: 2.1875rem;
|
||||
line-height: 0.9375rem;
|
||||
}
|
||||
|
||||
a.button{
|
||||
font-size: 100% !important;
|
||||
padding: 9px 15px !important;
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
{% block field_sets %}
|
||||
<div class="submit-row">
|
||||
<a href="{% url 'domain' domain_id %}" class="button" >Edit domain</a>
|
||||
<input type="submit" value="Place hold" name="_place_client_hold">
|
||||
</div>
|
||||
{{ block.super }}
|
||||
|
|
|
@ -19,16 +19,29 @@
|
|||
|
||||
<div class="tablet:grid-col-9">
|
||||
<main id="main-content" class="grid-container">
|
||||
|
||||
{% if not is_analyst_or_superuser %}
|
||||
<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>
|
||||
|
||||
</a>
|
||||
{% elif is_analyst_or_superuser%}
|
||||
<a href="{% url 'admin:registrar_domain_change' domain.id%}" 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 %}
|
||||
{# messages block is under the back breadcrumb link #}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
|
|
|
@ -4,24 +4,38 @@
|
|||
{% block domain_content %}
|
||||
{{ block.super }}
|
||||
<div class="margin-top-4 tablet:grid-col-10">
|
||||
|
||||
{% url 'domain-nameservers' pk=domain.id as url %}
|
||||
{% 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 %}
|
||||
{% else %}
|
||||
{% include "includes/summary_item.html" with title='DNS name servers' value=domain.nameservers list='true' %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<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>
|
||||
<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 %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% 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 %}
|
||||
{% if is_original_creator %}
|
||||
{% 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' %}
|
||||
{% endif %}
|
||||
|
||||
{% 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 %}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
Domain overview
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if is_original_creator %}
|
||||
<li class="usa-sidenav__item">
|
||||
{% url 'domain-nameservers' pk=domain.id as url %}
|
||||
<a href="{{ url }}"
|
||||
|
@ -20,7 +20,7 @@
|
|||
DNS name servers
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
<li class="usa-sidenav__item">
|
||||
{% url 'domain-org-name-address' pk=domain.id as url %}
|
||||
<a href="{{ url }}"
|
||||
|
@ -29,7 +29,7 @@
|
|||
Organization name and mailing address
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if is_original_creator %}
|
||||
<li class="usa-sidenav__item">
|
||||
{% url 'domain-authorizing-official' pk=domain.id as url %}
|
||||
<a href="{{ url }}"
|
||||
|
@ -38,7 +38,8 @@
|
|||
Authorizing official
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
{% if is_original_creator %}
|
||||
<li class="usa-sidenav__item">
|
||||
{% url 'domain-your-contact-information' pk=domain.id as url %}
|
||||
<a href="{{ url }}"
|
||||
|
@ -47,7 +48,7 @@
|
|||
Your contact information
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% endif %}
|
||||
<li class="usa-sidenav__item">
|
||||
{% url 'domain-security-email' pk=domain.id as url %}
|
||||
<a href="{{ url }}"
|
||||
|
|
|
@ -38,7 +38,6 @@ logger = logging.getLogger(__name__)
|
|||
class DomainView(DomainPermissionView):
|
||||
|
||||
"""Domain detail overview page."""
|
||||
|
||||
template_name = "domain_detail.html"
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
|
||||
from registrar.models import UserDomainRole, DomainApplication, DomainInvitation
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class PermissionsLoginMixin(PermissionRequiredMixin):
|
||||
|
||||
|
@ -23,6 +24,8 @@ class DomainPermission(PermissionsLoginMixin):
|
|||
|
||||
The user is in self.request.user and the domain needs to be looked
|
||||
up from the domain's primary key in self.kwargs["pk"]
|
||||
|
||||
analysts and superusers are exempt
|
||||
"""
|
||||
|
||||
# ticket 806
|
||||
|
@ -33,10 +36,15 @@ class DomainPermission(PermissionsLoginMixin):
|
|||
if not self.request.user.is_authenticated:
|
||||
return False
|
||||
|
||||
# user needs to be the creator of the application
|
||||
# this query is empty if there isn't a domain application with this
|
||||
# id and this user as creator
|
||||
user_is_creator: bool = DomainApplication.objects.filter(
|
||||
creator=self.request.user, id=self.kwargs["pk"]
|
||||
).exists()
|
||||
user_is_analyst_or_superuser = self.request.user.is_staff or self.request.user.is_superuser
|
||||
# user needs to have a role on the domain
|
||||
if not UserDomainRole.objects.filter(
|
||||
user=self.request.user, domain__id=self.kwargs["pk"]
|
||||
).exists():
|
||||
if not user_is_creator and not user_is_analyst_or_superuser:
|
||||
return False
|
||||
|
||||
# ticket 796
|
||||
|
|
|
@ -5,14 +5,15 @@ import abc # abstract base class
|
|||
from django.views.generic import DetailView, DeleteView
|
||||
|
||||
from registrar.models import Domain, DomainApplication, DomainInvitation
|
||||
from registrar.models.domain_information import DomainInformation
|
||||
|
||||
from .mixins import (
|
||||
DomainPermission,
|
||||
DomainApplicationPermission,
|
||||
DomainInvitationPermission,
|
||||
)
|
||||
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
class DomainPermissionView(DomainPermission, DetailView, abc.ABC):
|
||||
|
||||
"""Abstract base view for domains that enforces permissions.
|
||||
|
@ -26,6 +27,17 @@ class DomainPermissionView(DomainPermission, DetailView, abc.ABC):
|
|||
# variable name in template context for the model object
|
||||
context_object_name = "domain"
|
||||
|
||||
# Adds context information for user permissions
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
user = self.request.user
|
||||
context['primary_key'] = self.kwargs["pk"]
|
||||
context['is_analyst_or_superuser'] = user.is_superuser or user.is_staff
|
||||
context['is_original_creator'] = DomainInformation.objects.filter(
|
||||
creator=self.request.user, id=self.kwargs["pk"]
|
||||
).exists()
|
||||
return context
|
||||
|
||||
# Abstract property enforces NotImplementedError on an attribute.
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue