diff --git a/auctions/filters.py b/auctions/filters.py index 6ecadf7..ebffea6 100755 --- a/auctions/filters.py +++ b/auctions/filters.py @@ -145,6 +145,8 @@ def generic(self, qs, value): 'unseen': {'auctiontos__opened': False}, 'no bid': {'bidding_allowed': False}, 'no sell': {'selling_allowed': False}, + 'email good': {'email_address_status': 'BAD'}, + 'email bad': {'email_address_status': 'VALID'}, } # Apply filters based on patterns diff --git a/auctions/models.py b/auctions/models.py index 3109f49..70ed423 100755 --- a/auctions/models.py +++ b/auctions/models.py @@ -1360,6 +1360,15 @@ def check_number_in_auction(number): self.bidder_number = 999 if str(self.memo) == "None": self.memo = "" + # update the email address as appropriate + if self.email and self.email_address_status == "UNKNOWN": + existing_instance = AuctionTOS.objects.filter( + email=self.email, + auction__created_by=self.auction.created_by, + email_address_status__ne="UNKNOWN" + ).order_by('-createdon').first() + if existing_instance: + self.email_address_status = existing_instance.email_address_status super().save(*args, **kwargs) @property @@ -3712,30 +3721,16 @@ def bounce_handler(sender, mail_obj, bounce_obj, raw_message, *args, **kwargs): # you can then use the message ID and/or recipient_list(email address) to identify any problematic email messages that you have sent #message_id = mail_obj['messageId'] recipient_list = mail_obj['destination'] - print("Mail bounced") - print(mail_obj) - try: - email = recipient_list[0] - print(email) - auctiontos = AuctionTOS.objects.filter(email=email) - for tos in auctiontos: - tos.email_address_status="BAD" - tos.save() - except Exception as e: - print(e) - print(recipient_list) + email = recipient_list[0] + auctiontos = AuctionTOS.objects.filter(email=email) + for tos in auctiontos: + tos.email_address_status="BAD" + tos.save() @receiver(complaint_received) def complaint_handler(sender, mail_obj, complaint_obj, raw_message, *args, **kwargs): recipient_list = mail_obj['destination'] - print("Mail complaint") - print(mail_obj) - try: - email = recipient_list[0] - print(email) - #user = User.objects.filter(email=email).first() - #if user: - # user.userdata.unsubscribe_from_all - except Exception as e: - print(e) - print(recipient_list) \ No newline at end of file + email = recipient_list[0] + user = User.objects.filter(email=email).first() + if user: + user.userdata.unsubscribe_from_all \ No newline at end of file diff --git a/auctions/tables.py b/auctions/tables.py index 59320bc..887c21a 100644 --- a/auctions/tables.py +++ b/auctions/tables.py @@ -27,8 +27,10 @@ def render_name(self, value, record): def render_email(self, value, record): email_string = f'{value}' #email_string = value - if record.user: - email_string += "" + if record.email_address_status == "BAD": + email_string += "" + if record.email_address_status == "VALID": + email_string += "" return mark_safe(email_string) class Meta: diff --git a/auctions/templates/auction_users.html b/auctions/templates/auction_users.html index 36a2654..f5dad6c 100755 --- a/auctions/templates/auction_users.html +++ b/auctions/templates/auction_users.html @@ -43,12 +43,18 @@