Permalink
Browse files

Added start of request receivers adding account_user_signed_up

  • Loading branch information...
1 parent 60bfea3 commit b4277010aae906f431d67be13f31bb80cf530ce6 @brosner brosner committed Feb 23, 2010
View
11 pinax/apps/account/models.py
@@ -13,6 +13,8 @@
from emailconfirmation.signals import email_confirmed
from timezones.fields import TimeZoneField
+from account import receivers
+
class Account(models.Model):
@@ -127,10 +129,5 @@ def __unicode__(self):
)
-def mark_user_active(sender, instance=None, **kwargs):
- user = kwargs.get("email_address").user
- user.is_active = True
- user.save()
-
-
-email_confirmed.connect(mark_user_active, sender=EmailConfirmation)
+# signals
+email_confirmed.connect(receivers.email_confirmed)
View
7 pinax/apps/account/receivers.py
@@ -0,0 +1,7 @@
+def email_confirmed(sender, user, **kwargs):
+ request = sender
+
+ # mark user as active
+ user = kwargs.get("email_address").user
+ user.is_active = True
+ user.save()
View
5 pinax/apps/account/signals.py
@@ -0,0 +1,5 @@
+import django.dispatch
+
+
+
+account_user_signed_up = django.dispatch.Signal(providing_args=["user"])
View
4 pinax/apps/account/views.py
@@ -22,12 +22,13 @@
if association_model is not None:
from django_openid.models import UserOpenidAssociation
-from account.utils import get_default_redirect, user_display
+from account import signals
from account.models import OtherServiceInfo
from account.forms import AddEmailForm, ChangeLanguageForm, ChangePasswordForm
from account.forms import ChangeTimezoneForm, LoginForm, ResetPasswordKeyForm
from account.forms import ResetPasswordForm, SetPasswordForm, SignupForm
from account.forms import TwitterForm
+from account.utils import get_default_redirect, user_display
@@ -127,6 +128,7 @@ def signup(request, **kwargs):
}, context_instance=RequestContext(request))
else:
user = authenticate(**credentials)
+ signals.user_signed_up.send(sender=request, user=user)
auth_login(request, user)
messages.add_message(request, messages.SUCCESS,
ugettext("Successfully logged in as %(user)s.") % {
View
0 pinax/projects/social_project/apps/request_receivers/__init__.py
No changes.
View
7 pinax/projects/social_project/apps/request_receivers/models.py
@@ -0,0 +1,7 @@
+from account import signals
+
+from request_receivers import receivers
+
+
+
+signals.account_user_signed_up.connect(receivers.account_user_signed_up)
View
3 pinax/projects/social_project/apps/request_receivers/receivers.py
@@ -0,0 +1,3 @@
+
+def account_user_signed_up(sender, **kwargs):
+ pass
View
11 pinax/projects/social_project/apps/request_receivers/tests.py
@@ -0,0 +1,11 @@
+from django.test import TestCase
+
+
+
+class RecieverTest(TestCase):
+
+ def test_account_user_signed_up(self):
+ """
+ ensure behavior of account_user_signed_up behavior works.
+ """
+ pass
View
1 pinax/projects/social_project/settings.py
@@ -191,6 +191,7 @@
"debug_toolbar",
# internal (for now)
+ "request_receivers",
"analytics",
"profiles",
"account",

0 comments on commit b427701

Please sign in to comment.