From ff5ed1fdb1d6034db3395e8ec9ae84f4dce1eaca Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 2 Feb 2012 16:13:34 +0530 Subject: [PATCH] added itfprofiles app --- itf/itfprofiles/__init__.py | 0 itf/itfprofiles/forms.py | 13 +++++++++++++ itf/itfprofiles/models.py | 13 +++++++++++++ itf/itfprofiles/tests.py | 16 ++++++++++++++++ itf/itfprofiles/views.py | 1 + 5 files changed, 43 insertions(+) create mode 100644 itf/itfprofiles/__init__.py create mode 100644 itf/itfprofiles/forms.py create mode 100644 itf/itfprofiles/models.py create mode 100644 itf/itfprofiles/tests.py create mode 100644 itf/itfprofiles/views.py diff --git a/itf/itfprofiles/__init__.py b/itf/itfprofiles/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/itf/itfprofiles/forms.py b/itf/itfprofiles/forms.py new file mode 100644 index 0000000..fd00c3d --- /dev/null +++ b/itf/itfprofiles/forms.py @@ -0,0 +1,13 @@ +from django import forms +from registration.forms import RegistrationForm +from models import ItfProfile +from registration.models import RegistrationProfile + +class ItfRegistrationForm(RegistrationForm): + subscribe = forms.BooleanField(help_text='Subscribe to newsletter?') + + def save(self, profile_callback=None): + new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], password=self.cleaned_data['password1'], email=self.cleaned_data['email']) + new_profile = ItfProfile(user=new_user, subscribed=self.cleaned_data['subscribe']) + new_profile.save() + return new_user diff --git a/itf/itfprofiles/models.py b/itf/itfprofiles/models.py new file mode 100644 index 0000000..2e6d1d2 --- /dev/null +++ b/itf/itfprofiles/models.py @@ -0,0 +1,13 @@ +from django.db import models +from app.models import ItfModel +from django.contrib.auth.models import User + + + +class ItfProfile(ItfModel): + user = models.ForeignKey(User, null=True) + subscribed = models.BooleanField(default=True) + + + +# Create your models here. diff --git a/itf/itfprofiles/tests.py b/itf/itfprofiles/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/itf/itfprofiles/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this with more appropriate tests for your application. +""" + +from django.test import TestCase + + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.assertEqual(1 + 1, 2) diff --git a/itf/itfprofiles/views.py b/itf/itfprofiles/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/itf/itfprofiles/views.py @@ -0,0 +1 @@ +# Create your views here.