From 8755fc05ca8ac046c530b4f5bfa7345febb7e731 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 16 Jul 2013 15:56:20 -0400 Subject: [PATCH] Move subscription_property state change code to actions.py. (imported from commit 57056af4e4fe021fafa1d0d511a9c551cd53c74d) --- zephyr/lib/actions.py | 7 +++++++ zephyr/views.py | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/zephyr/lib/actions.py b/zephyr/lib/actions.py index dce7006310..3344c0fc40 100644 --- a/zephyr/lib/actions.py +++ b/zephyr/lib/actions.py @@ -695,6 +695,13 @@ def log_subscription_property_change(user_email, stream_name, property, value): 'value': value} log_event(event) +def do_change_subscription_property(user_profile, sub, stream_name, + property_name, value): + setattr(sub, property_name, value) + sub.save(update_fields=[property_name]) + log_subscription_property_change(user_profile.email, stream_name, + property_name, value) + def do_activate_user(user_profile, log=True, join_date=timezone.now()): user_profile.is_active = True user_profile.set_password(initial_password(user_profile.email)) diff --git a/zephyr/views.py b/zephyr/views.py index 96c28512c8..5445c44dcc 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -25,7 +25,7 @@ from zephyr.lib.actions import do_remove_subscription, bulk_remove_subscriptions do_change_password, create_mit_user_if_needed, do_change_full_name, \ do_change_enable_desktop_notifications, do_change_enter_sends, do_change_enable_sounds, \ do_send_confirmation_email, do_activate_user, do_create_user, check_send_message, \ - log_subscription_property_change, internal_send_message, \ + do_change_subscription_property, internal_send_message, \ create_stream_if_needed, gather_subscriptions, subscribed_to_stream, \ update_user_presence, bulk_add_subscriptions, update_message_flags, \ recipient_for_emails, extract_recipients, do_events_register, \ @@ -1425,10 +1425,8 @@ def json_subscription_property(request, user_profile, stream_name=REQ, @has_request_variables def do_set_property(request, value=REQ(converter=property_converters[property])): - setattr(sub, property, value) - sub.save(update_fields=[property]) - log_subscription_property_change(user_profile.email, stream_name, - property, value) + do_change_subscription_property(user_profile, sub, stream_name, + property, value) do_set_property(request) return json_success() else: