Skip to content

Commit

Permalink
fix for #5280
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Oct 14, 2019
1 parent ba1411b commit c4cbf61
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,10 +1614,20 @@ def receive_url_for_recipient(self):
class TipPayoutException(Exception):
pass


@receiver(pre_save, sender=Tip, dispatch_uid="psave_tip")
def psave_tip(sender, instance, **kwargs):
# when a new tip is saved, make sure it doesnt have whitespace in it
instance.username = instance.username.replace(' ', '')
# set missing attributes
if not instance.sender_profile:
profiles = Profile.objects.filter(handle__iexact=instance.from_username)
if profiles.exists():
instance.sender_profile = profiles.first()
if not instance.recipient_profile:
profiles = Profile.objects.filter(handle__iexact=instance.username)
if profiles.exists():
instance.recipient_profile = profiles.first()


@receiver(post_save, sender=Tip, dispatch_uid="post_save_tip")
Expand Down

0 comments on commit c4cbf61

Please sign in to comment.