diff --git a/zephyr/lib/actions.py b/zephyr/lib/actions.py index d02ba4e7a5..b8939ff36f 100644 --- a/zephyr/lib/actions.py +++ b/zephyr/lib/actions.py @@ -936,7 +936,7 @@ def subscribed_to_stream(user_profile, stream): def do_update_onboarding_steps(user_profile, steps): user_profile.onboarding_steps = ujson.dumps(steps) - user_profile.save() + user_profile.save(update_fields=["onboarding_steps"]) log_event({'type': 'update_onboarding', 'user': user_profile.email, diff --git a/zephyr/management/commands/bankrupt_users.py b/zephyr/management/commands/bankrupt_users.py index ef814c4217..36679e41f7 100644 --- a/zephyr/management/commands/bankrupt_users.py +++ b/zephyr/management/commands/bankrupt_users.py @@ -30,7 +30,7 @@ Usage: python manage.py bankrupt_users """ old_pointer = user_profile.pointer new_pointer = messages[0].id user_profile.pointer = new_pointer - user_profile.save() + user_profile.save(update_fields=["pointer"]) print "%s: %d => %d" % (email, old_pointer, new_pointer) else: print "%s has no messages, can't bankrupt!" % (email,) diff --git a/zephyr/management/commands/delete_tutorial_streams.py b/zephyr/management/commands/delete_tutorial_streams.py index 5fb08435dc..1a875a0a8d 100644 --- a/zephyr/management/commands/delete_tutorial_streams.py +++ b/zephyr/management/commands/delete_tutorial_streams.py @@ -45,7 +45,7 @@ class Command(BaseCommand): if options["for_real"]: tutorial_user = subscribers[0] tutorial_user.active = False - tutorial_user.save() + tutorial_user.save(update_fields=["active"]) if options["for_real"]: print "Subscriptions deactivated." diff --git a/zephyr/management/commands/dump_pointers.py b/zephyr/management/commands/dump_pointers.py index c732a12278..eddc73a990 100755 --- a/zephyr/management/commands/dump_pointers.py +++ b/zephyr/management/commands/dump_pointers.py @@ -36,7 +36,7 @@ def restore(change): continue if change: u.pointer = pointer - u.save() + u.save(update_fields=["pointer"]) class Command(BaseCommand): option_list = BaseCommand.option_list + ( diff --git a/zephyr/management/commands/populate_db.py b/zephyr/management/commands/populate_db.py index 13512e1d16..cf855bbda0 100644 --- a/zephyr/management/commands/populate_db.py +++ b/zephyr/management/commands/populate_db.py @@ -558,21 +558,22 @@ def restore_saved_messages(): # Just handle these the slow way user_profile = users[old_message["user"]] user_profile.full_name = old_message["full_name"] - user_profile.save() + user_profile.save(update_fields=["full_name"]) continue elif message_type == "enable_desktop_notifications_changed": # Just handle these the slow way user_profile = users[old_message["user"]] user_profile.enable_desktop_notifications = (old_message["enable_desktop_notifications"] != "false") - user_profile.save() + user_profile.save(update_fields=["enable_desktop_notifications"]) continue elif message_type == "enable_sounds_changed": user_profile = users[old_message["user"]] user_profile.enable_sounds = (old_message["enable_sounds"] != "false") + user_profile.save(update_fields=["enable_sounds"]) elif message_type == "enable_offline_email_notifications_changed": user_profile = users[old_message["user"]] user_profile.enable_offline_email_notifications = (old_message["enable_offline_email_notifications"] != "false") - user_profile.save() + user_profile.save(update_fields=["enable_offline_email_notifications"]) continue elif message_type == "default_streams": set_default_streams(Realm.objects.get(domain=old_message["domain"]), @@ -656,7 +657,7 @@ def restore_saved_messages(): with transaction.commit_on_success(): for (sub, active) in subscriptions_to_change: current_subs_obj[sub].active = active - current_subs_obj[sub].save() + current_subs_obj[sub].save(update_fields=["active"]) subs = {} for sub in Subscription.objects.all(): @@ -683,7 +684,7 @@ def restore_saved_messages(): user_profile.pointer = top.message_id except IndexError: user_profile.pointer = -1 - user_profile.save() + user_profile.save(update_fields=["pointer"]) print datetime.datetime.now(), "Done replaying old messages" diff --git a/zephyr/management/commands/sync_api_key.py b/zephyr/management/commands/sync_api_key.py index 3ddd7ff8ac..06c1944f4e 100644 --- a/zephyr/management/commands/sync_api_key.py +++ b/zephyr/management/commands/sync_api_key.py @@ -20,4 +20,4 @@ class Command(BaseCommand): user_profile = get_user_profile_by_email(email) user_profile.api_key = api_key - user_profile.save() + user_profile.save(update_fields=["api_key"]) diff --git a/zephyr/management/commands/update_mit_fullnames.py b/zephyr/management/commands/update_mit_fullnames.py index 045b1c35c1..b1b01a2b95 100644 --- a/zephyr/management/commands/update_mit_fullnames.py +++ b/zephyr/management/commands/update_mit_fullnames.py @@ -19,7 +19,7 @@ def update_mit_fullnames(change=False): print "%s: %s => %s" % (u.email, u.full_name, computed_name) if change: u.full_name = computed_name - u.save() + u.save(update_fields=["full_name"]) class Command(BaseCommand): option_list = BaseCommand.option_list + ( diff --git a/zephyr/views.py b/zephyr/views.py index c932970d58..80650b37aa 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -413,8 +413,7 @@ def handle_openid_errors(request, issue, openid_response=None): if form.is_valid(): # Construct a PreregistrationUser object and send the user over to # the confirmation view. - prereg_user = PreregistrationUser() - prereg_user.email = google_email + prereg_user = PreregistrationUser(email=google_email) prereg_user.save() return redirect("".join(( "/", @@ -475,8 +474,7 @@ def accounts_home(request): form = HomepageForm(request.POST) if form.is_valid(): email = form.cleaned_data['email'] - prereg_user = PreregistrationUser() - prereg_user.email = email + prereg_user = PreregistrationUser(email=email) prereg_user.save() Confirmation.objects.send_confirmation(prereg_user, email) return HttpResponseRedirect(reverse('send_confirm', kwargs={'email': email})) @@ -508,7 +506,7 @@ def home(request): # user has since logged in if not user_profile.last_reminder is None: user_profile.last_reminder = None - user_profile.save() + user_profile.save(update_fields=["last_reminder"]) # Brand new users get the tutorial needs_tutorial = settings.TUTORIAL_ENABLED and \ @@ -1052,7 +1050,7 @@ def json_tutorial_status(request, user_profile, status=REQ('status')): user_profile.tutorial_status = UserProfile.TUTORIAL_STARTED elif status == 'finished': user_profile.tutorial_status = UserProfile.TUTORIAL_FINISHED - user_profile.save() + user_profile.save(update_fields=["tutorial_status"]) return json_success()