diff --git a/sponsors/forms.py b/sponsors/forms.py index 5a31605af..21258f3b2 100644 --- a/sponsors/forms.py +++ b/sponsors/forms.py @@ -253,10 +253,17 @@ 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 than mailing address", 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="For contractual purposes", required=False + ) def __init__(self, *args, **kwargs): self.user = kwargs.pop("user", None) @@ -373,6 +380,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/migrations/0100_auto_20240107_1054.py b/sponsors/migrations/0100_auto_20240107_1054.py new file mode 100644 index 000000000..8bad2bc92 --- /dev/null +++ b/sponsors/migrations/0100_auto_20240107_1054.py @@ -0,0 +1,29 @@ +# Generated by Django 2.2.24 on 2024-01-07 10:54 + +from django.db import migrations, models +import django_countries.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('sponsors', '0099_auto_20231224_1854'), + ] + + operations = [ + migrations.AddField( + model_name='sponsor', + name='country_of_incorporation', + 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', + 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 eee7f585e..ba0cff83d 100644 --- a/sponsors/models/sponsors.py +++ b/sponsors/models/sponsors.py @@ -73,8 +73,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)", help_text="For contractual purposes", 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/sponsors/tests/test_forms.py b/sponsors/tests/test_forms.py index 123dc1729..49b0515cd 100644 --- a/sponsors/tests/test_forms.py +++ b/sponsors/tests/test_forms.py @@ -423,14 +423,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() @@ -440,6 +444,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_create_sponsor_with_svg_for_print_logo( self, diff --git a/templates/sponsors/new_sponsorship_application_form.html b/templates/sponsors/new_sponsorship_application_form.html index 9f7597650..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 %}
-

Submit Sponsorship Information

-
+{% if sponsor %} +
+

Edit {{sponsor}}

+
+{% else %} +
{% if sponsorship_package %}

You selected the {{ sponsorship_package.name }} package {% if sponsorship_price %}costing ${{ sponsorship_price|intcomma }} USD {% endif %}and the following benefits: @@ -34,6 +38,10 @@

Submit Sponsorship Information

| Back to select benefits
+

Submit Sponsorship Information

+{% endif %} + + {% if form.errors %} The form has one or more errors {{ form.non_field_errors }} @@ -53,6 +61,8 @@

Submit Sponsorship Information

+

Basics

+

{% render_field form.name %} @@ -62,6 +72,33 @@

Submit Sponsorship Information

{% endif %}

+ +
+
+

+ + {% render_field form.country_of_incorporation %} + {% if form.country_of_incorporation.help_text %} +
+ {{ form.country_of_incorporation.help_text }} + {% endif %} +

+
+ +
+

+ + {% render_field form.state %} + {% if form.state_of_incorporation.help_text %} +
+ {{ form.state_of_incorporation.help_text }} + {% endif %} +

+
+
+

{% render_field form.description %} @@ -95,14 +132,39 @@

Submit Sponsorship Information

-

- - {% render_field form.country %} - {% if form.country.help_text %} -
- {{ form.country.help_text }} - {% endif %} -

+
+
+

+ + {% render_field form.web_logo %} + {% if sponsor.web_logo %} +

Currently: {{ sponsor.web_logo.name }}

+ {% endif %} + {% if form.web_logo.help_text %} +
+ {{ form.web_logo.help_text }} + {% endif %} +

+
+ +
+

+ + {% render_field form.print_logo %} + {% if sponsor.print_logo %} +

Currently: {{ sponsor.print_logo.name }}

+ {% endif %} + {% if form.print_logo.help_text %} +
+ {{ form.print_logo.help_text }} + {% endif %} +

+
+
+ +
+ +

Mailing and Contact

@@ -167,11 +229,11 @@

Submit Sponsorship Information

- - {% render_field form.primary_phone %} - {% if form.primary_phone.help_text %} + + {% render_field form.country %} + {% if form.country.help_text %}
- {{ form.primary_phone.help_text }} + {{ form.country.help_text }} {% endif %}

@@ -179,25 +241,14 @@

Submit Sponsorship Information

-

- - {% render_field form.web_logo %} - {% if form.web_logo.help_text %} -
- {{ form.web_logo.help_text }} - {% endif %} -

-
- -
-

- - {% render_field form.print_logo %} - {% if form.print_logo.help_text %} -
- {{ form.print_logo.help_text }} - {% endif %} -

+

+ + {% render_field form.primary_phone %} + {% if form.primary_phone.help_text %} +
+ {{ form.primary_phone.help_text }} + {% endif %} +

@@ -216,11 +267,16 @@

Contacts

- +{% if sponsor %} +
+ +
+ {% else %}
+ {% endif %}
{% endblock content %} diff --git a/templates/users/sponsor_info_update.html b/templates/users/sponsor_info_update.html index 3ae2e720c..e1984a28c 100644 --- a/templates/users/sponsor_info_update.html +++ b/templates/users/sponsor_info_update.html @@ -17,6 +17,7 @@ {% block user_content %}

Edit {{ sponsor }}

+

Basics

{% if form.errors %} The form has one or more errors @@ -36,7 +37,31 @@

Sponsor Information

{% endif %} {% render_field form.name %}

+
+
+

+ + {% render_field form.country_of_incorporation %} + {% if form.country_of_incorporation.help_text %} +
+ {{ form.country_of_incorporation.help_text }} + {% endif %} +

+
+
+

+ + {% render_field form.state %} + {% if form.state_of_incorporation.help_text %} +
+ {{ form.state_of_incorporation.help_text }} + {% endif %} +

+
+

@@ -69,16 +94,29 @@

Sponsor Information

- +
+

{% render_field form.country %} {% if form.country.help_text %} -
{{ form.country.help_text }} {% endif %}

+
+
+

+ + {% render_field form.country_of_incorporation %} + {% if form.country_of_incorporation.help_text %} +
+ {{ form.country_of_incorporation.help_text }} + {% endif %} +

+
+
@@ -131,8 +169,19 @@

Sponsor Information

{{ form.state.help_text }} {% endif %}

+
+
+

+ + {% render_field form.state %} + {% if form.state_of_incorporation.help_text %} +
+ {{ form.state_of_incorporation.help_text }} + {% endif %} +

+
-
diff --git a/users/tests/test_views.py b/users/tests/test_views.py index 952425c98..13c226e5f 100644 --- a/users/tests/test_views.py +++ b/users/tests/test_views.py @@ -489,7 +489,7 @@ def test_display_template_with_sponsor_info(self): response = self.client.get(self.url) context = response.context - self.assertTemplateUsed(response, "users/sponsor_info_update.html") + self.assertTemplateUsed(response, "sponsors/new_sponsorship_application_form.html") self.assertEqual(context["sponsor"], self.sponsor) self.assertIsInstance(context["form"], SponsorUpdateForm) diff --git a/users/views.py b/users/views.py index 517c1419a..c56dbace4 100644 --- a/users/views.py +++ b/users/views.py @@ -264,7 +264,7 @@ def get_context_data(self, *args, **kwargs): @method_decorator(login_required(login_url=settings.LOGIN_URL), name="dispatch") class UpdateSponsorInfoView(UpdateView): object_name = "sponsor" - template_name = 'users/sponsor_info_update.html' + template_name = 'sponsors/new_sponsorship_application_form.html' form_class = SponsorUpdateForm def get_queryset(self):