예제 #1
0
    def __call__(self, entity, user):
        # cache = getattr(entity, '_alerts_cache', None)
        #
        # if cache is None:
        #     cache = entity._alerts_cache = list(Alert.objects
        #                                              .filter(entity_id=entity.id, is_validated=False)
        #                                              .order_by('trigger_date')
        #                                              .values_list('title', flat=True)
        #                                        )
        #
        # return FunctionFieldResultsList(FunctionFieldResult(title) for title in cache)
        cache = self._cache
        e_id = entity.id
        cached = cache.get(e_id)

        if cached is None:
            cached = cache[e_id] = [
                *Alert.objects.filter(
                    entity_id=e_id,
                    is_validated=False).order_by('trigger_date').values_list(
                        'title', flat=True)
            ]

        return FunctionFieldResultsList(
            FunctionFieldResult(title) for title in cached)
예제 #2
0
    def __call__(self, entity, user):
        cache = getattr(entity, '_memos_cache', None)

        if cache is None:
            cache = entity._memos_cache = list(
                Memo.objects.filter(entity_id=entity.id).order_by(
                    '-creation_date').values_list('content', flat=True))

        return FunctionFieldResultsList(
            FunctionFieldResult(content) for content in cache)
예제 #3
0
    def __call__(self, entity, user):
        cache = getattr(entity, '_todos_cache', None)

        if cache is None:
            cache = entity._todos_cache = list(
                ToDo.objects.filter(
                    entity_id=entity.id,
                    is_ok=False).order_by('-creation_date').values_list(
                        'title', flat=True))

        return FunctionFieldResultsList(
            FunctionFieldResult(title) for title in cache)
예제 #4
0
    def __call__(self, entity, user):
        cache = getattr(entity, '_alerts_cache', None)

        if cache is None:
            cache = entity._alerts_cache = list(
                Alert.objects.filter(
                    entity_id=entity.id,
                    is_validated=False).order_by('trigger_date').values_list(
                        'title', flat=True))

        return FunctionFieldResultsList(
            FunctionFieldResult(title) for title in cache)
예제 #5
0
    def __call__(self, entity, user):
        cache = self._cache
        e_id = entity.id
        cached = cache.get(e_id)

        if cached is None:
            cached = cache[e_id] = [
                *Memo.objects.filter(entity_id=entity.id).order_by(
                    '-creation_date').values_list('content', flat=True)
            ]

        return FunctionFieldResultsList(
            FunctionFieldResult(content) for content in cached)
예제 #6
0
    def __call__(self, entity, user):
        cache = self._cache
        e_id = entity.id
        cached = cache.get(e_id)

        if cached is None:
            cached = cache[e_id] = [
                *ToDo.objects.filter(
                    entity_id=entity.id,
                    is_ok=False).order_by('-creation_date').values_list(
                        'title', flat=True)
            ]

        return FunctionFieldResultsList(
            FunctionFieldResult(title) for title in cached)