newsletter checkboxes in suggestions and registration
[wolnelektury.git] / src / wolnelektury / forms.py
diff --git a/src/wolnelektury/forms.py b/src/wolnelektury/forms.py
new file mode 100644 (file)
index 0000000..0973e7d
--- /dev/null
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.models import User
+
+from newsletter.forms import NewsletterForm
+
+
+# has to be this order, because otherwise the form is lacking fields
+class RegistrationForm(UserCreationForm, NewsletterForm):
+    class Meta:
+        model = User
+        fields = ('username', 'email')
+
+    def save(self, commit=True):
+        super(RegistrationForm, self).save(commit=commit)
+        NewsletterForm.save(self)