Skip to content

Commit

Permalink
Sponsorship application tweaks (#1730)
Browse files Browse the repository at this point in the history
* sponsorship: add twitter handle to Sponsor model and application form

* sponsorship: Update text on the submit button for sponsorship application
  • Loading branch information
ewdurbin committed Feb 12, 2021
1 parent 6722104 commit 6d02143
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
9 changes: 8 additions & 1 deletion sponsors/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ class SponsorshipApplicationForm(forms.Form):
)
landing_page_url = forms.URLField(
label="Sponsor landing page",
help_text="Sponsor landing page URL. This may be provided by the sponsor, however the linked page may not contain any sales or marketing information.",
help_text="Landing page URL. The linked page may not contain any sales or marketing information.",
required=False,
)
twitter_handle = forms.CharField(
max_length=32,
label="Twitter handle",
help_text="For promotion of your sponsorship on social media.",
required=False,
)
web_logo = forms.ImageField(
Expand Down Expand Up @@ -300,6 +306,7 @@ def save(self):
country=self.cleaned_data["country"],
description=self.cleaned_data.get("description", ""),
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"),
)
contacts = [f.save(commit=False) for f in self.contacts_formset.forms]
Expand Down
23 changes: 23 additions & 0 deletions sponsors/migrations/0019_sponsor_twitter_handle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.0.13 on 2021-02-12 14:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("sponsors", "0018_auto_20201201_1659"),
]

operations = [
migrations.AddField(
model_name="sponsor",
name="twitter_handle",
field=models.CharField(
blank=True,
max_length=32,
null=True,
verbose_name="Sponsor twitter hanlde",
),
),
]
6 changes: 6 additions & 0 deletions sponsors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ class Sponsor(ContentManageable):
verbose_name="Sponsor landing page",
help_text="Sponsor landing page URL. This may be provided by the sponsor, however the linked page may not contain any sales or marketing information.",
)
twitter_handle = models.CharField(
max_length=32, # Actual limit set by twitter is 15 characters, but that may change?
blank=True,
null=True,
verbose_name="Sponsor twitter hanlde",
)
web_logo = models.ImageField(
upload_to="sponsor_web_logos",
verbose_name="Sponsor web logo",
Expand Down
2 changes: 2 additions & 0 deletions sponsors/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs(
):
self.data["description"] = "Important company"
self.data["landing_page_url"] = "https://companyx.com"
self.data["twitter_handle"] = "@companyx"
self.files["print_logo"] = get_static_image_file_as_upload(
"psf-logo_print.png", "logo_print.png"
)
Expand All @@ -248,6 +249,7 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs(
self.assertTrue(sponsor.print_logo)
self.assertFalse(form.user_with_previous_sponsors)
self.assertEqual(sponsor.landing_page_url, "https://companyx.com")
self.assertEqual(sponsor.twitter_handle, "@companyx")

def test_use_previous_user_sponsor(self):
contact = baker.make(SponsorContact, user__email="foo@foo.com")
Expand Down
33 changes: 24 additions & 9 deletions templates/sponsors/new_sponsorship_application_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,29 @@ <h1>Submit Sponsorship Information</h1>
{% endif %}
</p>

<p class="form_field">
<label>{{ form.landing_page_url.label }} <span class="error-message">{% if form.landing_page_url.errors %}{{ form.landing_page_url.errors.as_text }}</span>{% endif %}</label>
{% render_field form.landing_page_url %}
{% if form.landing_page_url.help_text %}
<br/>
<span class="helptext">{{ form.landing_page_url.help_text }}</span>
{% endif %}
</p>
<div class="inline_fields">
<div>
<p class="form_field">
<label>{{ form.landing_page_url.label }} <span class="error-message">{% if form.landing_page_url.errors %}{{ form.landing_page_url.errors.as_text }}</span>{% endif %}</label>
{% render_field form.landing_page_url %}
{% if form.landing_page_url.help_text %}
<br/>
<span class="helptext">{{ form.landing_page_url.help_text }}</span>
{% endif %}
</p>
</div>

<div>
<p class="form_field">
<label>{{ form.twitter_handle.label }} <span class="error-message">{% if form.twitter_handle.errors %}{{ form.twitter_handle.errors.as_text }}</span>{% endif %}</label>
{% render_field form.twitter_handle %}
{% if form.twitter_handle.help_text %}
<br/>
<span class="helptext">{{ form.twitter_handle.help_text }}</span>
{% endif %}
</p>
</div>
</div>

<p class="form_field">
<label>{{ form.country.label }} <span class="error-message">{% if form.country.errors %}{{ form.country.errors.as_text }}</span>{% endif %}</label>
Expand Down Expand Up @@ -203,7 +218,7 @@ <h1>Contacts</h1>

</div>

<input id="submit-btn" type="submit" value="Submit">
<input id="submit-btn" type="submit" value="Apply">
</form>
</article>

Expand Down

0 comments on commit 6d02143

Please sign in to comment.