mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-20 03:19:24 +02:00
Linting activities
This commit is contained in:
parent
b4829d650a
commit
361392ba71
6 changed files with 29 additions and 8 deletions
|
@ -50,13 +50,13 @@ def error_page(request, error):
|
||||||
"""Display a sensible message and log the error."""
|
"""Display a sensible message and log the error."""
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
if isinstance(error, o_e.AuthenticationFailed):
|
if isinstance(error, o_e.AuthenticationFailed):
|
||||||
context={
|
context = {
|
||||||
"friendly_message": error.friendly_message,
|
"friendly_message": error.friendly_message,
|
||||||
"log_identifier": error.locator,
|
"log_identifier": error.locator,
|
||||||
}
|
}
|
||||||
return custom_401_error_view(request, context)
|
return custom_401_error_view(request, context)
|
||||||
if isinstance(error, o_e.InternalError):
|
if isinstance(error, o_e.InternalError):
|
||||||
context={
|
context = {
|
||||||
"friendly_message": error.friendly_message,
|
"friendly_message": error.friendly_message,
|
||||||
"log_identifier": error.locator,
|
"log_identifier": error.locator,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
For more information see:
|
For more information see:
|
||||||
https://docs.djangoproject.com/en/4.0/topics/http/urls/
|
https://docs.djangoproject.com/en/4.0/topics/http/urls/
|
||||||
"""
|
"""
|
||||||
from django.conf.urls import handler500
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
|
@ -151,6 +151,14 @@ urlpatterns = [
|
||||||
|
|
||||||
# Djangooidc strips out context data from that context, so we define a custom error
|
# Djangooidc strips out context data from that context, so we define a custom error
|
||||||
# view through this method.
|
# view through this method.
|
||||||
|
# If Djangooidc is left to its own devices and uses reverse directly,
|
||||||
|
# then both context and session information will be obliterated due to:
|
||||||
|
|
||||||
|
# a) Djangooidc being out of scope for context_processors
|
||||||
|
# b) Potential cyclical import errors restricting what kind of data is passable.
|
||||||
|
|
||||||
|
# Rather than dealing with that, we keep everything centralized in one location.
|
||||||
|
# This way, we can share a view for djangooidc, and other pages as we see fit.
|
||||||
handler500 = "registrar.views.utility.error_views.custom_500_error_view"
|
handler500 = "registrar.views.utility.error_views.custom_500_error_view"
|
||||||
|
|
||||||
# we normally would guard these with `if settings.DEBUG` but tests run with
|
# we normally would guard these with `if settings.DEBUG` but tests run with
|
||||||
|
|
|
@ -325,7 +325,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
Subordinate hosts (something.your-domain.gov) MUST have IP addresses,
|
Subordinate hosts (something.your-domain.gov) MUST have IP addresses,
|
||||||
while non-subordinate hosts MUST NOT.
|
while non-subordinate hosts MUST NOT.
|
||||||
"""
|
"""
|
||||||
raise ValueError("test")
|
|
||||||
try:
|
try:
|
||||||
# attempt to retrieve hosts from registry and store in cache and db
|
# attempt to retrieve hosts from registry and store in cache and db
|
||||||
hosts = self._get_property("hosts")
|
hosts = self._get_property("hosts")
|
||||||
|
|
|
@ -6,7 +6,7 @@ from registrar.models.domain import Domain
|
||||||
from registrar.models.user_domain_role import UserDomainRole
|
from registrar.models.user_domain_role import UserDomainRole
|
||||||
from registrar.views.domain import DomainNameserversView
|
from registrar.views.domain import DomainNameserversView
|
||||||
|
|
||||||
from .common import MockEppLib, less_console_noise # type: ignore
|
from .common import MockEppLib # type: ignore
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
@ -135,4 +135,3 @@ class TestEnvironmentVariablesEffects(TestCase):
|
||||||
self.assertEqual(contact_page_500.status_code, 500)
|
self.assertEqual(contact_page_500.status_code, 500)
|
||||||
|
|
||||||
self.assertNotContains(contact_page_500, "You are on a test site.")
|
self.assertNotContains(contact_page_500, "You are on a test site.")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
"""Custom views that allow for error view customization"""
|
"""
|
||||||
|
Custom views that allow for error view customization.
|
||||||
|
|
||||||
|
Used as a general handler for 500 errors both coming from the registrar app, but
|
||||||
|
also the djangooidc app.
|
||||||
|
|
||||||
|
If Djangooidc is left to its own devices and uses reverse directly,
|
||||||
|
then both context and session information will be obliterated due to:
|
||||||
|
|
||||||
|
a) Djangooidc being out of scope for context_processors
|
||||||
|
b) Potential cyclical import errors restricting what kind of data is passable.
|
||||||
|
|
||||||
|
Rather than dealing with that, we keep everything centralized in one location.
|
||||||
|
"""
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
def custom_500_error_view(request, context=None):
|
def custom_500_error_view(request, context=None):
|
||||||
"""Used to redirect 500 errors to a custom view"""
|
"""Used to redirect 500 errors to a custom view"""
|
||||||
if context is None:
|
if context is None:
|
||||||
|
@ -8,6 +23,7 @@ def custom_500_error_view(request, context=None):
|
||||||
else:
|
else:
|
||||||
return render(request, "500.html", context=context, status=500)
|
return render(request, "500.html", context=context, status=500)
|
||||||
|
|
||||||
|
|
||||||
def custom_401_error_view(request, context=None):
|
def custom_401_error_view(request, context=None):
|
||||||
"""Used to redirect 401 errors to a custom view"""
|
"""Used to redirect 401 errors to a custom view"""
|
||||||
if context is None:
|
if context is None:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import abc # abstract base class
|
import abc # abstract base class
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.views.generic import DetailView, DeleteView, TemplateView
|
from django.views.generic import DetailView, DeleteView, TemplateView
|
||||||
from registrar.models import Domain, DomainRequest, DomainInvitation
|
from registrar.models import Domain, DomainRequest, DomainInvitation
|
||||||
from registrar.models.user_domain_role import UserDomainRole
|
from registrar.models.user_domain_role import UserDomainRole
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue