Commits

Peter Sanchez  committed 16fa2a6

Adding forms

  • Participants
  • Parent commits be608a1
  • Branches trunk

Comments (0)

Files changed (2)

File webutils/baseacct/forms.py

+from django import forms
+from django.conf import settings
+from django.utils.translation import ugettext_lazy as _
+
+
+class LoginForm(AuthenticationForm):
+    username = forms.CharField(
+        label=_('Username'),
+        max_length=30,
+    )
+    password = forms.CharField(
+        label=_('Password'),
+    )
+
+
+class ResetForm(forms.Form):
+    email = forms.EmailField(
+        max_length=125,
+        label=_('Email Address'),
+    )
+
+    def clean_email(self):
+        if 'email' in self.cleaned_data:
+            email = self.cleaned_data['email']
+            if not User.objects.filter(email__iexact=email).count() > 0:
+                raise forms.ValidationError(
+                    u'There is no account registered to this email address.'
+                )
+            return email.lower()
+
+        raise forms.ValidationError(u'This field is required.')

File webutils/baseacct/views.py

 
     return render_to_response(template, {
         'form': form,
-        }, context_instance=RequestContext(request))
+    }, context_instance=RequestContext(request))