removed extraneous logging and code from views/application.py and application_wizard.py

This commit is contained in:
David Kennedy 2024-01-08 17:08:53 -05:00
parent 080d59c0b5
commit fd1bd09f6c
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 1 additions and 23 deletions

View file

@ -1,12 +1,10 @@
from __future__ import annotations # allows forward references in annotations from __future__ import annotations # allows forward references in annotations
from itertools import zip_longest from itertools import zip_longest
import logging import logging
import copy
from typing import Callable from typing import Callable
from phonenumber_field.formfields import PhoneNumberField # type: ignore from phonenumber_field.formfields import PhoneNumberField # type: ignore
from django import forms from django import forms
from django.forms.utils import ErrorDict
from django.core.validators import RegexValidator, MaxLengthValidator from django.core.validators import RegexValidator, MaxLengthValidator
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.db.models.fields.related import ForeignObjectRel, OneToOneField from django.db.models.fields.related import ForeignObjectRel, OneToOneField
@ -16,13 +14,9 @@ from api.views import DOMAIN_API_MESSAGES
from registrar.models import Contact, DomainApplication, DraftDomain, Domain from registrar.models import Contact, DomainApplication, DraftDomain, Domain
from registrar.templatetags.url_helpers import public_site_url from registrar.templatetags.url_helpers import public_site_url
from registrar.utility import errors from registrar.utility import errors
from django.utils.translation import gettext_lazy as _, ngettext
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
TOTAL_FORM_COUNT = 'TOTAL_FORMS'
INITIAL_FORM_COUNT = 'INITIAL_FORMS'
class RegistrarForm(forms.Form): class RegistrarForm(forms.Form):
""" """
A common set of methods and configuration. A common set of methods and configuration.
@ -688,7 +682,6 @@ class OtherContactsForm(RegistrarForm):
# That causes problems. # That causes problems.
for field in self.fields: for field in self.fields:
if field in self.errors: if field in self.errors:
logger.info(f"deleting error {self.errors[field]}")
del self.errors[field] del self.errors[field]
# return empty object with only 'delete' attribute defined. # return empty object with only 'delete' attribute defined.
# this will prevent _to_database from creating an empty # this will prevent _to_database from creating an empty

View file

@ -277,7 +277,6 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
for form in forms: for form in forms:
data = form.from_database(self.application) if self.has_pk() else None data = form.from_database(self.application) if self.has_pk() else None
if use_post: if use_post:
logger.info("about to instantiate form ")
instantiated.append(form(self.request.POST, **kwargs)) instantiated.append(form(self.request.POST, **kwargs))
elif use_db: elif use_db:
instantiated.append(form(data, **kwargs)) instantiated.append(form(data, **kwargs))
@ -371,10 +370,6 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
def post(self, request, *args, **kwargs) -> HttpResponse: def post(self, request, *args, **kwargs) -> HttpResponse:
"""This method handles POST requests.""" """This method handles POST requests."""
# Log the keys and values of request.POST
for key, value in request.POST.items():
logger.info("Key: %s, Value: %s", key, value)
# which button did the user press? # which button did the user press?
button: str = request.POST.get("submit_button", "") button: str = request.POST.get("submit_button", "")
@ -390,7 +385,6 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
return self.goto(self.steps.first) return self.goto(self.steps.first)
forms = self.get_forms(use_post=True) forms = self.get_forms(use_post=True)
logger.info("after geting forms")
if self.is_valid(forms): if self.is_valid(forms):
# always save progress # always save progress
self.save(forms) self.save(forms)
@ -492,11 +486,6 @@ class YourContact(ApplicationWizard):
class OtherContacts(ApplicationWizard): class OtherContacts(ApplicationWizard):
template_name = "application_other_contacts.html" template_name = "application_other_contacts.html"
forms = [forms.OtherContactsYesNoForm, forms.OtherContactsFormSet, forms.NoOtherContactsForm] forms = [forms.OtherContactsYesNoForm, forms.OtherContactsFormSet, forms.NoOtherContactsForm]
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
logger.info(context)
return context
def is_valid(self, forms: list) -> bool: def is_valid(self, forms: list) -> bool:
"""Overrides default behavior defined in ApplicationWizard. """Overrides default behavior defined in ApplicationWizard.
@ -511,7 +500,7 @@ class OtherContacts(ApplicationWizard):
# set all the required other_contact fields as necessary since new forms # set all the required other_contact fields as necessary since new forms
# were added through javascript # were added through javascript
for form in forms[1].forms: for form in forms[1].forms:
for field_name, field in form.fields.items(): for _, field in form.fields.items():
if field.required: if field.required:
field.widget.attrs['required'] = 'required' field.widget.attrs['required'] = 'required'
@ -520,14 +509,10 @@ class OtherContacts(ApplicationWizard):
if other_contacts_yes_no_form.is_valid(): if other_contacts_yes_no_form.is_valid():
# test for has_contacts # test for has_contacts
if other_contacts_yes_no_form.cleaned_data.get("has_other_contacts"): if other_contacts_yes_no_form.cleaned_data.get("has_other_contacts"):
logger.info("has other contacts")
# mark the no_other_contacts_form for deletion # mark the no_other_contacts_form for deletion
no_other_contacts_form.mark_form_for_deletion() no_other_contacts_form.mark_form_for_deletion()
logger.info("after marking for deletion")
# test that the other_contacts_forms and no_other_contacts_forms are valid # test that the other_contacts_forms and no_other_contacts_forms are valid
all_forms_valid = all(form.is_valid() for form in forms[1:]) all_forms_valid = all(form.is_valid() for form in forms[1:])
logger.info("after checking forms for validity")
logger.info(f"all forms valid = {all_forms_valid}")
else: else:
# mark the other_contacts_forms formset for deletion # mark the other_contacts_forms formset for deletion
other_contacts_forms.mark_formset_for_deletion() other_contacts_forms.mark_formset_for_deletion()