From ddb80bcb945d9bb614f988fd567c6c92b6670a5d Mon Sep 17 00:00:00 2001
From: jessiebelle
Date: Sun, 24 Dec 2023 17:41:35 +0200
Subject: [PATCH 01/11] adding new fields to form and sponsor model
---
sponsors/forms.py | 7 +++++
.../migrations/0099_auto_20231224_1539.py | 29 ++++++++++++++++++
sponsors/models/sponsors.py | 9 +++++-
templates/users/sponsor_info_update.html | 30 +++++++++++++++++--
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 sponsors/migrations/0099_auto_20231224_1539.py
diff --git a/sponsors/forms.py b/sponsors/forms.py
index 8d262b337..1a5fc229c 100644
--- a/sponsors/forms.py
+++ b/sponsors/forms.py
@@ -251,11 +251,18 @@ class SponsorshipApplicationForm(forms.Form):
state = forms.CharField(
label="State/Province/Region", max_length=64, required=False
)
+ state_of_incorporation = forms.CharField(
+ label="State of incorporation", help_text="US only, if different from registered state", max_length=64, required=False
+ )
postal_code = forms.CharField(
label="Zip/Postal Code", max_length=64, required=False
)
country = CountryField().formfield(required=False)
+ country_of_incorporation = CountryField().formfield(
+ label="Country of incorporation", help_text="If different from registered country", required=False
+ )
+
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None)
super().__init__(*args, **kwargs)
diff --git a/sponsors/migrations/0099_auto_20231224_1539.py b/sponsors/migrations/0099_auto_20231224_1539.py
new file mode 100644
index 000000000..065c4e786
--- /dev/null
+++ b/sponsors/migrations/0099_auto_20231224_1539.py
@@ -0,0 +1,29 @@
+# Generated by Django 2.2.24 on 2023-12-24 15:39
+
+from django.db import migrations, models
+import django_countries.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('sponsors', '0098_auto_20231219_1910'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='sponsor',
+ name='country_of_incorporation',
+ field=django_countries.fields.CountryField(blank=True, max_length=2, null=True, verbose_name='Country of incorporation (If different)'),
+ ),
+ migrations.AddField(
+ model_name='sponsor',
+ name='state_of_incorporation',
+ field=models.CharField(blank=True, default='', max_length=64, null=True, verbose_name='US only: State of incorporation (If different)'),
+ ),
+ migrations.AlterField(
+ model_name='sponsor',
+ name='country',
+ field=django_countries.fields.CountryField(default='', help_text='For mailing/contact purposes', max_length=2),
+ ),
+ ]
diff --git a/sponsors/models/sponsors.py b/sponsors/models/sponsors.py
index 9b4d8fe86..feda8fc06 100644
--- a/sponsors/models/sponsors.py
+++ b/sponsors/models/sponsors.py
@@ -71,8 +71,15 @@ class Sponsor(ContentManageable):
postal_code = models.CharField(
verbose_name="Zip/Postal Code", max_length=64, default=""
)
- country = CountryField(default="")
+ country = CountryField(default="", help_text="For mailing/contact purposes")
assets = GenericRelation(GenericAsset)
+ country_of_incorporation = CountryField(
+ verbose_name="Country of incorporation (If different)", blank=True, null=True
+ )
+ state_of_incorporation = models.CharField(
+ verbose_name="US only: State of incorporation (If different)",
+ max_length=64, blank=True, null=True, default=""
+ )
class Meta:
verbose_name = "sponsor"
diff --git a/templates/users/sponsor_info_update.html b/templates/users/sponsor_info_update.html
index 3ae2e720c..2c1da5a21 100644
--- a/templates/users/sponsor_info_update.html
+++ b/templates/users/sponsor_info_update.html
@@ -69,16 +69,29 @@ Sponsor Information
-
+
+
{{ form.country.label }} {% if form.country.errors %}
{{ form.country.errors.as_text }} {% endif %}
{% render_field form.country %}
{% if form.country.help_text %}
-
{{ form.country.help_text }}
{% endif %}
+
+
+
+ {{ form.country_of_incorporation.label }} {% if form.country_of_incorporation.errors %}
+ {{ form.country.errors.as_text }} {% endif %}
+ {% render_field form.country_of_incorporation %}
+ {% if form.country_of_incorporation.help_text %}
+
+ {{ form.country_of_incorporation.help_text }}
+ {% endif %}
+
+
+
@@ -131,8 +144,19 @@
Sponsor Information
{{ form.state.help_text }}
{% endif %}
+
+
+
+ {{ form.state_of_incorporation.label }} {% if form.state_of_incorporation.errors %}
+ {{ form.state_of_incorporation.errors.as_text }} {% endif %}
+ {% render_field form.state %}
+ {% if form.state_of_incorporation.help_text %}
+
+ {{ form.state_of_incorporation.help_text }}
+ {% endif %}
+
+
-
From dc5ff5bd7e9b1b0465317b081ad1e0bd90998156 Mon Sep 17 00:00:00 2001
From: jessiebelle
Date: Sun, 24 Dec 2023 18:13:06 +0200
Subject: [PATCH 02/11] adding new optional fields to update sponsor
application form
---
sponsors/forms.py | 6 ++--
sponsors/models/sponsors.py | 2 +-
.../new_sponsorship_application_form.html | 30 +++++++++++++++++--
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/sponsors/forms.py b/sponsors/forms.py
index 1a5fc229c..04cacd876 100644
--- a/sponsors/forms.py
+++ b/sponsors/forms.py
@@ -252,15 +252,15 @@ class SponsorshipApplicationForm(forms.Form):
label="State/Province/Region", max_length=64, required=False
)
state_of_incorporation = forms.CharField(
- label="State of incorporation", help_text="US only, if different from registered state", max_length=64, required=False
+ label="State of incorporation", help_text="US only, If different", max_length=64, required=False
)
postal_code = forms.CharField(
label="Zip/Postal Code", max_length=64, required=False
)
- country = CountryField().formfield(required=False)
+ country = CountryField().formfield(required=False, help_text="For mailing/contact purposes")
country_of_incorporation = CountryField().formfield(
- label="Country of incorporation", help_text="If different from registered country", required=False
+ label="Country of incorporation", help_text="For contractual purposes", required=False
)
def __init__(self, *args, **kwargs):
diff --git a/sponsors/models/sponsors.py b/sponsors/models/sponsors.py
index feda8fc06..7b92b0a92 100644
--- a/sponsors/models/sponsors.py
+++ b/sponsors/models/sponsors.py
@@ -74,7 +74,7 @@ class Sponsor(ContentManageable):
country = CountryField(default="", help_text="For mailing/contact purposes")
assets = GenericRelation(GenericAsset)
country_of_incorporation = CountryField(
- verbose_name="Country of incorporation (If different)", blank=True, null=True
+ verbose_name="Country of incorporation (If different)", help_text="For contractual purposes", blank=True, null=True
)
state_of_incorporation = models.CharField(
verbose_name="US only: State of incorporation (If different)",
diff --git a/templates/sponsors/new_sponsorship_application_form.html b/templates/sponsors/new_sponsorship_application_form.html
index 9f7597650..29181f80f 100644
--- a/templates/sponsors/new_sponsorship_application_form.html
+++ b/templates/sponsors/new_sponsorship_application_form.html
@@ -94,7 +94,8 @@ Submit Sponsorship Information
-
+
+
{{ form.country.label }} {% if form.country.errors %}{{ form.country.errors.as_text }} {% endif %}
{% render_field form.country %}
@@ -103,6 +104,19 @@
Submit Sponsorship Information
{{ form.country.help_text }}
{% endif %}
+
+
+
+ {{ form.country_of_incorporation.label }} {% if form.country_of_incorporation.errors %}
+ {{ form.country.errors.as_text }} {% endif %}
+ {% render_field form.country_of_incorporation %}
+ {% if form.country_of_incorporation.help_text %}
+
+ {{ form.country_of_incorporation.help_text }}
+ {% endif %}
+
+
+
@@ -149,7 +163,19 @@
Submit Sponsorship Information
{{ form.state.help_text }}
{% endif %}
-
+
+
+
+
+ {{ form.state_of_incorporation.label }} {% if form.state_of_incorporation.errors %}
+ {{ form.state_of_incorporation.errors.as_text }} {% endif %}
+ {% render_field form.state %}
+ {% if form.state_of_incorporation.help_text %}
+
+ {{ form.state_of_incorporation.help_text }}
+ {% endif %}
+
+
From 7f73df0340801610e89945964a90bcde1fdd46e0 Mon Sep 17 00:00:00 2001
From: jessiebelle
Date: Sun, 24 Dec 2023 18:15:47 +0200
Subject: [PATCH 03/11] fix migrations
---
...{0099_auto_20231224_1539.py => 0099_auto_20231224_1615.py} | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
rename sponsors/migrations/{0099_auto_20231224_1539.py => 0099_auto_20231224_1615.py} (83%)
diff --git a/sponsors/migrations/0099_auto_20231224_1539.py b/sponsors/migrations/0099_auto_20231224_1615.py
similarity index 83%
rename from sponsors/migrations/0099_auto_20231224_1539.py
rename to sponsors/migrations/0099_auto_20231224_1615.py
index 065c4e786..8cc05097f 100644
--- a/sponsors/migrations/0099_auto_20231224_1539.py
+++ b/sponsors/migrations/0099_auto_20231224_1615.py
@@ -1,4 +1,4 @@
-# Generated by Django 2.2.24 on 2023-12-24 15:39
+# Generated by Django 2.2.24 on 2023-12-24 16:15
from django.db import migrations, models
import django_countries.fields
@@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='sponsor',
name='country_of_incorporation',
- field=django_countries.fields.CountryField(blank=True, max_length=2, null=True, verbose_name='Country of incorporation (If different)'),
+ field=django_countries.fields.CountryField(blank=True, help_text='For contractual purposes', max_length=2, null=True, verbose_name='Country of incorporation (If different)'),
),
migrations.AddField(
model_name='sponsor',
From 091f7bfe7d58608baa8bef6000300b64250c89ad Mon Sep 17 00:00:00 2001
From: jessiebelle
Date: Sat, 30 Dec 2023 15:02:24 +0200
Subject: [PATCH 04/11] modifying existing tests to assert new fields are
correctly saved
---
sponsors/forms.py | 2 ++
sponsors/tests/test_forms.py | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/sponsors/forms.py b/sponsors/forms.py
index 04cacd876..6033a0b18 100644
--- a/sponsors/forms.py
+++ b/sponsors/forms.py
@@ -378,6 +378,8 @@ def save(self):
landing_page_url=self.cleaned_data.get("landing_page_url", ""),
twitter_handle=self.cleaned_data["twitter_handle"],
print_logo=self.cleaned_data.get("print_logo"),
+ country_of_incorporation=self.cleaned_data.get("country_of_incorporation", ""),
+ state_of_incorporation=self.cleaned_data.get("state_of_incorporation", ""),
)
contacts = [f.save(commit=False) for f in self.contacts_formset.forms]
for contact in contacts:
diff --git a/sponsors/tests/test_forms.py b/sponsors/tests/test_forms.py
index 058e21625..3d9342927 100644
--- a/sponsors/tests/test_forms.py
+++ b/sponsors/tests/test_forms.py
@@ -420,14 +420,18 @@ def test_create_sponsor_with_valid_data(self):
def test_create_sponsor_with_valid_data_for_non_required_inputs(
self,
):
+ user = baker.make(settings.AUTH_USER_MODEL)
+
self.data["description"] = "Important company"
self.data["landing_page_url"] = "https://companyx.com"
self.data["twitter_handle"] = "@companyx"
+ self.data["country_of_incorporation"] = "US"
+ self.data["state_of_incorporation"] = "NY"
self.files["print_logo"] = get_static_image_file_as_upload(
"psf-logo_print.png", "logo_print.png"
)
- form = SponsorshipApplicationForm(self.data, self.files)
+ form = SponsorshipApplicationForm(self.data, self.files, user=user)
self.assertTrue(form.is_valid(), form.errors)
sponsor = form.save()
@@ -437,6 +441,8 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs(
self.assertFalse(form.user_with_previous_sponsors)
self.assertEqual(sponsor.landing_page_url, "https://companyx.com")
self.assertEqual(sponsor.twitter_handle, "@companyx")
+ self.assertEqual(sponsor.country_of_incorporation, "US")
+ self.assertEqual(sponsor.state_of_incorporation, "NY")
def test_use_previous_user_sponsor(self):
contact = baker.make(SponsorContact, user__email="foo@foo.com")
From 4c3236450ec88fd58bd30ec5e281687a01286679 Mon Sep 17 00:00:00 2001
From: Ee Durbin
Date: Tue, 2 Jan 2024 08:43:06 -0500
Subject: [PATCH 05/11] Re-structure and re-order sponsor information form
---
sponsors/forms.py | 2 +-
.../new_sponsorship_application_form.html | 129 ++++++++++--------
2 files changed, 71 insertions(+), 60 deletions(-)
diff --git a/sponsors/forms.py b/sponsors/forms.py
index 6033a0b18..c6a3d0bde 100644
--- a/sponsors/forms.py
+++ b/sponsors/forms.py
@@ -252,7 +252,7 @@ class SponsorshipApplicationForm(forms.Form):
label="State/Province/Region", max_length=64, required=False
)
state_of_incorporation = forms.CharField(
- label="State of incorporation", help_text="US only, If different", max_length=64, required=False
+ label="State of incorporation", help_text="US only, If different than mailing address", max_length=64, required=False
)
postal_code = forms.CharField(
label="Zip/Postal Code", max_length=64, required=False
diff --git a/templates/sponsors/new_sponsorship_application_form.html b/templates/sponsors/new_sponsorship_application_form.html
index 29181f80f..ddce38459 100644
--- a/templates/sponsors/new_sponsorship_application_form.html
+++ b/templates/sponsors/new_sponsorship_application_form.html
@@ -53,6 +53,8 @@ Submit Sponsorship Information
+
Basics
+
{{ form.name.label }} {% if form.name.errors %}{{ form.name.errors.as_text }} {% endif %}
{% render_field form.name %}
@@ -62,6 +64,33 @@
Submit Sponsorship Information
{% endif %}
+
+
+
+
+ {{ form.country_of_incorporation.label }} {% if form.country_of_incorporation.errors %}
+ {{ form.country.errors.as_text }} {% endif %}
+ {% render_field form.country_of_incorporation %}
+ {% if form.country_of_incorporation.help_text %}
+
+ {{ form.country_of_incorporation.help_text }}
+ {% endif %}
+
+
+
+
+
+ {{ form.state_of_incorporation.label }} {% if form.state_of_incorporation.errors %}
+ {{ form.state_of_incorporation.errors.as_text }} {% endif %}
+ {% render_field form.state %}
+ {% if form.state_of_incorporation.help_text %}
+
+ {{ form.state_of_incorporation.help_text }}
+ {% endif %}
+
+
+
+
{{ form.description.label }} {% if form.description.errors %}{{ form.description.errors.as_text }} {% endif %}
{% render_field form.description %}
@@ -94,29 +123,34 @@
Submit Sponsorship Information
-
-
-
- {{ form.country.label }} {% if form.country.errors %}{{ form.country.errors.as_text }} {% endif %}
- {% render_field form.country %}
- {% if form.country.help_text %}
-
- {{ form.country.help_text }}
- {% endif %}
-
-
-
-
- {{ form.country_of_incorporation.label }} {% if form.country_of_incorporation.errors %}
- {{ form.country.errors.as_text }} {% endif %}
- {% render_field form.country_of_incorporation %}
- {% if form.country_of_incorporation.help_text %}
-
- {{ form.country_of_incorporation.help_text }}
- {% endif %}
-
-
-
+
+
+
+
+ {{ form.web_logo.label }} {% if form.web_logo.errors %}{{ form.web_logo.errors.as_text }} {% endif %}
+ {% render_field form.web_logo %}
+ {% if form.web_logo.help_text %}
+
+ {{ form.web_logo.help_text }}
+ {% endif %}
+
+
+
+
+
+ {{ form.print_logo.label }} {% if form.print_logo.errors %}{{ form.print_logo.errors.as_text }} {% endif %}
+ {% render_field form.print_logo %}
+ {% if form.print_logo.help_text %}
+
+ {{ form.print_logo.help_text }}
+ {% endif %}
+
+
+
+
+
+
+ Mailing and Contact
@@ -163,19 +197,7 @@
Submit Sponsorship Information
{{ form.state.help_text }}
{% endif %}
-
-
-
-
- {{ form.state_of_incorporation.label }} {% if form.state_of_incorporation.errors %}
- {{ form.state_of_incorporation.errors.as_text }} {% endif %}
- {% render_field form.state %}
- {% if form.state_of_incorporation.help_text %}
-
- {{ form.state_of_incorporation.help_text }}
- {% endif %}
-
-
+
@@ -193,11 +215,11 @@ Submit Sponsorship Information
- {{ form.primary_phone.label }} {% if form.primary_phone.errors %}{{ form.primary_phone.errors.as_text }} {% endif %}
- {% render_field form.primary_phone %}
- {% if form.primary_phone.help_text %}
+ {{ form.country.label }} {% if form.country.errors %}{{ form.country.errors.as_text }} {% endif %}
+ {% render_field form.country %}
+ {% if form.country.help_text %}
- {{ form.primary_phone.help_text }}
+ {{ form.country.help_text }}
{% endif %}
@@ -205,25 +227,14 @@ Submit Sponsorship Information
-
- {{ form.web_logo.label }} {% if form.web_logo.errors %}{{ form.web_logo.errors.as_text }} {% endif %}
- {% render_field form.web_logo %}
- {% if form.web_logo.help_text %}
-
- {{ form.web_logo.help_text }}
- {% endif %}
-
-
-
-
-
- {{ form.print_logo.label }} {% if form.print_logo.errors %}{{ form.print_logo.errors.as_text }} {% endif %}
- {% render_field form.print_logo %}
- {% if form.print_logo.help_text %}
-
- {{ form.print_logo.help_text }}
- {% endif %}
-
+
+ {{ form.primary_phone.label }} {% if form.primary_phone.errors %}{{ form.primary_phone.errors.as_text }} {% endif %}
+ {% render_field form.primary_phone %}
+ {% if form.primary_phone.help_text %}
+
+ {{ form.primary_phone.help_text }}
+ {% endif %}
+
From bfa4e1a2dc260ea2a5426b1dc260e601fd6ed118 Mon Sep 17 00:00:00 2001
From: jessiebelle
Date: Sun, 7 Jan 2024 11:59:49 +0200
Subject: [PATCH 06/11] update and refactor of new_sponsorship_application_form
to be usable for editing
---
.../new_sponsorship_application_form.html | 27 ++++++++++++++++---
templates/users/sponsor_info_update.html | 25 +++++++++++++++++
users/views.py | 2 +-
3 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/templates/sponsors/new_sponsorship_application_form.html b/templates/sponsors/new_sponsorship_application_form.html
index ddce38459..1610807e8 100644
--- a/templates/sponsors/new_sponsorship_application_form.html
+++ b/templates/sponsors/new_sponsorship_application_form.html
@@ -2,15 +2,19 @@
{% load boxes widget_tweaks %}
{% load humanize %}
{% load sponsors %}
+{% block page_title %}Sponsorship Information{% endblock %}
-{% block page_title %}Submit Sponsorship Information{% endblock %}
{% block content %}
{% endblock content %}
diff --git a/templates/users/sponsor_info_update.html b/templates/users/sponsor_info_update.html
index 2c1da5a21..e1984a28c 100644
--- a/templates/users/sponsor_info_update.html
+++ b/templates/users/sponsor_info_update.html
@@ -17,6 +17,7 @@
{% block user_content %}