diff --git a/Clubs/__pycache__/models.cpython-310.pyc b/Clubs/__pycache__/models.cpython-310.pyc index 7fdf897..642403c 100644 Binary files a/Clubs/__pycache__/models.cpython-310.pyc and b/Clubs/__pycache__/models.cpython-310.pyc differ diff --git a/Clubs/__pycache__/views.cpython-310.pyc b/Clubs/__pycache__/views.cpython-310.pyc index ff53b47..02c8153 100644 Binary files a/Clubs/__pycache__/views.cpython-310.pyc and b/Clubs/__pycache__/views.cpython-310.pyc differ diff --git a/Clubs/__pycache__/views_schedule.cpython-310.pyc b/Clubs/__pycache__/views_schedule.cpython-310.pyc index 5a75955..5255626 100644 Binary files a/Clubs/__pycache__/views_schedule.cpython-310.pyc and b/Clubs/__pycache__/views_schedule.cpython-310.pyc differ diff --git a/Clubs/models.py b/Clubs/models.py index 9f1f9e9..a236feb 100644 --- a/Clubs/models.py +++ b/Clubs/models.py @@ -90,17 +90,20 @@ class Request(models.Model): status = models.CharField(choices=ACCEPTED, max_length=30) def save(self, *args, **kwargs): - clubID = self.club.id - receiverClub = Club.objects.get(id=clubID) - authorizedMembers = receiverClub.authorizedMembers() - for member in authorizedMembers: + if(self.status == 'NO'): + clubID = self.club.id + receiverClub = Club.objects.get(id=clubID) + authorizedMembers = receiverClub.authorizedMembers() myNotification = Notification( message="A user sent a request to join your club!", userSender=self.user, ) + print("save creates a notification") myNotification.save() - authorizedUser = User.objects.get(id=member.user_id) - myNotification.userReceiver.add(authorizedUser) + + for member in authorizedMembers: + authorizedUser = User.objects.get(id=member.user_id) + myNotification.userReceiver.add(authorizedUser) super(Request, self).save(*args, **kwargs) diff --git a/Clubs/templates/Clubs/clubMembers.html b/Clubs/templates/Clubs/clubMembers.html index 31ec5ad..7dc30ff 100644 --- a/Clubs/templates/Clubs/clubMembers.html +++ b/Clubs/templates/Clubs/clubMembers.html @@ -8,7 +8,7 @@