Skip to content

Commit

Permalink
Fixed create borrowings feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Kateryna-Bordonos17 committed Dec 18, 2023
1 parent f5da51c commit 454986c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions borrowing_service/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
@receiver(post_save, sender=Borrowing)
def notify_new_borrowing(sender, instance, created, **kwargs):
if created:
borrowing_info = (
"New borrowing created:\n\n"
f"-Book: {instance.book}\n"
f"--Borrow date: {instance.borrow_date}\n"
f"--Expected return date: {instance.expected_return_date}\n"
)
send_notification(
TelegramUser.objects.get(user_id=instance.user_id).chat_id,
borrowing_info
)
try:
borrowing_info = (
"New borrowing created:\n\n"
f"-Book: {instance.book}\n"
f"--Borrow date: {instance.borrow_date}\n"
f"--Expected return date: {instance.expected_return_date}\n"
)
send_notification(
TelegramUser.objects.get(user_id=instance.user_id).chat_id,
borrowing_info
)
except TelegramUser.DoesNotExist:
pass

0 comments on commit 454986c

Please sign in to comment.