Move subscription_property state change code to actions.py.

(imported from commit 57056af4e4fe021fafa1d0d511a9c551cd53c74d)
This commit is contained in:
Tim Abbott 2013-07-16 15:56:20 -04:00
parent 907bb154b1
commit 8755fc05ca
2 changed files with 10 additions and 5 deletions

View File

@ -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))

View File

@ -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: