prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Save a new domain application on form submission
  _Outcome_: On "save" press, save any form changes to the Application model. 
  
  Relies on #221 
  
  </issue>
  <code>
  [start of src/registrar/forms/application_wizard.py]
  1 """Forms Wizard for creating a new domain application."""
  2 
  3 import logging
  4 
  5 from django import forms
  6 
  7 from django.contrib.auth.mixins import LoginRequiredMixin
  8 
  9 from formtools.wizard.views import NamedUrlSessionWizardView  # type: ignore
  10 
  11 
  12 logger = logging.getLogger(__name__)
  13 
  14 
  15 class OrganizationForm(forms.Form):
  16     organization_type = forms.ChoiceField(
  17         required=True,
  18         choices=[
  19             ("Federal", "Federal: a federal agency"),
  20             ("Interstate", "Interstate: an organization of two or more states"),
  21             (
  22                 "State_or_Territory",
  23                 (
  24                     "State or Territory: One of the 50 U.S. states, the District of "
  25                     "Columbia, American Samoa, Guam, Northern Mariana Islands, "
  26                     "Puerto Rico, or the U.S. Virgin Islands"
  27                 ),
  28             ),
  29             (
  30                 "Tribal",
  31                 (
  32                     "Tribal: a tribal government recognized by the federal or "
  33                     "state government"
  34                 ),
  35             ),
  36             ("County", "County: a county, parish, or borough"),
  37             ("City", "City: a city, town, township, village, etc."),
  38             (
  39                 "Special_District",
  40                 "Special District: an independent organization within a single state",
  41             ),
  42         ],
  43         widget=forms.RadioSelect,
  44     )
  45     federal_type = forms.ChoiceField(
  46         required=False,
  47         choices=[
  48             ("Executive", "Executive"),
  49             ("Judicial", "Judicial"),
  50             ("Legislative", "Legislative"),
  51         ],
  52         widget=forms.RadioSelect,
  53     )
  54     is_election_board = forms.ChoiceField(
  55         required=False,
  56         choices=[
  57             ("Yes", "Yes"),
  58             ("No", "No"),
  59         ],
  60         widget=forms.RadioSelect,
  61     )
  62 
  63 
  64 class ContactForm(forms.Form):
  65     organization_name = forms.CharField(label="Organization Name")
  66     street_address = forms.CharField(label="Street address")
  67 
  68 
  69 # List of forms in our wizard. Each entry is a tuple of a name and a form
  70 # subclass
  71 FORMS = [
  72     ("organization", OrganizationForm),
  73     ("contact", ContactForm),
  74 ]
  75 
  76 # Dict to match up the right template with the right step. Keys here must
  77 # match the first elements of the tuples in FORMS
  78 TEMPLATES = {
  79     "organization": "application_organization.html",
  80     "contact": "application_contact.html",
  81 }
  82 
  83 # We need to pass our page titles as context to the templates, indexed
  84 # by the step names
  85 TITLES = {
  86     "organization": "About your organization",
  87     "contact": "Your organization's contact information",
  88 }
  89 
  90 
  91 class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
  92 
  93     """Multi-page form ("wizard") for new domain applications.
  94 
  95     This sets up a sequence of forms that gather information for new
  96     domain applications. Each form in the sequence has its own URL and
  97     the progress through the form is stored in the Django session (thus
  98     "NamedUrlSessionWizardView").
  99     """
  100 
  101     form_list = FORMS
  102 
  103     def get_template_names(self):
  104         """Template for the current step.
  105 
  106         The return is a singleton list.
  107         """
  108         return [TEMPLATES[self.steps.current]]
  109 
  110     def get_context_data(self, form, **kwargs):
  111         """Add title information to the context for all steps."""
  112         context = super().get_context_data(form=form, **kwargs)
  113         context["form_titles"] = TITLES
  114         return context
  115 
  116     def done(self, form_list, **kwargs):
  117         logger.info("Application form submitted.")
  118
  [end of src/registrar/forms/application_wizard.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py
  --- a/src/registrar/forms/application_wizard.py
  +++ b/src/registrar/forms/application_wizard.py
  @@ -3,11 +3,14 @@
   import logging
   
   from django import forms
  +from django.shortcuts import redirect
   
   from django.contrib.auth.mixins import LoginRequiredMixin
   
   from formtools.wizard.views import NamedUrlSessionWizardView  # type: ignore
   
  +from registrar.models import DomainApplication, Website
  +
   
   logger = logging.getLogger(__name__)
   
  @@ -113,5 +116,33 @@
           context["form_titles"] = TITLES
           return context
   
  -    def done(self, form_list, **kwargs):
  -        logger.info("Application form submitted.")
  +    def forms_to_object(self, form_dict: dict) -> DomainApplication:
  +        """Unpack the form responses onto the model object properties."""
  +        application = DomainApplication.objects.create(creator=self.request.user)
  +
  +        # organization information
  +        organization_data = form_dict["organization"].cleaned_data
  +        application.organization_type = organization_data["organization_type"]
  +        application.federal_branch = organization_data["federal_type"]
  +        application.is_election_office = organization_data["is_election_board"]
  +
  +        # contact information
  +        contact_data = form_dict["contact"].cleaned_data
  +        application.organization_name = contact_data["organization_name"]
  +        application.street_address = contact_data["street_address"]
  +        # TODO: add the rest of these fields when they are created in the forms
  +
  +        # This isn't really the requested_domain field
  +        # but we need something in this field to make the form submittable
  +        requested_site, _ = Website.objects.get_or_create(
  +            website=contact_data["organization_name"] + ".gov"
  +        )
  +        application.requested_domain = requested_site
  +        return application
  +
  +    def done(self, form_list, form_dict, **kwargs):
  +        application = self.forms_to_object(form_dict)
  +        application.submit()  # change the status to submitted
  +        application.save()
  +        logger.debug("Application object saved:", application.id)
  +        return redirect("home")
  
verification_info: {"golden_diff": "diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py\n--- a/src/registrar/forms/application_wizard.py\n+++ b/src/registrar/forms/application_wizard.py\n@@ -3,11 +3,14 @@\n import logging\n \n from django import forms\n+from django.shortcuts import redirect\n \n from django.contrib.auth.mixins import LoginRequiredMixin\n \n from formtools.wizard.views import NamedUrlSessionWizardView  # type: ignore\n \n+from registrar.models import DomainApplication, Website\n+\n \n logger = logging.getLogger(__name__)\n \n@@ -113,5 +116,33 @@\n         context[\"form_titles\"] = TITLES\n         return context\n \n-    def done(self, form_list, **kwargs):\n-        logger.info(\"Application form submitted.\")\n+    def forms_to_object(self, form_dict: dict) -> DomainApplication:\n+        \"\"\"Unpack the form responses onto the model object properties.\"\"\"\n+        application = DomainApplication.objects.create(creator=self.request.user)\n+\n+        # organization information\n+        organization_data = form_dict[\"organization\"].cleaned_data\n+        application.organization_type = organization_data[\"organization_type\"]\n+        application.federal_branch = organization_data[\"federal_type\"]\n+        application.is_election_office = organization_data[\"is_election_board\"]\n+\n+        # contact information\n+        contact_data = form_dict[\"contact\"].cleaned_data\n+        application.organization_name = contact_data[\"organization_name\"]\n+        application.street_address = contact_data[\"street_address\"]\n+        # TODO: add the rest of these fields when they are created in the forms\n+\n+        # This isn't really the requested_domain field\n+        # but we need something in this field to make the form submittable\n+        requested_site, _ = Website.objects.get_or_create(\n+            website=contact_data[\"organization_name\"] + \".gov\"\n+        )\n+        application.requested_domain = requested_site\n+        return application\n+\n+    def done(self, form_list, form_dict, **kwargs):\n+        application = self.forms_to_object(form_dict)\n+        application.submit()  # change the status to submitted\n+        application.save()\n+        logger.debug(\"Application object saved:\", application.id)\n+        return redirect(\"home\")\n", "issue": "Save a new domain application on form submission\n_Outcome_: On \"save\" press, save any form changes to the Application model. \n\nRelies on #221 \n", "before_files": [{"content": "\"\"\"Forms Wizard for creating a new domain application.\"\"\"\n\nimport logging\n\nfrom django import forms\n\nfrom django.contrib.auth.mixins import LoginRequiredMixin\n\nfrom formtools.wizard.views import NamedUrlSessionWizardView  # type: ignore\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass OrganizationForm(forms.Form):\n    organization_type = forms.ChoiceField(\n        required=True,\n        choices=[\n            (\"Federal\", \"Federal: a federal agency\"),\n            (\"Interstate\", \"Interstate: an organization of two or more states\"),\n            (\n                \"State_or_Territory\",\n                (\n                    \"State or Territory: One of the 50 U.S. states, the District of \"\n                    \"Columbia, American Samoa, Guam, Northern Mariana Islands, \"\n                    \"Puerto Rico, or the U.S. Virgin Islands\"\n                ),\n            ),\n            (\n                \"Tribal\",\n                (\n                    \"Tribal: a tribal government recognized by the federal or \"\n                    \"state government\"\n                ),\n            ),\n            (\"County\", \"County: a county, parish, or borough\"),\n            (\"City\", \"City: a city, town, township, village, etc.\"),\n            (\n                \"Special_District\",\n                \"Special District: an independent organization within a single state\",\n            ),\n        ],\n        widget=forms.RadioSelect,\n    )\n    federal_type = forms.ChoiceField(\n        required=False,\n        choices=[\n            (\"Executive\", \"Executive\"),\n            (\"Judicial\", \"Judicial\"),\n            (\"Legislative\", \"Legislative\"),\n        ],\n        widget=forms.RadioSelect,\n    )\n    is_election_board = forms.ChoiceField(\n        required=False,\n        choices=[\n            (\"Yes\", \"Yes\"),\n            (\"No\", \"No\"),\n        ],\n        widget=forms.RadioSelect,\n    )\n\n\nclass ContactForm(forms.Form):\n    organization_name = forms.CharField(label=\"Organization Name\")\n    street_address = forms.CharField(label=\"Street address\")\n\n\n# List of forms in our wizard. Each entry is a tuple of a name and a form\n# subclass\nFORMS = [\n    (\"organization\", OrganizationForm),\n    (\"contact\", ContactForm),\n]\n\n# Dict to match up the right template with the right step. Keys here must\n# match the first elements of the tuples in FORMS\nTEMPLATES = {\n    \"organization\": \"application_organization.html\",\n    \"contact\": \"application_contact.html\",\n}\n\n# We need to pass our page titles as context to the templates, indexed\n# by the step names\nTITLES = {\n    \"organization\": \"About your organization\",\n    \"contact\": \"Your organization's contact information\",\n}\n\n\nclass ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):\n\n    \"\"\"Multi-page form (\"wizard\") for new domain applications.\n\n    This sets up a sequence of forms that gather information for new\n    domain applications. Each form in the sequence has its own URL and\n    the progress through the form is stored in the Django session (thus\n    \"NamedUrlSessionWizardView\").\n    \"\"\"\n\n    form_list = FORMS\n\n    def get_template_names(self):\n        \"\"\"Template for the current step.\n\n        The return is a singleton list.\n        \"\"\"\n        return [TEMPLATES[self.steps.current]]\n\n    def get_context_data(self, form, **kwargs):\n        \"\"\"Add title information to the context for all steps.\"\"\"\n        context = super().get_context_data(form=form, **kwargs)\n        context[\"form_titles\"] = TITLES\n        return context\n\n    def done(self, form_list, **kwargs):\n        logger.info(\"Application form submitted.\")\n", "path": "src/registrar/forms/application_wizard.py"}]}