On Wed, Dec 24, 2008 at 11:47 AM, Alessandro Ronchi
<[email protected]> wrote:
> 2008/12/24 Alessandro Ronchi <[email protected]>:
>
>> I thought it can be a problem of database definition.
>> I've checked and price table has emtpy column expires, but it seems
>> it's not null.
>
> The database is correct, the fields are null.
> Is the code that it's wrong, for me.
>
> qty_discounts = product.price_set.exclude(expires__isnull=False,
> expires__lt=datetime.date.today()).filter(quantity__lte=qty)
>
> filters out prices that have expires NOT NULL AND have expires before
> today, which gets all correct prices but doesn't order them.
>
> to do what we want I think it should be ordered like that:
>
> val = qty_discounts.order_by('-quantity').order_by('expires')[0].dynamic_price
>
> instead of current
>
> val = qty_discounts.order_by('-quantity')[0].dynamic_price
>
> don't you think?
With that simple mod
val = qty_discounts.order_by('-quantity', 'expires')[0].dynamic_price
I can get this result:
http://www.detectorpoint.com/product/italia-1940-45-seconda-guerra-mondiale/
The correct barred price (without expiration) and the current price
(with expiration) shown.
Without that ordering it shows the same price.
If you want I can share the template tag I use to show the old barred
price, but please correct this bug into the two trunks because now it
doesn't show the correct price if you set two.
--
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net
SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928
Rispetta l'ambiente: se non ti è necessario, non stampare questa mail
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Satchmo users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---