mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 19:09:22 +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."""
|
||||
logger.error(error)
|
||||
if isinstance(error, o_e.AuthenticationFailed):
|
||||
context={
|
||||
context = {
|
||||
"friendly_message": error.friendly_message,
|
||||
"log_identifier": error.locator,
|
||||
}
|
||||
return custom_401_error_view(request, context)
|
||||
if isinstance(error, o_e.InternalError):
|
||||
context={
|
||||
context = {
|
||||
"friendly_message": error.friendly_message,
|
||||
"log_identifier": error.locator,
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
For more information see:
|
||||
https://docs.djangoproject.com/en/4.0/topics/http/urls/
|
||||
"""
|
||||
from django.conf.urls import handler500
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
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
|
||||
# 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"
|
||||
|
||||
# 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,
|
||||
while non-subordinate hosts MUST NOT.
|
||||
"""
|
||||
raise ValueError("test")
|
||||
try:
|
||||
# attempt to retrieve hosts from registry and store in cache and db
|
||||
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.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 django.urls import reverse
|
||||
|
||||
|
@ -135,4 +135,3 @@ class TestEnvironmentVariablesEffects(TestCase):
|
|||
self.assertEqual(contact_page_500.status_code, 500)
|
||||
|
||||
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
|
||||
|
||||
|
||||
def custom_500_error_view(request, context=None):
|
||||
"""Used to redirect 500 errors to a custom view"""
|
||||
if context is None:
|
||||
|
@ -8,6 +23,7 @@ def custom_500_error_view(request, context=None):
|
|||
else:
|
||||
return render(request, "500.html", context=context, status=500)
|
||||
|
||||
|
||||
def custom_401_error_view(request, context=None):
|
||||
"""Used to redirect 401 errors to a custom view"""
|
||||
if context is None:
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import abc # abstract base class
|
||||
|
||||
from django.conf import settings
|
||||
from django.views.generic import DetailView, DeleteView, TemplateView
|
||||
from registrar.models import Domain, DomainRequest, DomainInvitation
|
||||
from registrar.models.user_domain_role import UserDomainRole
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue