remove debug print and handle creation cases in signal handler

This commit is contained in:
Thomas Steen Rasmussen 2018-04-09 23:24:36 +02:00
parent edcf363027
commit 9b8e72a3c0

View file

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