-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add cache to ProjectAdminAuthentication endpoint * feat: fix authenticate credential method * feat: update external views to work with new cached authentication * feat: use new projectadmindto when not cached aswell * feat: fix authenticate_credentials * feat: use __dict__ when caching the data * feat: fix user first name if user is none on external authentication * feat: optimize query on sector, queue and agents external endpoints
- Loading branch information
1 parent
b351e26
commit 1179048
Showing
9 changed files
with
160 additions
and
59 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
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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
from django_filters import rest_framework as filters | ||
|
||
from chats.apps.msgs.models import Message | ||
|
||
|
||
class MessageFilter(filters.FilterSet): | ||
class Meta: | ||
model = Message | ||
fields = ["contact", "room"] | ||
|
||
contact = filters.UUIDFilter( | ||
field_name="contact", | ||
required=False, | ||
method="filter_contact", | ||
help_text=_("Contact's UUID"), | ||
) | ||
|
||
room = filters.UUIDFilter( | ||
field_name="room", | ||
required=False, | ||
method="filter_room", | ||
help_text=_("Room's UUID"), | ||
) | ||
|
||
project = filters.UUIDFilter( | ||
field_name="project", | ||
required=False, | ||
method="filter_project", | ||
help_text=_("Projects's UUID"), | ||
) | ||
|
||
is_active = filters.BooleanFilter( | ||
field_name="is_active", | ||
required=False, | ||
method="filter_is_active", | ||
help_text=_("Is room active"), | ||
) | ||
|
||
def filter_room(self, queryset, name, value): | ||
return queryset.filter(room__uuid=value) | ||
|
||
def filter_is_active(self, queryset, name, value): | ||
return queryset.filter(room__is_active=value) | ||
|
||
def filter_project(self, queryset, name, value): | ||
return queryset.filter(room__queue__sector__project__uuid=value) | ||
|
||
def filter_contact(self, queryset, name, value): | ||
""" | ||
Return msgs given a contact. | ||
""" | ||
permission = self.request.auth | ||
queryset = queryset.filter( | ||
room__queue__sector__project=permission.project, | ||
room__contact__uuid=value, | ||
) | ||
|
||
return queryset |
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
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
Oops, something went wrong.