Skip to content

Commit

Permalink
Only log in case validated name changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Iso5786 committed Oct 8, 2024
1 parent 700bd67 commit 73ec7b9
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions apps/badgrsocialauth/providers/eduid/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,25 @@ def new_val_name_audit_trail(
sender, user, old_validated_name, new_validated_name, **kwargs
):
try:
if old_validated_name is None:
audit_trail = ValidatedNameAuditTrail.objects.create(
user=user,
new_validated_name=new_validated_name,
if not old_validated_name == new_validated_name:
if old_validated_name is None:
audit_trail = ValidatedNameAuditTrail.objects.create(
user=user,
new_validated_name=new_validated_name,
)
elif new_validated_name is None:
audit_trail = ValidatedNameAuditTrail.objects.create(
user=user,
old_validated_name=old_validated_name,
)
else:
audit_trail = ValidatedNameAuditTrail.objects.create(
user=user,
old_validated_name=old_validated_name,
new_validated_name=new_validated_name,
)
logger.info(
f"val_name_audit_trail created {audit_trail.id} for user {audit_trail.user}"
)
else:
audit_trail = ValidatedNameAuditTrail.objects.create(
user=user,
old_validated_name=old_validated_name,
new_validated_name=new_validated_name,
)
logger.info(
f"val_name_audit_trail created {audit_trail.id} for user {audit_trail.user}"
)
except Exception as e:
logger.error("val_name_audit_trail error: %s" % (e))

0 comments on commit 73ec7b9

Please sign in to comment.