From 079f87b1d26172d15556c8844bad28fdee8b61d5 Mon Sep 17 00:00:00 2001 From: Sachi King Date: Sun, 23 Apr 2017 17:19:38 +1000 Subject: [PATCH] Use a selectbox for of_legal_age To me, this registeres to a user as a required field better than a radio-button. As well, we now signal it as "required = True" --- pinaxcon/monkey_patch.py | 2 +- pinaxcon/proposals/admin.py | 2 +- pinaxcon/registrasion/forms.py | 20 +++++++++---------- .../registrasion/migrations/0001_initial.py | 2 +- pinaxcon/registrasion/models.py | 2 -- pinaxcon/registrasion/views.py | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pinaxcon/monkey_patch.py b/pinaxcon/monkey_patch.py index 16eba9ba..fbfd6a0a 100644 --- a/pinaxcon/monkey_patch.py +++ b/pinaxcon/monkey_patch.py @@ -20,7 +20,7 @@ def do_monkey_patch(): def patch_speaker_profile_form(): ''' Replaces textarea widgets with markdown editors. ''' - import widgets + from . import widgets from symposion.speakers.forms import SpeakerForm fields = SpeakerForm.base_fields diff --git a/pinaxcon/proposals/admin.py b/pinaxcon/proposals/admin.py index b5418e64..95fce57f 100644 --- a/pinaxcon/proposals/admin.py +++ b/pinaxcon/proposals/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -import models +from . import models from symposion.proposals import models as symposion_models diff --git a/pinaxcon/registrasion/forms.py b/pinaxcon/registrasion/forms.py index 20145f59..d4e67ef3 100644 --- a/pinaxcon/registrasion/forms.py +++ b/pinaxcon/registrasion/forms.py @@ -1,17 +1,17 @@ -import models +from . import models from django import forms class YesNoField(forms.TypedChoiceField): - def __init__(self, *a, **k): + def __init__(self, *args, **kwargs): + kwargs['required'] = True super(YesNoField, self).__init__( - *a, - coerce=lambda x: x == 'True', - choices=((False, 'No'), (True, 'Yes')), - widget=forms.RadioSelect, - **k + *args, + coerce=lambda x: x == True, + choices=((None, '--------'), (False, 'No'), (True, 'Yes')), + **kwargs ) @@ -21,12 +21,12 @@ class ProfileForm(forms.ModelForm): class Meta: model = models.AttendeeProfile exclude = ['attendee'] + widgets = { + 'past_lca': forms.widgets.CheckboxSelectMultiple + } field_classes = { "of_legal_age": YesNoField, } - widgets = { - "past_lca": forms.widgets.CheckboxSelectMultiple(), - } class Media: js = ("lca2017/js/profile_form.js", ) diff --git a/pinaxcon/registrasion/migrations/0001_initial.py b/pinaxcon/registrasion/migrations/0001_initial.py index 0ba8cc14..58aefa6b 100644 --- a/pinaxcon/registrasion/migrations/0001_initial.py +++ b/pinaxcon/registrasion/migrations/0001_initial.py @@ -68,7 +68,7 @@ class Migration(migrations.Migration): ('free_text_2', models.CharField(blank=True, max_length=64, verbose_name=b'Free text line 2')), ('name_per_invoice', models.CharField(blank=True, help_text=b"If your legal name is different to the name on your badge, fill this in, and we'll put it on your invoice. Otherwise, leave it blank.", max_length=256, verbose_name=b'Your legal name (for invoicing purposes)')), ('address', models.TextField(blank=True, help_text=b'This address, if provided, will appear on your invoices.', verbose_name=b'Invoicing address')), - ('of_legal_age', models.BooleanField(default=False, help_text=b'Being under 18 will not stop you from attending the conference. We need to know whether you are over 18 to allow us to cater for you at venues that serve alcohol.', verbose_name=b'Are you over 18?')), + ('of_legal_age', models.BooleanField(help_text=b'Being under 18 will not stop you from attending the conference. We need to know whether you are over 18 to allow us to cater for you at venues that serve alcohol.', verbose_name=b'Are you over 18?')), ('dietary_restrictions', models.TextField(blank=True, max_length=256, verbose_name=b'Food allergies, intolerances, or dietary restrictions')), ('accessibility_requirements', models.TextField(blank=True, verbose_name=b'Accessibility-related requirements')), ('gender', models.CharField(blank=True, help_text=b'Gender data will only be used for demographic purposes.', max_length=64)), diff --git a/pinaxcon/registrasion/models.py b/pinaxcon/registrasion/models.py index 86d01b22..c6b138d0 100644 --- a/pinaxcon/registrasion/models.py +++ b/pinaxcon/registrasion/models.py @@ -172,9 +172,7 @@ The linux.conf.au 2016 attendees mailing listName ) of_legal_age = models.BooleanField( - default=False, verbose_name="Are you over 18?", - blank=True, help_text="Being under 18 will not stop you from attending the " "conference. We need to know whether you are over 18 to " "allow us to cater for you at venues that serve alcohol.", diff --git a/pinaxcon/registrasion/views.py b/pinaxcon/registrasion/views.py index 5f9d52f9..2eecd633 100644 --- a/pinaxcon/registrasion/views.py +++ b/pinaxcon/registrasion/views.py @@ -7,7 +7,7 @@ from django.shortcuts import redirect from registrasion import models as rego from registrasion.controllers.invoice import InvoiceController -import models +from . import models def demopay(request, invoice_id, access_code):