Add ' *' required markers back

The bootstrap renderer did not do anything to signify required rows.  We
can do this by adding a class for CSS to work on, and add this field in
a more simplified manner.

label-required == append ' *'
This commit is contained in:
Sachi King 2017-04-24 23:10:51 +10:00
parent b3ac11a66b
commit 8fa8fc4012
4 changed files with 12 additions and 1 deletions

View file

@ -7,6 +7,8 @@ from .models import TalkProposal, TutorialProposal, MiniconfProposal
class ProposalForm(forms.ModelForm):
required_css_class = 'label-required'
def clean_description(self):
value = self.cleaned_data["description"]
if len(value) > 400:

View file

@ -9,7 +9,7 @@ class YesNoField(forms.TypedChoiceField):
kwargs['required'] = True
super(YesNoField, self).__init__(
*args,
coerce=lambda x: x == True,
coerce=lambda x: x is True,
choices=((None, '--------'), (False, 'No'), (True, 'Yes')),
**kwargs
)
@ -18,6 +18,8 @@ class YesNoField(forms.TypedChoiceField):
class ProfileForm(forms.ModelForm):
''' A form for requesting badge and profile information. '''
required_css_class = 'label-required'
class Meta:
model = models.AttendeeProfile
exclude = ['attendee']

View file

@ -1,6 +1,12 @@
{% load pyconau2017_tags %}
{% load bootstrap %}
{% block extra_style %}
<style type="text/css">
.label-required:after { content: ' *'; }
</style>
{% endblock %}
{% if form.non_field_errors %}
<div class="has-errors">
{{ form.non_field_errors }}

1
static/src/css/app.css Normal file
View file

@ -0,0 +1 @@
.label-required:after { content: '*'; }