Beispiel #1
0
    def test_filters(self):
        """Test the label filters."""
        filter_string = "part__pk=10"

        filters = validateFilterString(filter_string, model=StockItem)

        self.assertEqual(type(filters), dict)

        bad_filter_string = "part_pk=10"

        with self.assertRaises(ValidationError):
            validateFilterString(bad_filter_string, model=StockItem)
Beispiel #2
0
    def matches_stock_item(self, item):
        """
        Test if this report template matches a given StockItem objects
        """

        filters = validateFilterString(self.filters)

        items = StockItem.objects.filter(**filters)

        return items.exists()
Beispiel #3
0
    def matches_stock_location(self, location):
        """
        Test if this label template matches a given StockLocation object
        """

        filters = validateFilterString(self.filters)

        locs = stock.models.StockLocation.objects.filter(**filters)

        locs = locs.filter(pk=location.pk)

        return locs.exists()
Beispiel #4
0
    def matches_stock_item(self, item):
        """
        Test if this label template matches a given StockItem object
        """

        filters = validateFilterString(self.filters)

        items = stock.models.StockItem.objects.filter(**filters)

        items = items.filter(pk=item.pk)

        return items.exists()
Beispiel #5
0
    def matches_stock_item(self, item):
        """Test if this report template matches a given StockItem objects."""
        try:
            filters = validateFilterString(self.filters)
            items = stock.models.StockItem.objects.filter(**filters)
        except (ValidationError, FieldError):
            return False

        # Ensure the provided StockItem object matches the filters
        items = items.filter(pk=item.pk)

        return items.exists()
Beispiel #6
0
    def matches_stock_item(self, item):
        """
        Test if this report template matches a given StockItem objects
        """

        filters = validateFilterString(self.filters)

        items = stock.models.StockItem.objects.filter(**filters)

        # Ensure the provided StockItem object matches the filters
        items = items.filter(pk=item.pk)

        return items.exists()
Beispiel #7
0
    def matches_stock_location(self, location):
        """
        Test if this label template matches a given StockLocation object
        """

        try:
            filters = validateFilterString(self.filters)
            locs = stock.models.StockLocation.objects.filter(**filters)
        except (ValidationError, FieldError):
            return False

        locs = locs.filter(pk=location.pk)

        return locs.exists()
Beispiel #8
0
    def matches_part(self, part):
        """
        Test if this label template matches a given Part object
        """

        try:
            filters = validateFilterString(self.filters)
            parts = part.models.Part.objects.filter(**filters)
        except (ValidationError, FieldError):
            return False

        parts = parts.filter(pk=part.pk)

        return parts.exists()
Beispiel #9
0
    def matches_stock_item(self, item):
        """
        Test if this label template matches a given StockItem object
        """

        try:
            filters = validateFilterString(self.filters)
            items = stock.models.StockItem.objects.filter(**filters)
        except (ValidationError, FieldError):
            # If an error exists with the "filters" field, return False
            return False

        items = items.filter(pk=item.pk)

        return items.exists()
Beispiel #10
0
def validate_purchase_order_filters(filters):
    """
    Validate filter string against PurchaseOrder model
    """

    return validateFilterString(filters, model=order.models.PurchaseOrder)
Beispiel #11
0
def validate_build_report_filters(filters):
    """
    Validate filter string against Build model
    """

    return validateFilterString(filters, model=build.models.Build)
Beispiel #12
0
def validate_part_report_filters(filters):
    """
    Validate filter string against Part model
    """

    return validateFilterString(filters, model=part.models.Part)
Beispiel #13
0
def validate_stock_item_report_filters(filters):
    """
    Validate filter string against StockItem model
    """

    return validateFilterString(filters, model=stock.models.StockItem)
Beispiel #14
0
def validate_stock_item_report_filters(filters):

    return validateFilterString(filters, model=stock.models.StockItem)
Beispiel #15
0
def validate_part_filters(filters):

    filters = validateFilterString(filters, model=part.models.Part)

    return filters
Beispiel #16
0
def validate_stock_item_filters(filters):

    filters = validateFilterString(filters, model=stock.models.StockItem)

    return filters
Beispiel #17
0
def validate_stock_location_filters(filters):

    filters = validateFilterString(filters, model=stock.models.StockLocation)

    return filters
Beispiel #18
0
def validate_sales_order_filters(filters):
    """
    Validate filter string against SalesOrder model
    """

    return validateFilterString(filters, model=order.models.SalesOrder)