Beispiel #1
0
    def variation_choice(cls, variation, attributes=None, **kwargs):

        result = (yield chaining.forward).result
        if result is not None:
            return

        variant = variation.variant.downcast()
        price_adjustment = None

        if variant.is_variant:
            a = Price.calculate(product=variant, raw=True)
            b = Price.calculate(product=variant.product, raw=True)

            price_adjustment = Price(0)
            if a is not None and b is not None:
                price_adjustment = (a - b)

        values = variation.values.all().order_by('attribute')
        if attributes is not None:
            values = values.filter(attribute__in=attributes)

        values = VARIATION_VALUE_SEPERATOR.join(
            [unicode(value) for value in values]
        )

        yield call_or_format(
            VARIATION_CHOICE_FORMAT,
            variation=variation,
            variant=variant,
            values=values,
            price_adjustment=price_adjustment
        )
Beispiel #2
0
    def variation_choice(cls, variation, attributes=None, **kwargs):

        result = (yield chaining.forward).result
        if result is not None:
            return

        variant = variation.variant.downcast()
        price_adjustment = None

        if variant.is_variant:
            a = Price.calculate(product=variant, raw=True)
            b = Price.calculate(product=variant.product, raw=True)

            price_adjustment = Price(0)
            if a is not None and b is not None:
                price_adjustment = (a - b)

        values = variation.values.all().order_by('attribute')
        if attributes is not None:
            values = values.filter(attribute__in=attributes)

        values = VARIATION_VALUE_SEPERATOR.join(
            [unicode(value) for value in values])

        yield call_or_format(VARIATION_CHOICE_FORMAT,
                             variation=variation,
                             variant=variant,
                             values=values,
                             price_adjustment=price_adjustment)
Beispiel #3
0
 def __unicode__(self):
     # Do not simply supply value=self, this would encourage recursive calls to
     # __unicode__
     return call_or_format(
         VALUE_FORMAT,
         value=self.value,
         attribute=self.attribute
     )
Beispiel #4
0
def values_description(values, prefix=None):

    values = VARIATION_VALUE_SEPERATOR.join(
        [unicode(value) for value in values])

    return call_or_format(VARIATION_DESCRIPTION_FORMAT,
                          prefix=prefix,
                          values=values)
 def format(self, amount, align=-1):
     return call_or_format(self._frmt, amount=amount, align=align)
Beispiel #6
0
 def __unicode__(self):
     # Do not simply supply value=self, this would encourage recursive calls to
     # __unicode__
     return call_or_format(VALUE_FORMAT,
                           value=self.value,
                           attribute=self.attribute)
Beispiel #7
0
def values_description(values, prefix=None):

    values = VARIATION_VALUE_SEPERATOR.join([unicode(value) for value in values])

    return call_or_format(VARIATION_DESCRIPTION_FORMAT, prefix=prefix, values=values)