How to use the formulas.models.Formula.objects.filter function in formulas

To help you get started, we’ve selected a few formulas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stackdio / stackdio / stackdio / server / search / api.py View on Github external
))
        except ValueError:
            page_size = 10

        if q:
            # finds all matching blueprints that are owned by the user or
            # have been made public
            blueprints = Blueprint.objects.filter(
                Q(owner=request.user) | Q(public=True),
                Q(title__icontains=q) | Q(description__icontains=q)
            ).order_by('created')
            res.extend(serializers.BlueprintSearchSerializer(blueprints, many=True, context=context).data)

            # finds all matching formulas that are owned by the user or
            # have been made public
            formulas = Formula.objects.filter(
                Q(owner=request.user) | Q(public=True),
                Q(title__icontains=q) | Q(description__icontains=q)
            ).order_by('created')
            res.extend(serializers.FormulaSearchSerializer(formulas, many=True, context=context).data)

            # finds all matching stacks that are owned by the user
            stacks = Stack.objects.filter(
                Q(title__icontains=q) | Q(description__icontains=q),
                owner=request.user
            ).order_by('created')
            res.extend(serializers.StackSearchSerializer(stacks, many=True, context=context).data)

        # add in pagination and render the serialized and paginated data
        # paginator = Paginator(res, page_size)
        # page = paginator.page(page_index)
        # serializer = PaginationSerializer(instance=page, context=context)