-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
from typing import Optional | ||
|
||
import strawberry | ||
from komment import models, scalars, enums | ||
import strawberry_django | ||
from kammer import enums, models, scalars | ||
from strawberry import auto | ||
from typing import Optional | ||
from strawberry_django.filters import FilterLookup | ||
import strawberry_django | ||
|
||
|
||
@strawberry_django.filter(models.Comment) | ||
class CommentFilter: | ||
name: Optional[FilterLookup[str]] | None | ||
@strawberry_django.filter(models.Message) | ||
class MessageFilter: | ||
ids: list[strawberry.ID] | None | ||
search: Optional[str] | None | ||
|
||
def filter_ids(self, queryset, info): | ||
if self.ids is None: | ||
return queryset | ||
return queryset.filter(id__in=self.ids) | ||
|
||
def filter_search(self, queryset, info): | ||
if self.search is None: | ||
return queryset | ||
return queryset.filter(text__icontains=self.search) | ||
|
||
|
||
@strawberry_django.filter(models.Room) | ||
class RoomFilter: | ||
search: Optional[str] | None | ||
ids: list[strawberry.ID] | None | ||
|
||
def filter_ids(self, queryset, info): | ||
if self.ids is None: | ||
return queryset | ||
return queryset.filter(id__in=self.ids) | ||
|
||
def filter_search(self, queryset, info): | ||
if self.search is None: | ||
return queryset | ||
return queryset.filter(title__icontains=self.search) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters