Some more redirects. Editing user settings does not work. Overhauled adding a new...
[~kgodey/maayanwich.git] / forms.py
1 from django.forms import ModelForm
2 from models import Sandwich, Ingredient
3 from django.contrib.auth.models import User
4 from django import forms
5
6
7 class SandwichForm(ModelForm):
8         
9         class Meta:
10                 model = Sandwich
11                 exclude = ('slug', 'user', 'ingredients')
12                 fields = ('adjective', 'date_made', 'notes', 'picture')
13
14
15 class IngredientForm(ModelForm):
16
17         class Meta:
18                 model = Ingredient
19                 exclude = ('slug',)
20
21
22 class NewUserForm(forms.Form):
23         first_name = forms.CharField()
24         last_name = forms.CharField()
25         email = forms.EmailField()
26         username = forms.CharField()
27         password = forms.CharField(widget=forms.PasswordInput)
28         confirmpassword = forms.CharField(widget=forms.PasswordInput)
29
30         def clean_mpassword(self):
31                 password = self.cleaned_data.get("password", "")
32                 cpassword = self.cleaned_data["confirmpassword"]
33                 if password != cpassword:
34                         raise forms.ValidationError(_("The two password fields didn't match."))
35                         return cpassword