大量修改UI
This commit is contained in:
@@ -257,6 +257,15 @@ class NotificationViewSet(TeamScopedViewSetMixin, ModelViewSet):
|
||||
user = self.request.user
|
||||
return queryset.filter(Q(recipient=user) | Q(recipient__isnull=True))
|
||||
|
||||
def _excluded_types(self):
|
||||
"""静音同类: ?exclude_type=billing&exclude_type=system 或逗号分隔。非法值丢弃。"""
|
||||
allowed = {choice[0] for choice in Notification.Type.choices}
|
||||
raw = self.request.query_params.getlist("exclude_type")
|
||||
types: list[str] = []
|
||||
for item in raw:
|
||||
types.extend(part.strip() for part in item.split(",") if part.strip())
|
||||
return [item for item in types if item in allowed]
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = self._recipient_scope()
|
||||
notification_type = self.request.query_params.get("type")
|
||||
@@ -264,6 +273,9 @@ class NotificationViewSet(TeamScopedViewSetMixin, ModelViewSet):
|
||||
queryset = queryset.filter(notification_type=notification_type)
|
||||
if self.request.query_params.get("unread") in {"1", "true", "yes"}:
|
||||
queryset = queryset.filter(is_read=False)
|
||||
excluded = self._excluded_types()
|
||||
if excluded:
|
||||
queryset = queryset.exclude(notification_type__in=excluded)
|
||||
return queryset
|
||||
|
||||
def _refresh_notifications(self, request):
|
||||
|
||||
Reference in New Issue
Block a user