Skip to content
Browse files

Add a timezone changed signal

  • Loading branch information...
1 parent 9440336 commit 430daaa6dc2fe52b4fe33c4df16e3082604af667 @paltman paltman committed
Showing with 13 additions and 1 deletion.
  1. +3 −1 pinax/apps/account/signals.py
  2. +10 −0 pinax/apps/account/views.py
View
4 pinax/apps/account/signals.py
@@ -6,4 +6,6 @@
password_changed = django.dispatch.Signal(providing_args=["user",])
user_login_attempt = django.dispatch.Signal(providing_args=["username", "result"])
user_sign_up_attempt = django.dispatch.Signal(providing_args=["username", "email", "result"])
-user_signed_up = django.dispatch.Signal(providing_args=["user"])
+user_signed_up = django.dispatch.Signal(providing_args=["user"])
+
+timezone_changed = django.dispatch.Signal(providing_args=["request", "from_timezone", "to_timezone"])
View
10 pinax/apps/account/views.py
@@ -24,6 +24,7 @@
from pinax.apps.account.forms import AddEmailForm, ChangeLanguageForm, ChangePasswordForm
from pinax.apps.account.forms import ChangeTimezoneForm, LoginForm, ResetPasswordKeyForm
from pinax.apps.account.forms import ResetPasswordForm, SetPasswordForm, SignupForm
+from pinax.apps.account.signals import timezone_changed
def group_and_bridge(kwargs):
@@ -405,7 +406,16 @@ def timezone_change(request, **kwargs):
if request.method == "POST":
form = form_class(request.user, request.POST)
if form.is_valid():
+ from_timezone = form.account.timezone
form.save()
+ to_timezone = form.account.timezone
+ timezone_changed.send(
+ sender=User,
+ request=request,
+ from_timezone=from_timezone,
+ to_timezone=to_timezone
+ )
+ # @@@ consider removing this to be handled in the signal (or add default signal)
messages.add_message(request, messages.SUCCESS,
ugettext(u"Timezone successfully updated.")
)

0 comments on commit 430daaa

Please sign in to comment.
Something went wrong with that request. Please try again.