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
@classmethod | |
def filter_by_field(cls, filter_str: str, field: str, items: QuerySet) -> QuerySet: | |
"""Filter page items by different fields""" | |
criterion = { | |
f'{field}__contains': filter_str | |
} | |
return items.filter(**criterion) |
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
class ModifiedTablibFormat(TablibFormat): | |
def export_data(self, dataset, **kwargs): | |
return self.export_set(dataset, **kwargs) | |
def export_set(self, dataset, freeze_panes=True): | |
""" | |
Returns XLSX representation of Dataset. | |
""" | |
wb = Workbook() |
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
from django.conf import settings | |
from channels.generic.websocket import AsyncJsonWebsocketConsumer | |
from .exceptions.client import ClientError | |
from .utils import get_chat_or_error, create_message, get_page | |
class ChatConsumer(AsyncJsonWebsocketConsumer): | |
""" | |
This chat consumer handles websocket connections for chat clients. |
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
class IsPermittedAccess(BasePermission): | |
@staticmethod | |
def get_code_name(view, request, permission_map): | |
model_name = view.queryset.model._meta.model_name | |
app_label = view.queryset.model._meta.app_label | |
return '{}.{}_{}'.format(app_label, | |
permission_map.get(request.method), | |
model_name) |
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
from django.db import models | |
from django.db.models import Q | |
from wirelesstag.models import TagManager | |
from guardian.shortcuts import get_objects_for_user | |
class AlertQuerySet(models.QuerySet): | |
def for_user(self, user): | |
if user.groups.filter(name='Company administrators').exists(): | |
alerts = self.filter( |