diff --git a/totem/onboard/migrations/0008_onboardmodel_referral_other_and_more.py b/totem/onboard/migrations/0008_onboardmodel_referral_other_and_more.py new file mode 100644 index 00000000..ec35ce97 --- /dev/null +++ b/totem/onboard/migrations/0008_onboardmodel_referral_other_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.4 on 2025-01-08 01:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('onboard', '0007_alter_onboardmodel_hopes_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='onboardmodel', + name='referral_other', + field=models.CharField(blank=True, help_text='Please tell us more about how you found us', max_length=100, verbose_name='If other, please specify'), + ), + migrations.AddField( + model_name='onboardmodel', + name='referral_source', + field=models.CharField(blank=True, choices=[('search', 'Search Results'), ('social', 'Social Media'), ('keeper', 'A Keeper'), ('pamphlet', 'Pamphlet'), ('blog', 'Blog'), ('newsletter', 'Newsletter'), ('dream', 'A Dream')], max_length=20, verbose_name='How did you hear about us?'), + ), + ] diff --git a/totem/onboard/migrations/0009_alter_onboardmodel_referral_source.py b/totem/onboard/migrations/0009_alter_onboardmodel_referral_source.py new file mode 100644 index 00000000..ca580d01 --- /dev/null +++ b/totem/onboard/migrations/0009_alter_onboardmodel_referral_source.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.4 on 2025-01-08 01:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('onboard', '0008_onboardmodel_referral_other_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='onboardmodel', + name='referral_source', + field=models.CharField(blank=True, choices=[('default', "I'm not sure"), ('search', 'Search Results'), ('social', 'Social Media'), ('keeper', 'A Keeper'), ('pamphlet', 'Pamphlet'), ('blog', 'Blog'), ('newsletter', 'Newsletter'), ('dream', '✨A Dream✨'), ('other', 'Other')], max_length=20, verbose_name='How did you hear about us?'), + ), + ] diff --git a/totem/onboard/models.py b/totem/onboard/models.py index 14af134b..20a46031 100644 --- a/totem/onboard/models.py +++ b/totem/onboard/models.py @@ -4,6 +4,17 @@ class OnboardModel(models.Model): + REFERRAL_CHOICES = [ + ("default", "I'm not sure"), + ("search", "Search Results"), + ("social", "Social Media"), + ("keeper", "A Keeper"), + ("pamphlet", "Pamphlet"), + ("blog", "Blog"), + ("newsletter", "Newsletter"), + ("dream", "✨A Dream✨"), + ("other", "Other"), + ] user = models.OneToOneField( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, @@ -16,6 +27,18 @@ class OnboardModel(models.Model): suggestions = models.TextField(blank=True, null=True, validators=[MaxLengthValidator(5000)]) hopes = models.TextField(blank=True, null=True, validators=[MaxLengthValidator(5000)]) internal_notes = models.TextField(blank=True, null=True, validators=[MaxLengthValidator(10000)]) + referral_source = models.CharField( + max_length=20, + choices=REFERRAL_CHOICES, + verbose_name="How did you hear about us?", + blank=True, # Remove if you want to make it required + ) + referral_other = models.CharField( + max_length=100, + blank=True, + verbose_name="If other, please specify", + help_text="Please tell us more about how you found us", + ) def __str__(self): return f"Onboard: {self.user}" diff --git a/totem/onboard/templates/onboard/onboard_form.html b/totem/onboard/templates/onboard/onboard_form.html index 52d743d4..b0cc6f85 100644 --- a/totem/onboard/templates/onboard/onboard_form.html +++ b/totem/onboard/templates/onboard/onboard_form.html @@ -15,9 +15,10 @@

Welcome!

{{ form.non_field_errors }} {% csrf_token %}
- - {{ form.name.errors }} - {{ form.name }} + + {{ form.name.errors }} {{ form.name }}

Other people will see this, but you don't have to use your real name. Add any pronouns in parentheses if you'd like. @@ -25,7 +26,9 @@

Welcome!

- +
{{ form.age.errors }}
{{ form.age }}
@@ -46,6 +49,20 @@

Welcome!

Your feedback here will help inform us about new topics to offer.

+
+
+ +
+ {{ form.referral_source.errors }} {{ form.referral_source }} + +

+ This helps us understand how to reach more people like you. +

+
+ + {% endblock content %} diff --git a/totem/onboard/views.py b/totem/onboard/views.py index 3b61222e..c2b23ca4 100644 --- a/totem/onboard/views.py +++ b/totem/onboard/views.py @@ -1,7 +1,7 @@ import datetime from django.contrib.auth.decorators import login_required -from django.forms import CharField, Form, IntegerField, Textarea, TextInput +from django.forms import CharField, ChoiceField, Form, IntegerField, Select, Textarea, TextInput from django.http import HttpRequest from django.shortcuts import redirect, render @@ -26,6 +26,20 @@ class OnboardForm(Form): ) age = IntegerField(required=True, initial=None, min_value=13, max_value=120, widget=TextInput()) hopes = CharField(max_length=1000, required=False, widget=Textarea(attrs={"rows": 3})) + referral_source = ChoiceField( + choices=OnboardModel.REFERRAL_CHOICES, + required=False, + widget=Select(attrs={"class": "form-select", "onchange": "showOtherField(this.value)"}), + ) + referral_other = CharField( + max_length=100, + required=False, + widget=TextInput( + attrs={ + "placeholder": "Please tell us more about how you found us", + } + ), + ) def save(self, user: User, onboard: OnboardModel): user.name = self.cleaned_data.pop("name")