Dismiss all notifications for the current user.
(self, request)
| 689 | |
| 690 | @action(detail=False, methods=['post'], url_path='dismiss-all') |
| 691 | def dismiss_all(self, request): |
| 692 | """Dismiss all notifications for the current user.""" |
| 693 | notifications = self.get_queryset() |
| 694 | |
| 695 | # Get notifications not yet dismissed |
| 696 | dismissed_ids = NotificationDismissal.objects.filter( |
| 697 | user=request.user |
| 698 | ).values_list('notification_id', flat=True) |
| 699 | to_dismiss = notifications.exclude(id__in=dismissed_ids) |
| 700 | |
| 701 | # Create dismissals for all |
| 702 | dismissals = [ |
| 703 | NotificationDismissal(user=request.user, notification=n) |
| 704 | for n in to_dismiss |
| 705 | ] |
| 706 | NotificationDismissal.objects.bulk_create(dismissals, ignore_conflicts=True) |
| 707 | |
| 708 | return Response({ |
| 709 | 'success': True, |
| 710 | 'dismissed_count': len(dismissals) |
| 711 | }) |
| 712 | |
| 713 | @action(detail=False, methods=['get'], url_path='count') |
| 714 | def unread_count(self, request): |
nothing calls this directly
no test coverage detected