diff --git a/resrc/userprofile/forms.py b/resrc/userprofile/forms.py index 073d54c..2544067 100644 --- a/resrc/userprofile/forms.py +++ b/resrc/userprofile/forms.py @@ -6,24 +6,38 @@ from django.contrib.auth import authenticate from crispy_forms.helper import FormHelper -from crispy_forms_foundation.layout import Layout, Row, Div, Fieldset, Submit, Field, HTML +from crispy_forms_foundation.layout import Layout, Row, Column, Div, Fieldset, Submit, Field, HTML from captcha.fields import CaptchaField from django.conf import settings +class AbideCrispyField(Field): + template = 'abide_crispy_field.html' + + def __init__(self, *args, **kwargs): + clientside_error = kwargs.pop('clientside_error', None) + super(AbideCrispyField, self).__init__(*args, **kwargs) + self.clientside_error = clientside_error + + def render(self, form, form_style, context, *args, **kwargs): + if self.clientside_error is not None: + context['clientside_error'] = self.clientside_error + return super(AbideCrispyField, self).render(form, form_style, context, *args, **kwargs) class LoginForm(forms.Form): username = forms.CharField(max_length=30) password = forms.CharField(max_length=76, widget=forms.PasswordInput) - class RegisterForm(forms.Form): - email = forms.EmailField(label='email') - username = forms.CharField(label='username', max_length=30) + email = forms.EmailField(label='email', widget=forms.TextInput(attrs={'required':''})) + username = forms.CharField(label='username', max_length=30, widget=forms.TextInput(attrs={'required':''}) + ) password = forms.CharField( - label='password', max_length=76, widget=forms.PasswordInput) + label='password', max_length=76, widget=forms.PasswordInput(attrs={'required':''}) + ) password_confirm = forms.CharField( - label='confirm password', max_length=76, widget=forms.PasswordInput) + label='confirm password', max_length=76, widget=forms.PasswordInput(attrs={'required':''}) + ) captcha = CaptchaField() def __init__(self, *args, **kwargs): @@ -31,54 +45,31 @@ def __init__(self, *args, **kwargs): self.helper.form_method = 'post' self.helper.layout = Layout( - HTML('\ -