Example #1
0
 def _update_params(self, kwargs):
     from django.db.models.sql.constants import LOOKUP_SEP
     from money import Money
     to_append = {}
     for name, value in kwargs.items():
         if isinstance(value, Money):
             path = name.split(LOOKUP_SEP)
             if len(path) > 1:
                 field_name = currency_field_name(path[0])
             else:
                 field_name = currency_field_name(name)
             to_append[field_name] = smart_unicode(value.currency)
     kwargs.update(to_append)
     return kwargs
Example #2
0
 def _update_params(self, kwargs):
     from django.db.models.sql.constants import LOOKUP_SEP
     from money import Money
     to_append = {}
     for name, value in kwargs.items():
         if isinstance(value, Money):
             path = name.split(LOOKUP_SEP)
             if len(path) > 1:
                 field_name = currency_field_name(path[0])
             else:
                 field_name = currency_field_name(name)
             to_append[field_name] = smart_unicode(value.currency)
     kwargs.update(to_append)
     return kwargs
Example #3
0
def _expand_money_params(kwargs):
    from moneyed import Money
    from django.db.models.sql.constants import LOOKUP_SEP, QUERY_TERMS
    to_append = {}
    for name, value in kwargs.items():
        if isinstance(value, Money):
            # Get rid of __lt, __gt etc for the currency lookup
            path = name.split(LOOKUP_SEP)
            if QUERY_TERMS.has_key(path[-1]):
                clean_name = LOOKUP_SEP.join(path[:-1])
            else:
                clean_name = name

            to_append[name] = value.amount
            to_append[currency_field_name(clean_name)] = smart_unicode(value.currency)
    kwargs.update(to_append)
    return kwargs
Example #4
0
def _expand_money_params(kwargs):
    from moneyed import Money
    from django.db.models.sql.constants import LOOKUP_SEP, QUERY_TERMS
    to_append = {}
    for name, value in kwargs.items():
        if isinstance(value, Money):
            # Get rid of __lt, __gt etc for the currency lookup
            path = name.split(LOOKUP_SEP)
            if QUERY_TERMS.has_key(path[-1]):
                clean_name = LOOKUP_SEP.join(path[:-1])
            else:
                clean_name = name

            to_append[name] = value.amount
            to_append[currency_field_name(clean_name)] = smart_unicode(
                value.currency)
    kwargs.update(to_append)
    return kwargs