From 9b8e72a3c0435335bb62ac8706b71b9c2857dfbc Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Mon, 9 Apr 2018 23:24:36 +0200 Subject: [PATCH] remove debug print and handle creation cases in signal handler --- src/profiles/signal_handlers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/profiles/signal_handlers.py b/src/profiles/signal_handlers.py index 5fb38c6d..67802844 100644 --- a/src/profiles/signal_handlers.py +++ b/src/profiles/signal_handlers.py @@ -25,7 +25,6 @@ def profile_pre_save(sender, instance, **kwargs): original = sender.objects.get(pk=instance.pk) except sender.DoesNotExist: original = None - logger.debug("inside profile_pre_save with instance.nickserv_username=%s and original.nickserv_username=%s" % (instance.nickserv_username, original.nickserv_username)) public_credit_name_changed(instance, original) nickserv_username_changed(instance, original) @@ -35,11 +34,11 @@ def public_credit_name_changed(instance, original): """ Checks if a users public_credit_name has been changed, and triggers a public_credit_name_changed event if so """ - if original.public_credit_name == instance.public_credit_name: + if original and original.public_credit_name == instance.public_credit_name: # public_credit_name has not been changed return - if original.public_credit_name and not original.public_credit_name_approved: + if original and original.public_credit_name and not original.public_credit_name_approved: # the original.public_credit_name was not approved, no need to notify again return @@ -61,7 +60,7 @@ def nickserv_username_changed(instance, original): Check if profile.nickserv_username was changed, and uncheck irc_channel_acl_ok if so This will be picked up by the IRC bot and fixed as needed """ - if instance.nickserv_username and instance.nickserv_username != original.nickserv_username: + if instance.nickserv_username and original and instance.nickserv_username != original.nickserv_username: logger.debug("profile.nickserv_username changed for user %s, setting irc_channel_acl_ok=False" % instance.user.username) # find team memberships for this user